Detailed Description

Represents a canvas context which lets you draw 2D shapes and polygons on the UI. See the canvas html tag for more information.

Inheritance diagram for PowerUI.CanvasContext:
PowerUI.CanvasContext2D

Public Member Functions

 CanvasContext (HtmlCanvasElement canvas)
 Creates a new canvas context for the given canvas element. More...
 
Glyph ToGlyph ()
 Creates an infinitext glyph from the path you've just made. More...
 
void beginPath ()
 Starts creating a path on this context. Used to draw and fill in any kind of shape. More...
 
void closePath ()
 Closes the current path such that it forms a loop by drawing a line to the first node. More...
 
void lineTo (float x, float y)
 Adds a line from the current pen location to the given point. Note that nothing will be seen until you call a fill or stroke method. More...
 
void arc (float centerX, float centerY, float radius, float sAngle, float eAngle)
 Creates an arc around the given circle center. Note that nothing will be seen until you call a fill or stroke method. More...
 
void arc (float centerX, float centerY, float radius, float sAngle, float eAngle, bool counterClockwise)
 Creates an arc around the given circle center. Note that nothing will be seen until you call a fill or stroke method. More...
 
bool isPointInPath (float x, float y)
 Is the specified point in (not on) the current path? More...
 
void curveTo (float c1x, float c1y, float c2x, float c2y, float x, float y)
 
void quadraticCurveTo (float cx, float cy, float x, float y)
 
void Destroy ()
 Tidies up this context. More...
 
void arcTo (float x1, float y1, float x2, float y2, float radius)
 Adds an arc between the given points using the pen point as a control point. Note that nothing will be seen until you call a fill or stroke method. More...
 
float Angle (float x0, float y0, float x1, float y1)
 Gets the signed angle from one vector, the first, to another. More...
 
void stroke ()
 Draws the outline of path you created, and doesn't reset the path, using the stroke style. More...
 
void fill ()
 Fills the current path with a solid colour. The colour used originates from the fillStyle. More...
 
void moveTo (float x, float y)
 Moves the current pen location to the given point. Used when drawing paths. More...
 
void UpdateDimensions (LayoutBox box)
 Applies the image data so it's ready for rendering. More...
 
void clear ()
 Useful method to clear the whole context. More...
 
void clearRect (int xStart, int yStart, int width, int height)
 Clears the specified region of the canvas. More...
 
void fillRect (int xStart, int yStart, int width, int height)
 Fills the specified box region using the current fillStyle. More...
 
void fillRect (int xStart, int yStart, int rectWidth, int rectHeight, Color32 colour)
 Fills the specified box region using the given colour. More...
 

Public Attributes

Scanner Rasteriser
 The rasteriser used to fill with. More...
 
VectorPath Path
 The underlying path. More...
 
Color FillColour =new Color(0,0,0,1f)
 The current fill colour. See fillStyle. Default is black. More...
 
Color StrokeColour =new Color(0,0,0,1f)
 The current stroke colour. See strokeStyle. Default is black. More...
 

Properties

DynamicTexture ImageData [get]
 The target rendering plane. Always exists. More...
 
byte[] pngData [get]
 This canvas as a png. Null if it contains nothing. More...
 
int PathNodeCount [get]
 The current number of nodes on the current path. More...
 
HtmlElement canvas [get]
 The canvas element that this is the context for. More...
 
string fillStyle [get, set]
 Applies the current fill style. More...
 
string strokeStyle [get, set]
 Applies the current stroke style. More...
 
int width [get, set]
 The width of the canvas context. More...
 
int height [get, set]
 The height of the canvas context. More...
 

Private Attributes

HtmlCanvasElement Canvas
 The element for the canvas that this is a context for. More...
 
DynamicTexture ImageData_
 The target rendering plane. Always exists. More...
 

Constructor & Destructor Documentation

PowerUI.CanvasContext.CanvasContext ( HtmlCanvasElement  canvas)
inline

Creates a new canvas context for the given canvas element.

Parameters
canvasThe canvas for a particular canvas element.

Member Function Documentation

float PowerUI.CanvasContext.Angle ( float  x0,
float  y0,
float  x1,
float  y1 
)
inline

Gets the signed angle from one vector, the first, to another.

void PowerUI.CanvasContext.arc ( float  centerX,
float  centerY,
float  radius,
float  sAngle,
float  eAngle 
)
inline

Creates an arc around the given circle center. Note that nothing will be seen until you call a fill or stroke method.

void PowerUI.CanvasContext.arc ( float  centerX,
float  centerY,
float  radius,
float  sAngle,
float  eAngle,
bool  counterClockwise 
)
inline

Creates an arc around the given circle center. Note that nothing will be seen until you call a fill or stroke method.

void PowerUI.CanvasContext.arcTo ( float  x1,
float  y1,
float  x2,
float  y2,
float  radius 
)
inline

Adds an arc between the given points using the pen point as a control point. Note that nothing will be seen until you call a fill or stroke method.

void PowerUI.CanvasContext.beginPath ( )
inline

Starts creating a path on this context. Used to draw and fill in any kind of shape.

void PowerUI.CanvasContext.clear ( )
inline

Useful method to clear the whole context.

void PowerUI.CanvasContext.clearRect ( int  xStart,
int  yStart,
int  width,
int  height 
)
inline

Clears the specified region of the canvas.

void PowerUI.CanvasContext.closePath ( )
inline

Closes the current path such that it forms a loop by drawing a line to the first node.

void PowerUI.CanvasContext.curveTo ( float  c1x,
float  c1y,
float  c2x,
float  c2y,
float  x,
float  y 
)
inline
void PowerUI.CanvasContext.Destroy ( )
inline

Tidies up this context.

void PowerUI.CanvasContext.fill ( )
inline

Fills the current path with a solid colour. The colour used originates from the fillStyle.

void PowerUI.CanvasContext.fillRect ( int  xStart,
int  yStart,
int  width,
int  height 
)
inline

Fills the specified box region using the current fillStyle.

void PowerUI.CanvasContext.fillRect ( int  xStart,
int  yStart,
int  rectWidth,
int  rectHeight,
Color32  colour 
)
inline

Fills the specified box region using the given colour.

bool PowerUI.CanvasContext.isPointInPath ( float  x,
float  y 
)
inline

Is the specified point in (not on) the current path?

Parameters
xThe x coordinate.
yThe y coordinate.
void PowerUI.CanvasContext.lineTo ( float  x,
float  y 
)
inline

Adds a line from the current pen location to the given point. Note that nothing will be seen until you call a fill or stroke method.

void PowerUI.CanvasContext.moveTo ( float  x,
float  y 
)
inline

Moves the current pen location to the given point. Used when drawing paths.

void PowerUI.CanvasContext.quadraticCurveTo ( float  cx,
float  cy,
float  x,
float  y 
)
inline
void PowerUI.CanvasContext.stroke ( )
inline

Draws the outline of path you created, and doesn't reset the path, using the stroke style.

Glyph PowerUI.CanvasContext.ToGlyph ( )
inline

Creates an infinitext glyph from the path you've just made.

void PowerUI.CanvasContext.UpdateDimensions ( LayoutBox  box)
inline

Applies the image data so it's ready for rendering.

Member Data Documentation

HtmlCanvasElement PowerUI.CanvasContext.Canvas
private

The element for the canvas that this is a context for.

Color PowerUI.CanvasContext.FillColour =new Color(0,0,0,1f)

The current fill colour. See fillStyle. Default is black.

DynamicTexture PowerUI.CanvasContext.ImageData_
private

The target rendering plane. Always exists.

VectorPath PowerUI.CanvasContext.Path

The underlying path.

Scanner PowerUI.CanvasContext.Rasteriser

The rasteriser used to fill with.

Color PowerUI.CanvasContext.StrokeColour =new Color(0,0,0,1f)

The current stroke colour. See strokeStyle. Default is black.

Property Documentation

HtmlElement PowerUI.CanvasContext.canvas
get

The canvas element that this is the context for.

string PowerUI.CanvasContext.fillStyle
getset

Applies the current fill style.

int PowerUI.CanvasContext.height
getset

The height of the canvas context.

DynamicTexture PowerUI.CanvasContext.ImageData
get

The target rendering plane. Always exists.

int PowerUI.CanvasContext.PathNodeCount
get

The current number of nodes on the current path.

byte [] PowerUI.CanvasContext.pngData
get

This canvas as a png. Null if it contains nothing.

string PowerUI.CanvasContext.strokeStyle
getset

Applies the current stroke style.

int PowerUI.CanvasContext.width
getset

The width of the canvas context.