CUGL 2.1
Cornell University Game Library
Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cugl::scene2::CanvasNode Class Reference

#include <CUCanvasNode.h>

Inheritance diagram for cugl::scene2::CanvasNode:
cugl::scene2::SceneNode

Classes

class  Paint
 

Public Types

enum  Winding : int { Winding::NONE = 0, Winding::CCW = 1, Winding::CW = 2 }
 
enum  FillRule : int {
  FillRule::NONZERO = 0, FillRule::EVENODD = 1, FillRule::STENCIL = 2, FillRule::CLIPFILL = 3,
  FillRule::MASKFILL = 4
}
 

Public Member Functions

 CanvasNode ()
 
 ~CanvasNode ()
 
virtual void dispose () override
 
virtual bool init () override
 
virtual bool initWithBounds (const Size size) override
 
virtual bool initWithBounds (float width, float height) override
 
virtual bool initWithBounds (const Rect rect) override
 
virtual bool initWithBounds (float x, float y, float width, float height) override
 
virtual bool initWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data) override
 
size_t pages () const
 
void paginate (size_t size)
 
size_t getEditPage ()
 
void setEditPage (size_t page)
 
size_t getDrawPage ()
 
void setDrawPage (size_t page)
 
void clearPage ()
 
void clearAll ()
 
virtual void draw (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint) override
 
void saveState ()
 
void restoreState ()
 
void resetState ()
 
float getFringe () const
 
void setFringe (float fringe)
 
float getGlobalAlpha ()
 
void setGlobalAlpha (float alpha)
 
const Affine2getCommandTransform ()
 
void setCommandTransform (const Affine2 &transform)
 
void clearCommandTransform ()
 
void translateCommands (const Vec2 p)
 
void translateCommands (float x, float y)
 
void scaleCommands (const Vec2 s)
 
void scaleCommands (float sx, float sy)
 
void rotateCommands (float angle)
 
void skewXCommands (float angle)
 
void skewYCommands (float angle)
 
const std::shared_ptr< Scissor > & getLocalScissor () const
 
void setLocalScissor (const std::shared_ptr< Scissor > &scissor)
 
void applyLocalScissor (const std::shared_ptr< Scissor > &scissor)
 
void clearLocalScissor ()
 
Winding getWinding () const
 
void setWinding (Winding winding)
 
FillRule getFillRule () const
 
void setFillRule (FillRule rule)
 
Color4 getFillColor () const
 
void setFillColor (Color4 color)
 
const std::shared_ptr< Paint > & getFillPaint () const
 
void setFillPaint (const std::shared_ptr< Paint > &paint)
 
Color4 getStrokeColor () const
 
void setStrokeColor (Color4 color)
 
const std::shared_ptr< Paint > & getStrokePaint () const
 
void setStrokePaint (const std::shared_ptr< Paint > &paint)
 
float getStrokeWidth () const
 
void setStrokeWidth (float width)
 
float getMitreLimit () const
 
void setMitreLimit (float limit)
 
poly2::Joint getLineJoint ()
 
void setLineJoint (poly2::Joint joint)
 
poly2::EndCap getLineCap ()
 
void setLineCap (poly2::EndCap cap)
 
GLenum getBlendEquation () const
 
void setBlendEquation (GLenum equation)
 
void setSrcBlendFunc (GLenum func)
 
void setSrcBlendFunc (GLenum srcRGB, GLenum srcAlpha)
 
GLenum getSrcRGBFunc () const
 
GLenum getSrcAlphaFunc () const
 
void setDstBlendFunc (GLenum func)
 
void setDstBlendFunc (GLenum dstRGB, GLenum dstAlpha)
 
GLenum getDstRGBFunc () const
 
GLenum getDstAlphaFunc () const
 
void beginPath ()
 
void moveTo (const Vec2 pos)
 
void moveTo (float x, float y)
 
void lineTo (const Vec2 pos)
 
void lineTo (float x, float y)
 
void bezierTo (const Vec2 c1, const Vec2 c2, const Vec2 p)
 
void bezierTo (float c1x, float c1y, float c2x, float c2y, float px, float py)
 
void quadTo (const Vec2 c, const Vec2 p)
 
void quadTo (float cx, float cy, float px, float py)
 
void arcTo (const Vec2 center, float r, float a0, float a1, bool ccw=true)
 
void arcTo (float cx, float cy, float r, float a0, float a1, bool ccw=true)
 
void arcTo (const Vec2 s, const Vec2 e, float radius)
 
void arcTo (float sx, float sy, float ex, float ey, float radius)
 
void closePath ()
 
void drawArc (const Vec2 center, float r, float a0, float a1, bool ccw=true)
 
void drawArc (float cx, float cy, float r, float a0, float a1, bool ccw=true)
 
void drawRect (const Rect rect)
 
void drawRect (float x, float y, float w, float h)
 
void drawRoundedRect (const Rect rect, float r)
 
void drawRoundedRect (float x, float y, float w, float h, float r)
 
void drawRoundedRectVarying (const Rect rect, float radBL, float radTL, float radTR, float radBR)
 
void drawRoundedRectVarying (float x, float y, float w, float h, float radBL, float radTL, float radTR, float radBR)
 
void drawEllipse (const Vec2 center, const Size size)
 
void drawEllipse (const Rect bounds)
 
void drawEllipse (float cx, float cy, float rx, float ry)
 
void drawCircle (const Vec2 center, float r)
 
void drawCircle (float cx, float cy, float r)
 
void fillPaths ()
 
void strokePaths ()
 
const std::shared_ptr< Font > & getFont () const
 
void setFont (const std::shared_ptr< Font > &font)
 
float getFontSize () const
 
void setFontSize (float size)
 
float getFontBlur () const
 
void setFontBlur (float blur)
 
float getTextSpacing () const
 
void setTextSpacing (float spacing)
 
HorizontalAlign getHorizontalTextAlign () const
 
void setHorizontalTextAlign (HorizontalAlign align)
 
VerticalAlign getVerticalTextAlign () const
 
void setVerticalTextAlign (VerticalAlign align)
 
void drawText (const Vec2 p, const std::string text)
 
void drawText (float x, float y, const std::string text)
 
void drawText (const Vec2 p, const char *substr, const char *end)
 
void drawText (float x, float y, const char *substr, const char *end)
 
void drawTextBox (const Vec2 p, float width, const std::string text)
 
void drawTextBox (float x, float y, float width, const std::string text)
 
void drawTextBox (const Vec2 p, float width, const char *substr, const char *end)
 
void drawTextBox (float x, float y, float width, const char *substr, const char *end)
 
- Public Member Functions inherited from cugl::scene2::SceneNode
 SceneNode ()
 
 ~SceneNode ()
 
virtual bool initWithPosition (const Vec2 pos)
 
bool initWithPosition (float x, float y)
 
virtual std::shared_ptr< SceneNodecopy (const std::shared_ptr< SceneNode > &dst) const
 
unsigned int getTag () const
 
void setTag (unsigned int tag)
 
const std::string getName () const
 
void setName (const std::string name)
 
const std::string getClassName () const
 
virtual std::string toString (bool verbose=false) const
 
 operator std::string () const
 
const Vec2 getPosition () const
 
void setPosition (const Vec2 &position)
 
void setPosition (float x, float y)
 
float getPositionX (void) const
 
void setPositionX (float x)
 
float getPositionY (void) const
 
void setPositionY (float y)
 
Vec2 getWorldPosition () const
 
const Size getContentSize () const
 
virtual void setContentSize (const Size size)
 
virtual void setContentSize (float width, float height)
 
float getContentWidth () const
 
void setContentWidth (float width)
 
float getContentHeight () const
 
void setContentHeight (float height)
 
virtual Rect getLayoutBounds () const
 
Size getSize () const
 
float getWidth () const
 
float getHeight () const
 
Rect getBoundingBox () const
 
virtual void setAnchor (const Vec2 anchor)
 
virtual void setAnchor (float x, float y)
 
const Vec2 getAnchor () const
 
Vec2 getAnchorInPixels ()
 
Color4 getColor () const
 
virtual void setColor (Color4 color)
 
Color4 getAbsoluteColor ()
 
bool isVisible () const
 
void setVisible (bool visible)
 
bool hasRelativeColor () const
 
void setRelativeColor (bool flag)
 
std::shared_ptr< ScissorgetScissor () const
 
void setScissor (const std::shared_ptr< Scissor > &scissor)
 
void setScissor ()
 
const Vec2 getScale () const
 
float getScaleX () const
 
float getScaleY () const
 
void setScale (float scale)
 
void setScale (const Vec2 vec)
 
void setScale (float sx, float sy)
 
float getAngle ()
 
void setAngle (float angle)
 
const Affine2getTransform () const
 
const Affine2getAlternateTransform () const
 
void setAlternateTransform (const Affine2 &transform)
 
bool withAlternateTransform ()
 
void chooseAlternateTransform (bool active)
 
const Affine2getNodeToParentTransform () const
 
Affine2 getParentToNodeTransform () const
 
Affine2 getNodeToWorldTransform () const
 
Affine2 getWorldToNodeTransform () const
 
Vec2 screenToNodeCoords (const Vec2 screenPoint) const
 
Vec2 worldToNodeCoords (const Vec2 worldPoint) const
 
Vec2 nodeToScreenCoords (const Vec2 nodePoint) const
 
Vec2 nodeToWorldCoords (const Vec2 nodePoint) const
 
Vec2 parentToNodeCoords (const Vec2 parentPoint) const
 
Vec2 nodeToParentCoords (const Vec2 nodePoint) const
 
size_t getChildCount () const
 
std::shared_ptr< SceneNodegetChild (unsigned int pos)
 
const std::shared_ptr< SceneNode > & getChild (unsigned int pos) const
 
template<typename T >
std::shared_ptr< T > getChild (unsigned int pos) const
 
std::shared_ptr< SceneNodegetChildByTag (unsigned int tag) const
 
template<typename T >
std::shared_ptr< T > getChildByTag (unsigned int tag) const
 
std::shared_ptr< SceneNodegetChildByName (const std::string name) const
 
template<typename T >
std::shared_ptr< T > getChildByName (const std::string name) const
 
std::vector< std::shared_ptr< SceneNode > > getChildren ()
 
const std::vector< std::shared_ptr< SceneNode > > & getChildren () const
 
void addChild (const std::shared_ptr< SceneNode > &child)
 
void addChildWithTag (const std::shared_ptr< SceneNode > &child, unsigned int tag)
 
void addChildWithName (const std::shared_ptr< SceneNode > &child, const std::string name)
 
void swapChild (const std::shared_ptr< SceneNode > &child1, const std::shared_ptr< SceneNode > &child2, bool inherit=false)
 
SceneNodegetParent ()
 
const SceneNodegetParent () const
 
Scene2getScene ()
 
const Scene2getScene () const
 
void removeFromParent ()
 
virtual void removeChild (unsigned int pos)
 
void removeChild (const std::shared_ptr< SceneNode > &child)
 
void removeChildByTag (unsigned int tag)
 
void removeChildByName (const std::string name)
 
virtual void removeAllChildren ()
 
void setPriority (float priority)
 
float getPriority ()
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch, const Affine2 &transform, Color4 tint)
 
virtual void render (const std::shared_ptr< SpriteBatch > &batch)
 
const std::shared_ptr< Layout > & getLayout () const
 
void setLayout (const std::shared_ptr< Layout > &layout)
 
virtual void doLayout ()
 

Static Public Member Functions

static std::shared_ptr< CanvasNodealloc ()
 
static std::shared_ptr< CanvasNodeallocWithBounds (const Size size)
 
static std::shared_ptr< CanvasNodeallocWithBounds (float width, float height)
 
static std::shared_ptr< CanvasNodeallocWithBounds (const Rect rect)
 
static std::shared_ptr< CanvasNodeallocWithBounds (float x, float y, float width, float height)
 
static std::shared_ptr< CanvasNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 
- Static Public Member Functions inherited from cugl::scene2::SceneNode
static std::shared_ptr< SceneNodealloc ()
 
static std::shared_ptr< SceneNodeallocWithPosition (const Vec2 pos)
 
static std::shared_ptr< SceneNodeallocWithPosition (float x, float y)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Size size)
 
static std::shared_ptr< SceneNodeallocWithBounds (float width, float height)
 
static std::shared_ptr< SceneNodeallocWithBounds (const Rect rect)
 
static std::shared_ptr< SceneNodeallocWithBounds (float x, float y, float width, float height)
 
static std::shared_ptr< SceneNodeallocWithData (const Scene2Loader *loader, const std::shared_ptr< JsonValue > &data)
 

Protected Attributes

std::vector< Page * > _canvas
 
size_t _draw
 
size_t _edit
 
- Protected Attributes inherited from cugl::scene2::SceneNode
Vec2 _position
 
Vec2 _anchor
 
Size _contentSize
 
Color4 _tintColor
 
bool _hasParentColor
 
bool _isVisible
 
std::shared_ptr< Scissor_scissor
 
Vec2 _scale
 
float _angle
 
Affine2 _transform
 
bool _useTransform
 
Affine2 _combined
 
std::vector< std::shared_ptr< SceneNode > > _children
 
SceneNode_parent
 
Scene2_graph
 
std::shared_ptr< Layout_layout
 
int _childOffset
 
unsigned int _tag
 
std::string _name
 
size_t _hashOfName
 
std::string _classname
 
float _priority
 
std::shared_ptr< JsonValue_json
 

Detailed Description

This is a scene graph node to support scalable vector graphics

WARNING: This is a highly experimental class. This class is the foundation for SVG support in the future roadmap, but it still needs significant testing. Use this class at your own risk.

A canvas node is a drawing slate, not unlike the classic drawing Turtle found in most programming languages. The programmer issues a sequence of drawing commands, and these commands produce an image on the screen. The commands are stored so that the image is shown every animation frame. However, the programmer can change or erase the drawing commands at any time, thus creating arbitrary animation effects.

There are actually two ways that a programmer can use a canvas node to animate the image. One way is to erase and reissue the drawing commands every animation frame. But the other way to make use of pages. A canvas can have any number of pages. At any given time, getEditPage is the page that receives the drawing commands while getDrawPage is the page whose drawing commands are shown on the screen. This allows the user to save multiple drawings and then switch between them, just as SpriteNode does for sprite sheets.

When drawing to a canvas node, it is often useful to think of units as pixels. Indeed, if the canvas node is the size of the display and anchored in the bottom left corner, this is indeed the case. However, a canvas node can itself be transformed just like any scene graph node, including scaling and rotating.

It is important to stress that this node is designed for complex noninteractive graphics. This node does not remember the format or geometry of any shape or object drawn. This is particularly true for text, which is immediately rendered to a mesh, with all glyph information lost. If the user needs to interact with part of the image, you should use a dedicated-purpose scene graph node for that element, such as PolygonNode or Label.

The API for this node is designed to be similar to the SVG API, allowing this class to render some subset of SVG files. However, there are some important differences. Most notably, the origin of this scene graph node is, as is the case for all scene graph nodes, in the bottom left corner. This is different from an SVG file where the origin is in the top left and the y-axis increases downwards. A conversion between these two formats is currently in development and will be released at a later date.

Much of the code for canvas nodes is heavily inspired by the nanovg framework, developed by Mikko Mononen (memon.nosp@m.@ins.nosp@m.ide.o.nosp@m.rg). However, there are numerous optimizations and changes to make it compatible with the CUGL scene graph architecture.

Member Enumeration Documentation

◆ FillRule

An enum to specify the winding rule for filled polygons

This rule specifies how to fill a polygon in the case of multiple subpaths and self-intersections. See

 https://en.wikipedia.org/wiki/Nonzero-rule

for a discussion of how the default rule works.

In addition, this category includes rules for clipping and masking. That is because, due to the way canvas nodes are designed, any non-trivial use of the stencil buffer mandates an even-odd fill rule.

Enumerator
NONZERO 

Uses the non-zero winding rule (DEFAULT)

If a stencil was previously created by the FillRule#STENCIL rule, this fill rule with erase that stencil.

EVENODD 

Uses the even-odd rule

If a stencil was previously created by the FillRule#STENCIL rule, this fill rule with erase that stencil.

STENCIL 

Creates a stencil buffer with this shape via an even-odd rule.

This fill rule writes to the stencil buffer but it does not draw to the screen. It is used in combination with FillRule#CLIPFILL and FillRule#MASKFILL to provide visual effects.

CLIPFILL 

Uses the even-odd rule to draw a shape clipped to the stencil buffer.

This rule must be preceded by a drawing sequence using the fill rule FillRule#STENCIL to have any effect.

MASKFILL 

Uses the even-odd rule to draw a shape masked by the stencil buffer.

This rule must be preceded by a drawing sequence using the fill rule FillRule#STENCIL to have any effect.

◆ Winding

An enum to allow the user to specify an explicit winding

This enum allows you to specify the winding order when creating a new path. A rule other than NONE will guarantee your path has a certain orientation even if you generate a path in the wrong order.

Enumerator
NONE 

Use the default, given orientation for each path

CCW 

Use a counter-clockwise orientation for each path

CW 

Use a clockwise orientation for each path

Constructor & Destructor Documentation

◆ CanvasNode()

cugl::scene2::CanvasNode::CanvasNode ( )
inline

Creates an uninitialized canvas node.

You must initialize this canvas node before use.

NEVER USE A CONSTRUCTOR WITH NEW. If you want to allocate a Node on the heap, use one of the static constructors instead.

◆ ~CanvasNode()

cugl::scene2::CanvasNode::~CanvasNode ( )
inline

Deletes this canvas node, disposing all resources

Member Function Documentation

◆ alloc()

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::alloc ( )
inlinestatic

Returns a newly allocated a canvas node the size of the display.

The bounding box of the node is the current screen size. The node is anchored in the center and has position (width/2,height/2) in the parent space. The node origin is the (0,0) at the bottom left corner of the bounding box.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Returns
a newly allocated a canvas node the size of the display.

◆ allocWithBounds() [1/4]

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::allocWithBounds ( const Rect  rect)
inlinestatic

Returns a newly allocated a canvas node with the given bounds.

The rectangle origin is the bottom left corner of the node in parent space, and corresponds to the origin of the Node space. The size defines its content width and height in node space. The node anchor is placed in the bottom left corner.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
rectThe bounds of the node in parent space
Returns
a newly allocated a canvas node with the given bounds.

◆ allocWithBounds() [2/4]

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::allocWithBounds ( const Size  size)
inlinestatic

Returns a newly allocated a canvas node with the given size.

The size defines the content size. The bounding box of the node is (0,0,width,height) and is anchored in the bottom left corner (0,0). The node is positioned at the origin in parent space.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
sizeThe size of the node in parent space
Returns
a newly allocated a canvas node with the given size.

◆ allocWithBounds() [3/4]

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::allocWithBounds ( float  width,
float  height 
)
inlinestatic

Returns a newly allocated a canvas node with the given size.

The size defines the content size. The bounding box of the node is (0,0,width,height) and is anchored in the bottom left corner (0,0). The node is positioned at the origin in parent space.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
widthThe width of the node in parent space
heightThe height of the node in parent space
Returns
a newly allocated a canvas node with the given size.

◆ allocWithBounds() [4/4]

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::allocWithBounds ( float  x,
float  y,
float  width,
float  height 
)
inlinestatic

Returns a newly allocated a canvas node with the given bounds.

The rectangle origin is the bottom left corner of the node in parent space, and corresponds to the origin of the Node space. The size defines its content width and height in node space. The node anchor is placed in the bottom left corner.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
xThe x-coordinate of the node origin in parent space
yThe y-coordinate of the node origin in parent space
widthThe width of the node in parent space
heightThe height of the node in parent space
Returns
a newly allocated a canvas node with the given bounds.

◆ allocWithData()

static std::shared_ptr<CanvasNode> cugl::scene2::CanvasNode::allocWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
inlinestatic

Returns a newly allocated a canvas node with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports the following attribute values:

"pages":     A positive integer indicating the number of pages
"edit":      A positive integer indicating the active edit page
"draw":      A positive integer indicating the active draw page

All attributes are optional. There are no required attributes. There are currently no options for drawing to a canvas node in in the JSON (the canvas will start out blank). Serialized drawing commands are a feature for a future release.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
a newly allocated a canvas node with the given JSON specificaton.

◆ applyLocalScissor()

void cugl::scene2::CanvasNode::applyLocalScissor ( const std::shared_ptr< Scissor > &  scissor)

Applies the given scissor to the stack.

If there is no active local scissor, this method is the same as setLocalScissor. Otherwise, this method will generate a new local scissor by calling Scissor#intersect on the previous local scisor. . The intersection will take place in the coordinate system of this scissor.

Parameters
scissorThe local scissor to add

◆ arcTo() [1/4]

void cugl::scene2::CanvasNode::arcTo ( const Vec2  center,
float  r,
float  a0,
float  a1,
bool  ccw = true 
)

Adds an arc segment sweeping from angle a0 to a1.

The arc center is at is at c and has radius is r. The method will draw a straight line from the previous point in the path to the point at angle a0. It will then sweep the arc from angle a0 to a1. The value ccw determines whether the arc sweeps counter clockwise or clockwise, as it is not necessarily possible to tell from the angles themselves.

If there is no current path, this method creates a new subpath starting at the point for a0. Note that this differs from other drawing commands that would start a new path at the origin. The command transform is applied to this method when called.

Parameters
centerThe arc center
rThe arc radius
a0The starting angle of the arc
a1The ending angle of the arc
ccwWhether draw the arc counter clockwise

◆ arcTo() [2/4]

void cugl::scene2::CanvasNode::arcTo ( const Vec2  s,
const Vec2  e,
float  radius 
)

Adds an arc segment whose corner is defined by the previous point.

The previous point acts as the center for the arc, which is drawn through the two points with the given radius.

If there is no current path, this method creates a new subpath starting at point s. Note that this differs from other drawing commands that would start a new path at the origin. The command transform is applied to this method when called.

Parameters
sThe start of the arc
eThe end of the arc
radiusThe arc radius

◆ arcTo() [3/4]

void cugl::scene2::CanvasNode::arcTo ( float  cx,
float  cy,
float  r,
float  a0,
float  a1,
bool  ccw = true 
)
inline

Adds an arc segment sweeping from angle a0 to a1.

The arc center is at is at (cx,cy) and has radius is r. The method will draw a straight line from the previous point in the path to the point at angle a0. It will then sweep the arc from angle a0 to a1. The value ccw determines whether the arc sweeps counter clockwise or clockwise, as it is not necessarily possible to tell from the angles themselves.

If there is no current path, this method creates a new subpath starting at the point for a0. Note that this differs from other drawing commands that would start a new path at the origin. The command transform is applied to this method when called.

Parameters
cxThe x-coordinate of the arc center
cyThe y-coordinate of the arc center
rThe arc radius
a0The starting angle of the arc
a1The ending angle of the arc
ccwWhether draw the arc counter clockwise

◆ arcTo() [4/4]

void cugl::scene2::CanvasNode::arcTo ( float  sx,
float  sy,
float  ex,
float  ey,
float  radius 
)
inline

Adds an arc segment whose corner is defined by the previous point.

The previous point acts as the center for the arc, which is drawn through the two points with the given radius.

If there is no current path, this method creates a new subpath starting at point (sx,sy). Note that this differs from other drawing commands that would start a new path at the origin. The command transform is applied to this method when called.

Parameters
sxThe x-coordinate of the start of the arc
syThe y-coordinate of the start of the arc
exThe x-coordinate of the end of the arc
eyThe y-coordinate of the end of the arc
radiusThe arc radius

◆ beginPath()

void cugl::scene2::CanvasNode::beginPath ( )

Clears the current path and sub-paths.

This method should be called before drawing a new path. Otherwise the commands will simply append to the existing paths.

The standard way to draw paths on a canvas is to first call this method and then call moveTo to start the path. To create a subpath (for holes or disjoint polygons) simple call moveTo again.

◆ bezierTo() [1/2]

void cugl::scene2::CanvasNode::bezierTo ( const Vec2  c1,
const Vec2  c2,
const Vec2  p 
)

Adds a cubic bezier segment from the previous point.

The control points specify the tangents as described in Spline2.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
c1The first control point
c2The second control point
pThe end of the bezier segment

◆ bezierTo() [2/2]

void cugl::scene2::CanvasNode::bezierTo ( float  c1x,
float  c1y,
float  c2x,
float  c2y,
float  px,
float  py 
)
inline

Adds a cubic bezier segment from the previous point.

The control points specify the tangents as described in Spline2.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
c1xThe x-coordinate of the first control point
c1yThe y-coordinate of the first control point
c2xThe x-coordinate of the second control point
c2yThe y-coordinate of the second control point
pxThe x-coordinate of the bezier end
pyThe y-coordinate of the bezier end

◆ clearAll()

void cugl::scene2::CanvasNode::clearAll ( )

Clears the drawing commands from all pages.

◆ clearCommandTransform()

void cugl::scene2::CanvasNode::clearCommandTransform ( )

Resets the command transform to an identity matrix.

When this method is called all subsequent calls will be applied in the native coordinate space of the canvas node.

For more information on how this transform is applied to commands, see getCommandTransform.

◆ clearLocalScissor()

void cugl::scene2::CanvasNode::clearLocalScissor ( )

Resets and disables scissoring for this canvas.

Clearing the local scissor will not reveal any commands previously clipped by the local scissor. In addition, this method has no effect on the global scissor SceneNode#getScissor.

◆ clearPage()

void cugl::scene2::CanvasNode::clearPage ( )

Clears the drawing commands for the active edit page.

Any other page is uneffected. This method should be called before drawing to a page, as otherwise the commands are appended to any existing drawing commands.

◆ closePath()

void cugl::scene2::CanvasNode::closePath ( )

Closes the current subpath with a line segment.

While this method closes the subpath, it does not start a new subpath. You will need to call moveTo to do that.

◆ dispose()

virtual void cugl::scene2::CanvasNode::dispose ( )
overridevirtual

Disposes all of the resources used by this canvas node.

A disposed node can be safely reinitialized. Any children owned by this node will be released. They will be deleted if no other object owns them.

It is unsafe to call this on a Node that is still currently inside of a scene graph.

Reimplemented from cugl::scene2::SceneNode.

◆ draw()

virtual void cugl::scene2::CanvasNode::draw ( const std::shared_ptr< SpriteBatch > &  batch,
const Affine2 transform,
Color4  tint 
)
overridevirtual

Draws the drawing page via the given SpriteBatch.

This method only worries about drawing the current node. It does not attempt to render the children.

Parameters
batchThe SpriteBatch to draw with.
transformThe global transformation matrix.
tintThe tint to blend with the Node color.

Reimplemented from cugl::scene2::SceneNode.

◆ drawArc() [1/2]

void cugl::scene2::CanvasNode::drawArc ( const Vec2  center,
float  r,
float  a0,
float  a1,
bool  ccw = true 
)

Creates a new circle arc subpath, sweeping from angle a0 to a1.

The arc center is at is at c and has radius is r. The new subpath will start at the point corresponding to angle a0. The value ccw determines whether the arc sweeps counter clockwise or clockwise, as it is not necessarily possible to tell this from the angles themselves.

The command transform is applied to this method when called.

Parameters
centerThe arc center
rThe arc radius
a0The starting angle of the arc
a1The ending angle of the arc
ccwWhether draw the arc counter clockwise

◆ drawArc() [2/2]

void cugl::scene2::CanvasNode::drawArc ( float  cx,
float  cy,
float  r,
float  a0,
float  a1,
bool  ccw = true 
)
inline

Creates a new circle arc subpath, sweeping from angle a0 to a1.

The arc center is at is at (cx,cy) and has radius is r. The new subpath will start at the point corresponding to angle a0. The value ccw determines whether the arc sweeps counter clockwise or clockwise, as it is not necessarily possible to tell this from the angles themselves.

The command transform is applied to this method when called.

Parameters
cxThe x-coordinate of the arc center
cyThe y-coordinate of the arc center
rThe arc radius
a0The starting angle of the arc
a1The ending angle of the arc
ccwWhether draw the arc counter clockwise

◆ drawCircle() [1/2]

void cugl::scene2::CanvasNode::drawCircle ( const Vec2  center,
float  r 
)
inline

Creates a new circle shaped sub-path.

Parameters
centerThe circle center
rThe circle radius

◆ drawCircle() [2/2]

void cugl::scene2::CanvasNode::drawCircle ( float  cx,
float  cy,
float  r 
)

Creates a new circle shaped sub-path.

Parameters
cxThe x-coordinate of the circle center
cyThe y-coordinate of the circle center
rThe circle radius

◆ drawEllipse() [1/3]

void cugl::scene2::CanvasNode::drawEllipse ( const Rect  bounds)

Creates a new ellipse shaped subpath.

Note that the bounding rectangle defines the bottom left corner of the ellipse and not the center.

The command transform is applied to this method when called.

Parameters
boundsThe rectangle bounding this ellipse

◆ drawEllipse() [2/3]

void cugl::scene2::CanvasNode::drawEllipse ( const Vec2  center,
const Size  size 
)
inline

Creates a new ellipse shaped subpath.

Note that the ellipse size defines the two diameters of the ellipse, and not the radii.

The command transform is applied to this method when called.

Parameters
centerThe ellipse center
sizeThe ellipse size

◆ drawEllipse() [3/3]

void cugl::scene2::CanvasNode::drawEllipse ( float  cx,
float  cy,
float  rx,
float  ry 
)

Creates a new ellipse shaped subpath.

The command transform is applied to this method when called.

Parameters
cxThe x-coordinate of the ellipse center
cyThe y-coordinate of the ellipse center
rxThe radius along the x-axis
ryThe radius along the y-axis

◆ drawRect() [1/2]

void cugl::scene2::CanvasNode::drawRect ( const Rect  rect)

Creates a new rectangle shaped subpath

The command transform is applied to this method when called.

Parameters
rectThe rectangle bounds

◆ drawRect() [2/2]

void cugl::scene2::CanvasNode::drawRect ( float  x,
float  y,
float  w,
float  h 
)
inline

Creates a new rectangle shaped subpath

The command transform is applied to this method when called.

Parameters
xThe x-coordinate of the rectangle origin
yThe y-coordinate of the rectangle origin
wThe rectangle width
hThe rectangle height

◆ drawRoundedRect() [1/2]

void cugl::scene2::CanvasNode::drawRoundedRect ( const Rect  rect,
float  r 
)
inline

Creates a new rounded rectangle shaped subpath.

To be well-defined, the corner radius should be no larger than half the width and height (at which point it defines a capsule). Shapes with abnormally large radii are undefined.

The command transform is applied to this method when called.

Parameters
rectThe rectangle bounds
rThe corner radius

◆ drawRoundedRect() [2/2]

void cugl::scene2::CanvasNode::drawRoundedRect ( float  x,
float  y,
float  w,
float  h,
float  r 
)

Creates a new rounded rectangle shaped subpath.

To be well-defined, the corner radius should be no larger than half the width and height (at which point it defines a capsule). Shapes with abnormally large radii are undefined.

The command transform is applied to this method when called.

Parameters
xThe x-coordinate of the rectangle origin
yThe y-coordinate of the rectangle origin
wThe rectangle width
hThe rectangle height
rThe corner radius

◆ drawRoundedRectVarying() [1/2]

void cugl::scene2::CanvasNode::drawRoundedRectVarying ( const Rect  rect,
float  radBL,
float  radTL,
float  radTR,
float  radBR 
)
inline

Creates a new rounded rectangle shaped subpath with varying radii.

Each corner will have its own radii. But to be well-defined, none of the radii should be larger than half the width and height (at which point it defines a capsule). Shapes with abnormally large radii are undefined.

The command transform is applied to this method when called.

Parameters
rectThe rectangle bounds
radBLThe corner radius of the bottom left
radTLThe corner radius of the top left
radTRThe corner radius of the top right
radBRThe corner radius of the bottom right

◆ drawRoundedRectVarying() [2/2]

void cugl::scene2::CanvasNode::drawRoundedRectVarying ( float  x,
float  y,
float  w,
float  h,
float  radBL,
float  radTL,
float  radTR,
float  radBR 
)

Creates a new rounded rectangle shaped subpath with varying radii.

Each corner will have its own radii. But to be well-defined, none of the radii should be larger than half the width and height (at which point it defines a capsule). Shapes with abnormally large radii are undefined.

The command transform is applied to this method when called.

Parameters
xThe x-coordinate of the rectangle origin
yThe y-coordinate of the rectangle origin
wThe rectangle width
hThe rectangle height
radBLThe corner radius of the bottom left
radTLThe corner radius of the top left
radTRThe corner radius of the top right
radBRThe corner radius of the bottom right

◆ drawText() [1/4]

void cugl::scene2::CanvasNode::drawText ( const Vec2  p,
const char *  substr,
const char *  end 
)
inline

Draws the text string at specified location.

Position p is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The C-style string substr need not be null-terminated. Instead, the termination is indicated by the parameter end. This provides efficient substring processing. The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
pThe position of the text origin
substrThe start of the string
endThe end of the string

◆ drawText() [2/4]

void cugl::scene2::CanvasNode::drawText ( const Vec2  p,
const std::string  text 
)
inline

Draws the text string at specified location.

Position p is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
pThe position of the text origin
textThe text to display

◆ drawText() [3/4]

void cugl::scene2::CanvasNode::drawText ( float  x,
float  y,
const char *  substr,
const char *  end 
)

Draws the text string at specified location.

Position (x,y) is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The C-style string substr need not be null-terminated. Instead, the termination is indicated by the parameter end. This provides efficient substring processing. The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
xThe x-coordinate of the text origin
yThe y-coordinate of the text origin
substrThe start of the string
endThe end of the string

◆ drawText() [4/4]

void cugl::scene2::CanvasNode::drawText ( float  x,
float  y,
const std::string  text 
)
inline

Draws the text string at specified location.

Position (x,y) is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
xThe x-coordinate of the text origin
yThe y-coordinate of the text origin
textThe text to display

◆ drawTextBox() [1/4]

void cugl::scene2::CanvasNode::drawTextBox ( const Vec2  p,
float  width,
const char *  substr,
const char *  end 
)
inline

Draws a multiline text string at specified location.

Position p is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

When breaking up lines, whitespace at the beginning and end of each line will be "swallowed", causing it to be ignored for purposes of alignment. The exception is at the beginning and end of a paragraph. Whitespace there will be preserved. A paragraph is defined as any piece of text separated by a newline. So the first part of the string before a newline is a paragraph, and each substring after a newline is also a paragraph.

Words longer than the max width are slit at nearest character. There is no support for hyphenation.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The C-style string substr need not be null-terminated. Instead, the termination is indicated by the parameter end. This provides efficient substring processing. The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
pThe position of the text origin
widthThe text-wrap width
substrThe start of the string
endThe end of the string

◆ drawTextBox() [2/4]

void cugl::scene2::CanvasNode::drawTextBox ( const Vec2  p,
float  width,
const std::string  text 
)
inline

Draws a multiline text string at specified location.

Position p is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

When breaking up lines, whitespace at the beginning and end of each line will be "swallowed", causing it to be ignored for purposes of alignment. The exception is at the beginning and end of a paragraph. Whitespace there will be preserved. A paragraph is defined as any piece of text separated by a newline. So the first part of the string before a newline is a paragraph, and each substring after a newline is also a paragraph.

Words longer than the max width are slit at nearest character. There is no support for hyphenation.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
pThe position of the text origin
widthThe text-wrap width
textThe text to display

◆ drawTextBox() [3/4]

void cugl::scene2::CanvasNode::drawTextBox ( float  x,
float  y,
float  width,
const char *  substr,
const char *  end 
)

Draws a multiline text string at specified location.

Position (x,y) is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

When breaking up lines, whitespace at the beginning and end of each line will be "swallowed", causing it to be ignored for purposes of alignment. The exception is at the beginning and end of a paragraph. Whitespace there will be preserved. A paragraph is defined as any piece of text separated by a newline. So the first part of the string before a newline is a paragraph, and each substring after a newline is also a paragraph.

Words longer than the max width are slit at nearest character. There is no support for hyphenation.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The C-style string substr need not be null-terminated. Instead, the termination is indicated by the parameter end. This provides efficient substring processing. The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
xThe x-coordinate of the text origin
yThe y-coordinate of the text origin
widthThe text-wrap width
substrThe start of the string
endThe end of the string

◆ drawTextBox() [4/4]

void cugl::scene2::CanvasNode::drawTextBox ( float  x,
float  y,
float  width,
const std::string  text 
)
inline

Draws a multiline text string at specified location.

Position (x,y) is the location of the text origin, which is defined by both getHorizontalTextAlign and getVerticalTextAlign. This command is subject to the current command transform.

When breaking up lines, whitespace at the beginning and end of each line will be "swallowed", causing it to be ignored for purposes of alignment. The exception is at the beginning and end of a paragraph. Whitespace there will be preserved. A paragraph is defined as any piece of text separated by a newline. So the first part of the string before a newline is a paragraph, and each substring after a newline is also a paragraph.

Words longer than the max width are slit at nearest character. There is no support for hyphenation.

This command will use the current text style, and color the glyphs with the current fill color. If there is a fill Paint then it will also be applied, provided that it is a gradient (text cannot be textured with images).

The string may either be in UTF8 or ASCII; the method will handle conversion automatically.

Parameters
xThe x-coordinate of the text origin
yThe y-coordinate of the text origin
widthThe text-wrap width
textThe text to display

◆ fillPaths()

void cugl::scene2::CanvasNode::fillPaths ( )

Fills the current path (and subpaths) with the current fill style.

This method will commit the any outstanding paths, but it will not clear them. You should call beginPath to start a new path sequence.

◆ getBlendEquation()

GLenum cugl::scene2::CanvasNode::getBlendEquation ( ) const

Returns the blending equation for this canvas node

This setting is applied at the call to either strokePaths or fillPaths.

By default this value is GL_FUNC_ADD. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml
Returns
the blending equation for this canvas node

◆ getCommandTransform()

const Affine2& cugl::scene2::CanvasNode::getCommandTransform ( )

Returns the current command transform

Transforms are applied to all paths, text, paints, and scissor regions. They are applied at the time that the are passed to the drawing API. So a translation applied after the first point in a path will skip that initial point, but apply to all subsequent points (until the command transform is changed again).

When using Paint objects, it is important to set a transform before applying them. That is because paint objects are specified in the canvas coordinate system, which is affected by the transform. If a paint object is applied to a shape in a different coordinate space then it can have unexpected effects.

The current coordinate system can be saved and restored by using the methods saveState and restoreState.

Returns
the current command transform

◆ getDrawPage()

size_t cugl::scene2::CanvasNode::getDrawPage ( )

Returns the index of the current drawing page

The drawing page is the page that is shown on the screen. It does not need to be the same page as the one currently receiving drawing commands.

Returns
the index of the current drawing page

◆ getDstAlphaFunc()

GLenum cugl::scene2::CanvasNode::getDstAlphaFunc ( ) const

Returns the destination blending function for the alpha component

This setting is applied at the call to either strokePaths or fillPaths.

By default this value is GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
Returns
the destination blending function for the alpha component

◆ getDstRGBFunc()

GLenum cugl::scene2::CanvasNode::getDstRGBFunc ( ) const

Returns the destination blending function for the RGB components

This setting is applied at the call to either strokePaths or fillPaths.

By default this value is GL_ONE_MINUS_SRC_ALPHA, as sprite batches do not use premultiplied alpha. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
Returns
the destination blending function for the RGB components

◆ getEditPage()

size_t cugl::scene2::CanvasNode::getEditPage ( )

Returns the index of the current edit page

The edit page is the page that receives drawing commands. It does not need to be the same page as the one currently being drawn.

Returns
the index of the current edit page

◆ getFillColor()

Color4 cugl::scene2::CanvasNode::getFillColor ( ) const

Returns the color to use for all filled paths

This setting is applied at a call to fillPaths.

It is possible to combine a color together with a paint. It the attribute getFillPaint is not nullptr, it will tinted by this color.

This color is also the one that will be used to render text. This value is Color4::WHITE by default.

Returns
the color to use for all filled paths

◆ getFillPaint()

const std::shared_ptr<Paint>& cugl::scene2::CanvasNode::getFillPaint ( ) const

Returns the paint to use for all filled paths.

This setting is applied at a call to fillPaths.

A Paint object is a user-friend gradient or texture that uses positional coordinates instead of texture coordinates. The paint will be tinted by the value getStrokeColor (which is Color4::WHITE by default).

If there is non-trivial getCommandTransform, it will be applied to the coordinates in this paint object at the time this method is called.

A fill paint will also be applied to text, assuming that it is a gradient paint. Pattern paints cannot be applied to text. If this value is nullptr, then all filled paths will have a solid color.

Returns
the paint to use for all filled paths

◆ getFillRule()

FillRule cugl::scene2::CanvasNode::getFillRule ( ) const

Returns the current fill rule

This setting is applied at a call to fillPaths.

By default a canvas node uses a nonzero fill rule, as described here:

 https://en.wikipedia.org/wiki/Nonzero-rule

This rule allows you to put holes inside a filled path simply by reversing the winding order.

Alternate fill rules are supported, though they are all the same as the nonzero rule for simple paths. They only differ when either a path has self-intersections, or two subpaths intersect one another.

Returns
the current fill rule

◆ getFont()

const std::shared_ptr<Font>& cugl::scene2::CanvasNode::getFont ( ) const

Returns the font for the current text style

This is the font that will be used as a call to either drawText or drawTextBox. If there is no active font when one of the those methods are called, they will fail.

Returns
the font for the current text style

◆ getFontBlur()

float cugl::scene2::CanvasNode::getFontBlur ( ) const

Returns the blur radius of the current text style.

When blurring text, use a font with the same Font#getPadding as the blur size. This will prevent bleeding across characters in the atlas.

Returns
the blur radius of the current text style.

◆ getFontSize()

float cugl::scene2::CanvasNode::getFontSize ( ) const

Returns the font size of the current text style.

By default, the text style will use the point size of getFont. However, it is possible to scale the font to get a smaller (or larger) text size. With that said, it is generally better to scale down a font than to scale it up.

If this value is 0, the canvas will use the point size of the active font. This value is 0 by default.

Returns
the font size of the current text style.

◆ getFringe()

float cugl::scene2::CanvasNode::getFringe ( ) const

Returns the antialiasing fringe for this canvas node

If this value is non-zero, any fill or stroke will be surrounded by a stroke the width of the fringe. The stroke will fade to transparent on the outside edge. This is a way of providing antialiasing that is significantly better than multisampling. Furthermore, this works on OpenGLES, which does not support multisampling.

A fringe value should be >= 0.5 to have noticeable effects. In practice, values between 1 and 2 work best. Note that this adds to the volume of the fill or stroke. Hence this value should be taken into account when drawing shapes

Returns
the antialiasing fringe for this canvas node

◆ getGlobalAlpha()

float cugl::scene2::CanvasNode::getGlobalAlpha ( )

Returns the transparency to apply to all rendered shapes.

The alpha should be a value 0..1. Already transparent paths will get proportionally more transparent as well.

Returns
the transparency to apply to all rendered shapes.

◆ getHorizontalTextAlign()

HorizontalAlign cugl::scene2::CanvasNode::getHorizontalTextAlign ( ) const

Returns the horizontal alignment of the text.

The horizontal alignment has two meanings. First, it is the relationship of the relative alignment of multiple lines. In addition, it defines the x-coordinate origin of the text. The later is relevant even when the text layout is a single line.

See HorizontalAlign for how alignment affects the text origin.

Returns
the horizontal alignment of the text.

◆ getLineCap()

poly2::EndCap cugl::scene2::CanvasNode::getLineCap ( )

Returns the end cap value for the stroke.

This setting is applied at a call to strokePaths.

The end cap type determines how the stroke draws the ends of the line segments at the start and end of the path. See poly2::EndCap for the description of the types.

Returns
the end cap value for the extrusion.

◆ getLineJoint()

poly2::Joint cugl::scene2::CanvasNode::getLineJoint ( )

Returns the joint value for the stroke.

The joint type determines how the stroke joins the extruded line segments together. See poly2::Joint for the description of the types.

Returns
the joint value for the stroke.

◆ getLocalScissor()

const std::shared_ptr<Scissor>& cugl::scene2::CanvasNode::getLocalScissor ( ) const

Returns the current local scissor

The local scissor is applied any subsequent drawing commands, but not to any commands issued before the scissor was applied. This is different from SceneNode#getScissor which is applied globally to the entire scene graph node. The local scissor is transformed by the getCommandTransform at the time it is set.

If there is both a local and a global scissor, their rectangles will be intersected to produce a single scissor, using the method Scissor#intersect. The intersection will take place in the coordinate system of this scissor.

Returns
the current local scissor

◆ getMitreLimit()

float cugl::scene2::CanvasNode::getMitreLimit ( ) const

Returns the mitre limit of the extrusion.

This setting is applied at a call to strokePaths.

The mitre limit sets how "pointy" a mitre joint is allowed to be before the algorithm switches it back to a bevel/square joint. Small angles can have very large mitre offsets that go way off-screen.

To determine whether to switch a miter to a bevel, the algorithm will take the two vectors at this joint, normalize them, and then average them. It will multiple the magnitude of that vector by the mitre limit. If that value is less than 1.0, it will switch to a bevel. By default this value is 10.0.

Returns
the mitre limit for joint calculations

◆ getSrcAlphaFunc()

GLenum cugl::scene2::CanvasNode::getSrcAlphaFunc ( ) const

Returns the source blending function for the alpha component

This setting is applied at the call to either strokePaths or fillPaths.

By default this value is GL_SRC_ALPHA, as scene graphs do not use premultiplied alpha. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
Returns
the source blending function for the alpha component

◆ getSrcRGBFunc()

GLenum cugl::scene2::CanvasNode::getSrcRGBFunc ( ) const

Returns the source blending function for the RGB components

This setting is applied at the call to either strokePaths or fillPaths.

By default this value is GL_SRC_ALPHA, as scene graphs do not use premultiplied alpha. For other options, see

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml
Returns
the source blending function for the RGB components

◆ getStrokeColor()

Color4 cugl::scene2::CanvasNode::getStrokeColor ( ) const

Returns the color to use for all stroked paths

This setting is applied at a call to strokePaths.

It is possible to combine a color together with a paint. It the attribute getStrokePaint is not nullptr, it will tinted by this color.

This value is Color4::WHITE by default.

Returns
the color to use for all stroked paths

◆ getStrokePaint()

const std::shared_ptr<Paint>& cugl::scene2::CanvasNode::getStrokePaint ( ) const

Returns the paint to use for all stroked paths.

This setting is applied at a call to strokePaths.

A Paint object is a user-friend gradient or texture that uses positional coordinates instead of texture coordinates. The paint will be tinted by the value getStrokeColor (which is Color4::WHITE by default).

If there is non-trivial getCommandTransform, it will be applied to the coordinates in this paint object at the time this method is called.

If this value is nullptr, then all strokes will have a solid color.

Returns
the paint to use for all stroked paths

◆ getStrokeWidth()

float cugl::scene2::CanvasNode::getStrokeWidth ( ) const

Returns the width of the stroke style.

This setting is applied at a call to strokePaths.

If the value of getFringe is not zero, this will be subtracted from the stroke width when extruding the path. The default stroke width is 2.

Returns
the width of the stroke style.

◆ getTextSpacing()

float cugl::scene2::CanvasNode::getTextSpacing ( ) const

Returns the line spacing of the current text style.

This value is multiplied by the font size to determine the space between lines. So a value of 1 is single-spaced text, while a value of 2 is double spaced. The value should be positive.

Returns
the line spacing of the current text style.

◆ getVerticalTextAlign()

VerticalAlign cugl::scene2::CanvasNode::getVerticalTextAlign ( ) const

Returns the vertical alignment of the text.

The vertical alignment defines the y-coordinate origin of this text layout. In the case of multiple lines, the alignment is (often) with respect to the entire block of text, not just the first line.

See VerticalAlign for how alignment affects the text origin.

Returns
the vertical alignment of the text.

◆ getWinding()

Winding cugl::scene2::CanvasNode::getWinding ( ) const

Returns the current winding order

As a general rule, solid shapes should have a counter clockwise winding, and holes should have a clockwise winding. This property allows you to specify the winding order to use, even if you generate the path in the wrong order. Hence, if this attribute is CCW, your paths will all be counter clockwise even if the drawing commands generate them clockwise.

By default this value is None, which means that paths use their native winding order.

The winding order is applied to a subpath when it is committed. A subpath is committed at a subsequent call to moveTo or a call to either fillPaths or strokePaths.

Returns
the current winding order

◆ init()

virtual bool cugl::scene2::CanvasNode::init ( )
overridevirtual

Initializes a canvas node the size of the display.

The bounding box of the node is the current screen size. The node is anchored in the center and has position (width/2,height/2) in the parent space. The node origin is the (0,0) at the bottom left corner of the bounding box.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithBounds() [1/4]

virtual bool cugl::scene2::CanvasNode::initWithBounds ( const Rect  rect)
overridevirtual

Initializes a canvas node with the given bounds.

The rectangle origin is the bottom left corner of the node in parent space, and corresponds to the origin of the Node space. The size defines its content width and height in node space. The node anchor is placed in the bottom left corner.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
rectThe bounds of the node in parent space
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithBounds() [2/4]

virtual bool cugl::scene2::CanvasNode::initWithBounds ( const Size  size)
overridevirtual

Initializes a canvas node with the given size.

The size defines the content size. The bounding box of the node is (0,0,width,height) and is anchored in the bottom left corner (0,0). The node is positioned at the origin in parent space.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
sizeThe size of the node in parent space
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithBounds() [3/4]

virtual bool cugl::scene2::CanvasNode::initWithBounds ( float  width,
float  height 
)
inlineoverridevirtual

Initializes a canvas node with the given size.

The size defines the content size. The bounding box of the node is (0,0,width,height) and is anchored in the bottom left corner (0,0). The node is positioned at the origin in parent space.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
widthThe width of the node in parent space
heightThe height of the node in parent space
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithBounds() [4/4]

virtual bool cugl::scene2::CanvasNode::initWithBounds ( float  x,
float  y,
float  width,
float  height 
)
inlineoverridevirtual

Initializes a canvas node with the given bounds.

The rectangle origin is the bottom left corner of the node in parent space, and corresponds to the origin of the Node space. The size defines its content width and height in node space. The node anchor is placed in the bottom left corner.

The canvas is initialized with only one drawing buffer. You should call paginate to add more buffers.

Parameters
xThe x-coordinate of the node origin in parent space
yThe y-coordinate of the node origin in parent space
widthThe width of the node in parent space
heightThe height of the node in parent space
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ initWithData()

virtual bool cugl::scene2::CanvasNode::initWithData ( const Scene2Loader loader,
const std::shared_ptr< JsonValue > &  data 
)
overridevirtual

Initializes a canvas node with the given JSON specificaton.

This initializer is designed to receive the "data" object from the JSON passed to Scene2Loader. This JSON format supports the following attribute values:

"pages":     A positive integer indicating the number of pages
"edit":      A positive integer indicating the active edit page
"draw":      A positive integer indicating the active draw page

All attributes are optional. There are no required attributes. There are currently no options for drawing to a canvas node in in the JSON (the canvas will start out blank). Serialized drawing commands are a feature for a future release.

Parameters
loaderThe scene loader passing this JSON file
dataThe JSON object specifying the node
Returns
true if initialization was successful.

Reimplemented from cugl::scene2::SceneNode.

◆ lineTo() [1/2]

void cugl::scene2::CanvasNode::lineTo ( const Vec2  pos)

Adds a line segment from the previous point to the given one.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
posThe next path point

◆ lineTo() [2/2]

void cugl::scene2::CanvasNode::lineTo ( float  x,
float  y 
)
inline

Adds a line segment from the previous point to the given one.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
xThe x-coordinate of the next path point
yThe y-coordinate of the next path point

◆ moveTo() [1/2]

void cugl::scene2::CanvasNode::moveTo ( const Vec2  pos)

Starts a new sub-path with specified point as first point.

The command transform is applied to this method when called.

Parameters
posThe initial path point

◆ moveTo() [2/2]

void cugl::scene2::CanvasNode::moveTo ( float  x,
float  y 
)
inline

Starts a new sub-path with specified point as first point.

The command transform is applied to this method when called.

Parameters
xThe x-coordinate of the initial path point
yThe y-coordinate of the initial path point

◆ pages()

size_t cugl::scene2::CanvasNode::pages ( ) const

Returns the number of pages in this canvas node.

Each page is capable of storing its own set of drawing commands. Flipping through pages is an efficient way to animate a canvas node.

By default a canvas node has only one page.

Returns
the number of pages in this canvas node.

◆ paginate()

void cugl::scene2::CanvasNode::paginate ( size_t  size)

Resizes the canvas node to support the given number of pages

Each page is capable of storing its own set of drawing commands. Flipping through pages is an efficient way to animate a canvas node.

When repaginating a canvas, all pages with indices less than size are preserved. Any pages with indices exceeding size are discarded.

Parameters
sizeThe number of pages for this canvas node

◆ quadTo() [1/2]

void cugl::scene2::CanvasNode::quadTo ( const Vec2  c,
const Vec2  p 
)

Adds a quadratic bezier segment from the previous point.

The control point is as described in Spline2#addQuad.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
cThe control point
pThe end of the bezier segment

◆ quadTo() [2/2]

void cugl::scene2::CanvasNode::quadTo ( float  cx,
float  cy,
float  px,
float  py 
)
inline

Adds a quadratic bezier segment from the previous point.

The control point is as described in Spline2#addQuad.

If there is no current path, this method creates a new subpath starting at the origin. The command transform is applied to this method when called.

Parameters
cxThe x-coordinate of the control point
cyThe y-coordinate of the control point
pxThe x-coordinate of the bezier end
pyThe y-coordinate of the bezier end

◆ resetState()

void cugl::scene2::CanvasNode::resetState ( )

Resets current render state to default values.

This option does not affect the render state stack. Any states that were previously saved are preserved.

Note that state is local to a canvas page. Changing the current getEditPage will also change the render state to the one for that page. This happens without any loss to the state of the original page.

◆ restoreState()

void cugl::scene2::CanvasNode::restoreState ( )

Pops and restores current render state.

The state which represents how text and paths will be rendered. It contains local transforms, fill and stroke styles, text and font styles, and scissor clipping regions.

Note that state is local to a canvas page. Changing the current getEditPage will also change the render state to the one for that page. This happens without any loss to the state of the original page.

If the state was not previously saved with a call to saveState, then this method will restore all options to their defaults.

◆ rotateCommands()

void cugl::scene2::CanvasNode::rotateCommands ( float  angle)

Rotates all commands by the given angle.

The angle is specified in radians, and specifies a rotation about the origin. This rotation is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
angleThe rotation angle in radians

◆ saveState()

void cugl::scene2::CanvasNode::saveState ( )

Pushes and saves the current render state on to a state stack.

The state which represents how text and paths will be rendered. It contains local transforms, fill and stroke styles, text and font styles, and scissor clipping regions.

Note that state is local to a canvas page. Changing the current getEditPage will also change the render state to the one for that page. This happens without any loss to the state of the original page.

After the state is saved, a matching call to restoreState must be used to restore the state.

◆ scaleCommands() [1/2]

void cugl::scene2::CanvasNode::scaleCommands ( const Vec2  s)
inline

Scales all commands by the given factor.

This resizing operation is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
sThe scaling factor

◆ scaleCommands() [2/2]

void cugl::scene2::CanvasNode::scaleCommands ( float  sx,
float  sy 
)

Scales all commands by the given factor.

This resizing operation is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
sxThe x-axis scaling factor
syThe y-axis scaling factor

◆ setBlendEquation()

void cugl::scene2::CanvasNode::setBlendEquation ( GLenum  equation)

Sets the blending equation for this canvas node.

This setting is applied at the call to either strokePaths or fillPaths.

The enum must be a standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendEquation.xhtml

However, this setter does not do any error checking to verify that the input is valid. By default, the equation is GL_FUNC_ADD.

Parameters
equationThe blending equation for this canvas node

◆ setCommandTransform()

void cugl::scene2::CanvasNode::setCommandTransform ( const Affine2 transform)

Sets the current command transform

Transforms are applied to all paths, text, paints, and scissor regions. They are applied at the time that the are passed to the drawing API. So a translation applied after the first point in a path will skip that initial point, but apply to all subsequent points (until the command transform is changed again).

When using Paint objects, it is important to set a transform before applying them. That is because paint objects are specified in the canvas coordinate system, which is affected by the transform. If a paint object is applied to a shape in a different coordinate space then it can have unexpected effects.

The current coordinate system can be saved and restored by using the methods saveState and restoreState.

Parameters
transformThe current command transform

◆ setDrawPage()

void cugl::scene2::CanvasNode::setDrawPage ( size_t  page)

Sets the index of the current drawing page

The drawing page is the page that is shown on the screen. It does not need to be the same page as the one currently receiving drawing commands.

If this index is higher than the number of pages, this canvas will paginate to support the request.

Parameters
pageThe index of the current drawing page

◆ setDstBlendFunc() [1/2]

void cugl::scene2::CanvasNode::setDstBlendFunc ( GLenum  dstRGB,
GLenum  dstAlpha 
)

Sets the blending functions for the destination color

This setting is applied at the call to either strokePaths or fillPaths.

The enums are the standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This version of the function allows you to specify different blending fuctions for the RGB and alpha components of the destiniation color. This setter does not do any error checking to verify that the enums are valid.

By default both values are GL_ONE_MINUS_SRC_ALPHA, as scene graphs do not use premultiplied alpha.

Parameters
dstRGBThe blend function for the destination RGB components
dstAlphaThe blend function for the destination alpha component

◆ setDstBlendFunc() [2/2]

void cugl::scene2::CanvasNode::setDstBlendFunc ( GLenum  func)
inline

Sets the blending function for the destination color

This setting is applied at the call to either strokePaths or fillPaths.

The enums are the standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

However, this setter does not do any error checking to verify that the enums are valid.

By default this value is GL_ONE_MINUS_SRC_ALPHA, as scene graphs do not use premultiplied alpha.

Parameters
funcSpecifies how the source color is blended

◆ setEditPage()

void cugl::scene2::CanvasNode::setEditPage ( size_t  page)

Sets the index of the current edit page

The edit page is the page that receives drawing commands. It does not need to be the same page as the one currently being drawn.

If this index is higher than the number of pages, this canvas will paginate to support the request.

Parameters
pageThe index of the current edit page

◆ setFillColor()

void cugl::scene2::CanvasNode::setFillColor ( Color4  color)

Sets the color to use for all filled paths

This setting is applied at a call to fillPaths.

It is possible to combine a color together with a paint. It the attribute getFillPaint is not nullptr, it will tinted by this color.

This color is also the one that will be used to render text. This value is Color4::WHITE by default.

Parameters
colorThe color to use for all filled paths

◆ setFillPaint()

void cugl::scene2::CanvasNode::setFillPaint ( const std::shared_ptr< Paint > &  paint)

Sets the paint to use for all filled paths.

This setting is applied at a call to fillPaths.

A Paint object is a user-friend gradient or texture that uses positional coordinates instead of texture coordinates. The paint will be tinted by the value getStrokeColor (which is Color4::WHITE by default).

If there is non-trivial getCommandTransform, it will be applied to the coordinates in this paint object at the time this method is called.

A fill paint will also be applied to text, assuming that it is a gradient paint. Pattern paints cannot be applied to text. If this value is nullptr, then all filled paths will have a solid color.

Parameters
paintThe paint to use for all filled paths

◆ setFillRule()

void cugl::scene2::CanvasNode::setFillRule ( FillRule  rule)

Sets the current fill rule

This setting is applied at a call to fillPaths.

By default a canvas node uses a nonzero fill rule, as described here:

 https://en.wikipedia.org/wiki/Nonzero-rule

This rule allows you to put holes inside a filled path simply by reversing the winding order.

Alternate fill rules are supported, though they are all the same as the nonzero rule for simple paths. They only differ when either a path has self-intersections, or two subpaths intersect one another.

Parameters
ruleThe current fill rule

◆ setFont()

void cugl::scene2::CanvasNode::setFont ( const std::shared_ptr< Font > &  font)

Sets the font for the current text style

This is the font that will be used as a call to either drawText or drawTextBox. If there is no active font when one of the those methods are called, they will fail.

Parameters
fontThe font for the current text style

◆ setFontBlur()

void cugl::scene2::CanvasNode::setFontBlur ( float  blur)

Sets the blur radius of the current text style.

When blurring text, use a font with the same Font#getPadding as the blur size. This will prevent bleeding across characters in the atlas.

Parameters
blurThe blur radius of the current text style.

◆ setFontSize()

void cugl::scene2::CanvasNode::setFontSize ( float  size)

Sets the font size of the current text style.

By default, the text style will use the point size of getFont. However, it is possible to scale the font to get a smaller (or larger) text size. With that said, it is generally better to scale down a font than to scale it up.

If this value is 0, the canvas will use the point size of the active font. This value is 0 by default.

Parameters
sizeThe font size of the current text style.

◆ setFringe()

void cugl::scene2::CanvasNode::setFringe ( float  fringe)

Sets the antialiasing fringe for this canvas node

If this value is non-zero, any fill or stroke will be surrounded by a stroke the width of the fringe. The stroke will fade to transparent on the outside edge. This is a way of providing antialiasing that is significantly better than multisampling. Furthermore, this works on OpenGLES, which does not support multisampling.

A fringe value should be >= 0.5 to have noticeable effects. In practice, values between 1 and 2 work best. Note that this adds to the volume of the fill or stroke. Hence this value should be taken into account when drawing shapes

Parameters
fringeThe antialiasing fringe for this canvas node

◆ setGlobalAlpha()

void cugl::scene2::CanvasNode::setGlobalAlpha ( float  alpha)

Sets the transparency to apply to all rendered shapes.

The alpha should be a value 0..1. Already transparent paths will get proportionally more transparent as well.

Parameters
alphaThe transparency to apply to all rendered shapes.

◆ setHorizontalTextAlign()

void cugl::scene2::CanvasNode::setHorizontalTextAlign ( HorizontalAlign  align)

Sets the horizontal alignment of the text.

The horizontal alignment has two meanings. First, it is the relationship of the relative alignment of multiple lines. In addition, it defines the x-coordinate origin of the text. The later is relevant even when the text layout is a single line.

See HorizontalAlign for how alignment affects the text origin.

Parameters
alignThe horizontal alignment of the text.

◆ setLineCap()

void cugl::scene2::CanvasNode::setLineCap ( poly2::EndCap  cap)

Sets the end cap value for the stroke.

This setting is applied at a call to strokePaths.

The end cap type determines how the stroke draws the ends of the line segments at the start and end of the path. See poly2::EndCap for the description of the types.

Parameters
capThe end cap value for the stroke.

◆ setLineJoint()

void cugl::scene2::CanvasNode::setLineJoint ( poly2::Joint  joint)

Sets the joint value for the stroke.

The joint type determines how the stroke joins the extruded line segments together. See poly2::Joint for the description of the types.

Parameters
jointThe joint value for the stroke.

◆ setLocalScissor()

void cugl::scene2::CanvasNode::setLocalScissor ( const std::shared_ptr< Scissor > &  scissor)

Sets the current local scissor

The local scissor is applied any subsequent drawing commands, but not to any commands issued before the scissor was applied. This is different from SceneNode#getScissor which is applied globally to the entire scene graph node. The local scissor is transformed by the getCommandTransform at the time it is set.

If there is both a local and a global scissor, their rectangles will be intersected to produce a single scissor, using the method Scissor#intersect. The intersection will take place in the coordinate system of this scissor.

Parameters
scissorThe current local scissor

◆ setMitreLimit()

void cugl::scene2::CanvasNode::setMitreLimit ( float  limit)

Sets the mitre limit of the extrusion.

This setting is applied at a call to strokePaths.

The mitre limit sets how "pointy" a mitre joint is allowed to be before the algorithm switches it back to a bevel/square joint. Small angles can have very large mitre offsets that go way off-screen.

To determine whether to switch a miter to a bevel, the algorithm will take the two vectors at this joint, normalize them, and then average them. It will multiple the magnitude of that vector by the mitre limit. If that value is less than 1.0, it will switch to a bevel. By default this value is 10.0.

Parameters
limitThe mitre limit for joint calculations

◆ setSrcBlendFunc() [1/2]

void cugl::scene2::CanvasNode::setSrcBlendFunc ( GLenum  func)
inline

Sets the blending function for the source color

This setting is applied at the call to either strokePaths or fillPaths.

The enums are the standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

However, this setter does not do any error checking to verify that the enums are valid.

By default this value is GL_SRC_ALPHA, as scene graphs do not use premultiplied alpha.

Parameters
funcSpecifies how the source color is blended

◆ setSrcBlendFunc() [2/2]

void cugl::scene2::CanvasNode::setSrcBlendFunc ( GLenum  srcRGB,
GLenum  srcAlpha 
)

Sets the blending functions for the source color

This setting is applied at the call to either strokePaths or fillPaths.

The enums are the standard ones supported by OpenGL. See

 https://www.opengl.org/sdk/docs/man/html/glBlendFunc.xhtml

This version of the function allows you to specify different blending fuctions for the RGB and alpha components of the source color. This setter does not do any error checking to verify that the enums are valid.

By default both values are GL_SRC_ALPHA, as scene graphs do not use premultiplied alpha.

Parameters
srcRGBThe blend function for the source RGB components
srcAlphaThe blend function for the source alpha component

◆ setStrokeColor()

void cugl::scene2::CanvasNode::setStrokeColor ( Color4  color)

Sets the color to use for all stroked paths

This setting is applied at a call to strokePaths.

It is possible to combine a color together with a paint. It the attribute getStrokePaint is not nullptr, it will tinted by this color.

This value is Color4::WHITE by default.

Parameters
colorThe color to use for all stroked paths

◆ setStrokePaint()

void cugl::scene2::CanvasNode::setStrokePaint ( const std::shared_ptr< Paint > &  paint)

Sets the paint to use for all stroked paths.

This setting is applied at a call to strokePaths.

A Paint object is a user-friend gradient or texture that uses positional coordinates instead of texture coordinates. The paint will be tinted by the value getStrokeColor (which is Color4::WHITE by default).

If there is non-trivial getCommandTransform, it will be applied to the coordinates in this paint object at the time this method is called.

If this value is nullptr, then all strokes will have a solid color.

Parameters
paintThe paint to use for all stroked paths

◆ setStrokeWidth()

void cugl::scene2::CanvasNode::setStrokeWidth ( float  width)

Sets the width of the stroke style.

This setting is applied at a call to strokePaths.

If the value of getFringe is not zero, this will be subtracted from the stroke width when extruding the path. The default stroke width is 2.

Parameters
widthThe width of the stroke style.

◆ setTextSpacing()

void cugl::scene2::CanvasNode::setTextSpacing ( float  spacing)

Sets the line spacing of the current text style.

This value is multiplied by the font size to determine the space between lines. So a value of 1 is single-spaced text, while a value of 2 is double spaced. The value should be positive.

Parameters
spacingThe line spacing of the current text style.

◆ setVerticalTextAlign()

void cugl::scene2::CanvasNode::setVerticalTextAlign ( VerticalAlign  align)

Sets the vertical alignment of the text.

The vertical alignment defines the y-coordinate origin of this text layout. In the case of multiple lines, the alignment is (often) with respect to the entire block of text, not just the first line.

See VerticalAlign for how alignment affects the text origin.

Parameters
alignThe vertical alignment of the text.

◆ setWinding()

void cugl::scene2::CanvasNode::setWinding ( Winding  winding)

Sets the current winding order

As a general rule, solid shapes should have a counter clockwise winding, and holes should have a clockwise winding. This setting allows you to specify the winding order to use, even if you generate the path in the wrong order. Hence, if this setting is CCW, your paths will all be counter clockwise even if the drawing commands generate them clockwise.

By default this value is None, which means that paths use their native winding order.

The winding order is applied to a subpath when it is committed. A subpath is committed at a subsequent call to moveTo or a call to either fillPaths or strokePaths.

Parameters
windingThe current winding order

◆ skewXCommands()

void cugl::scene2::CanvasNode::skewXCommands ( float  angle)

Skews all commands along x-axis.

A skew is a shear with the given angle is specified in radians. This shear is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
angleThe skew angle in radians

◆ skewYCommands()

void cugl::scene2::CanvasNode::skewYCommands ( float  angle)

Skews all commands along y-axis.

A skew is a shear with the given angle is specified in radians. This shear is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
angleThe skew angle in radians

◆ strokePaths()

void cugl::scene2::CanvasNode::strokePaths ( )

Extrudes the current path (and subpaths) with the current stroke style.

This method will commit the any outstanding paths, but it will not clear them. You should call beginPath to start a new path sequence.

◆ translateCommands() [1/2]

void cugl::scene2::CanvasNode::translateCommands ( const Vec2  p)
inline

Translates all commands by the given offset.

This translation is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
pThe translation offset

◆ translateCommands() [2/2]

void cugl::scene2::CanvasNode::translateCommands ( float  x,
float  y 
)

Translates all commands by the given offset.

This translation is cumulative with the existing command transform. It is applied after the existing transform operations.

For more information on how this transform is applied to commands, see getCommandTransform.

Parameters
xThe translation x-offset
yThe translation y-offset

Member Data Documentation

◆ _canvas

std::vector<Page*> cugl::scene2::CanvasNode::_canvas
protected

The individual canvases of this node

◆ _draw

size_t cugl::scene2::CanvasNode::_draw
protected

The active page for drawing

◆ _edit

size_t cugl::scene2::CanvasNode::_edit
protected

The active page for editing


The documentation for this class was generated from the following file: