class VectorPath

Inherits: Resource

Represents a vector path containing curves and geometric shapes that can be rasterized to any dimension.

Public

Constructors

VectorPath

VectorPath(const Size2 &canvasSize = kDefaultCanvasSize)

Methods

SetCanvasSize

void SetCanvasSize(const Size2 &canvasSize)

Determines the size of the coordinate system in which to draw the path.

This will be used for scaling/offset when rasterizing the path and for bounds testing.

GetCanvasSize

const Size2 &GetCanvasSize() const

SetDrawCursor

VectorPath &SetDrawCursor(const Vector2 &cursor)

Changes the current location of the draw cursor.

Any command using a draw cursor will use this value as the starting point.

SetSolidity

VectorPath &SetSolidity(VectorGraphicsPathSolidity solidity)

Sets the solidity of the drawn path.

By default paths will draw solid shapes, but changing the solidity to Hole allows you to create holes in previously drawn paths. Solidity should be set /after/ recording a path, and will be applied to the last recorded path.

ClosePath

VectorPath &ClosePath()

Closes a path by connecting the first and last path points.

This should be called before starting a new path.

DrawLineTo

VectorPath &DrawLineTo(const Vector2 &target)

Draws a line from the current cursor position to the target position.

Advances the cursor to the target position.

DrawArcTo

VectorPath &DrawArcTo(const Vector2 &middlePoint, const Vector2 &endPoint, float radius)

Draws an arc using three points on the arc (last cursor position, and two provided points), and a radius of the circle that the arc would be a part of..

Advances the cursor to the arc end point.

DrawQuadraticBezierTo

VectorPath &DrawQuadraticBezierTo(const Vector2 &controlPoint, const Vector2 &endPoint)

Draws a quadratic bezier curve using the current cursor position as the starting point.

Advanced the cursor to the curve end point.

DrawCubicBezierTo

VectorPath &DrawCubicBezierTo(const Vector2 &controlPoint1, const Vector2 &controlPoint2, const Vector2 &endPoint)

Draws a cubic bezier curve using the current cursor position as the starting point.

Advanced the cursor to the curve end point.

DrawRectangle

VectorPath &DrawRectangle(const Area2 &area)

Draws a rectangle.

DrawRoundedRectangle

VectorPath &DrawRoundedRectangle(const Area2 &area, float cornerRadius)

Draws a rectangle with rounded corners, all corners having the same radius.

DrawRoundedRectangle

VectorPath &DrawRoundedRectangle(const Area2 &area, float topLeftCornerRadius, float topRightCornerRadius, float bottomLeftCornerRadius, float bottomRightCornerRadius)

Draws a rectangle with rounded corners, with explicit radius for each corner.

DrawCircle

VectorPath &DrawCircle(const Vector2 &origin, float radius)

Draws a circle.

DrawEllipse

VectorPath &DrawEllipse(const Vector2 &origin, const Vector2 &radius)

Draws an ellipse.

DrawArc

VectorPath &DrawArc(const Vector2 &center, float radius, Radian startAngle, Radian endAngle, VectorGraphicsPathWinding direction = VectorGraphicsPathWinding::Clockwise)

Draws an arc.

Note if the start of the arc doesn't correspond to the last drawn cursor position, and line will be drawn between the last drawn point (if any) and the arc start.

center
Center of the circle that the arc is a part of.
radius
Radius of the circle that the arc is a part of.
startAngle
Angle at which to start drawing the arc.
endAngle
Angle at which to start drawing the arc.
direction
Direction of the arc. Doesn't affect coordinate system of or , but the direction in which the arc is filled. e.g. start angle 0, end angle 90 and direction 'counter-clickwise' will result in a 270 degree arc.

SetFillPaint

VectorPath &SetFillPaint(const VectorGraphicsPaint &paint)

Sets the paint to use when calling DrawFill().

SetStrokePaint

VectorPath &SetStrokePaint(const VectorGraphicsPaint &paint)

Sets the paint to use when calling DrawStroke().

SetStrokeWidth

VectorPath &SetStrokeWidth(float strokeWidth)

Sets the width of the stroke to draw.

SetMiterLimit

VectorPath &SetMiterLimit(float miterLimit)

Sets the limit that controls when is sharp stroke corner beveled.

SetLineCapType

VectorPath &SetLineCapType(VectorGraphicsLineCapType lineCap)

Sets the style that controls how is the line end rendered.

SetLineJoinType

VectorPath &SetLineJoinType(VectorGraphicsLineJoinStyle lineJoin)

Sets the style that controls how are line bends rendered.

SetAlpha

VectorPath &SetAlpha(float alpha)

Sets the transparency of the drawn shape.

SetBlendMode

VectorPath &SetBlendMode(VectorGraphicsBlendMode blendMode)

Sets the blend mode that determines how a shape blends with existing shapes in the path.

SetAntialiasShapes

VectorPath &SetAntialiasShapes(bool antialiasShapes)

Enables or disables antialiasing for the shape.

SetScissorRectangle

VectorPath &SetScissorRectangle(const Area2 &scissorArea)

Sets a rectangle to clip shape rendering to.

ClearScissor

VectorPath &ClearScissor()

Clears a previously set scissor rectangle.

DrawFill

VectorPath &DrawFill()

Draws the fill for the recorded shape.

DrawStroke

VectorPath &DrawStroke()

Draws the stroke for the recorded shape.

GetCommands

const Vector<VectorPathCommand> &GetCommands() const

Returns all the currently recorded commands.

GetCommandStates

const Vector<VectorPathState> &GetCommandStates() const

Returns all the states associated with the recorded commands.

CreateRenderable

SPtr<render::VectorPathRenderable> CreateRenderable(const VectorGraphicsSettings &settings) const

Creates a renderable object that can be used for rasterizing the vector path into pixels.

staticCreateShared

static SPtr<VectorPath> CreateShared(const Size2 &canvasSize = kDefaultCanvasSize)

Creates a new empty vector path.

canvasSize
Determines the size of the coordinate system in which to draw the path. This will be used for scaling/offset when rasterizing the path and for bounds testing.

Returns: Newly created path.

staticCreate

static HVectorPath Create(const Size2 &canvasSize = kDefaultCanvasSize)

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Private

Fields

mCanvasSize

Size2 mCanvasSize

mCurrentState

VectorPathState mCurrentState

mCommands

Vector<VectorPathCommand> mCommands

mCommandStates

Vector<VectorPathState> mCommandStates