Package | com.yworks.canvas.drawing |
Class | public class YGraphics |
Inheritance | YGraphics Object |
flash.display.Graphics
instance after the transformations are applied.
Property | Defined By | ||
---|---|---|---|
ALWAYS_USE_HTML_TEXT : Boolean = true [static]
Whether the text field's htmlText property should always
be used in the drawString implementations. | YGraphics | ||
mainSprite : Sprite [read-only] | YGraphics | ||
matrix : Matrix
The transformation matrix. | YGraphics | ||
SPRITE_ASSET_BOUNDS_MODE : Boolean = true [static]
Whether to use the visible bounds of sprite assets to determine
the location where sprite assets are drawn. | YGraphics |
Method | Defined By | ||
---|---|---|---|
YGraphics(sprite:Sprite)
Constructor. | YGraphics | ||
appendTransform(matrix:Matrix):void
Appends the given matrix to the current graphics transformation. | YGraphics | ||
applyFill(fill:IFill, fillRect:IRectangle = null):void
Applies the given fill to the graphics context. | YGraphics | ||
applyStroke(stroke:IStroke, bounds:Rectangle = null, origin:Point = null):void
Applies the given stroke to the graphics context. | YGraphics | ||
beginFill(color:uint, alpha:Number = 1.0):void
Specifies a simple one-color fill that Flash Player uses for subsequent calls to other Graphics methods. | YGraphics | ||
beginGradientFill(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix = null, spreadMethod:String = pad, interpolationMethod:String = rgb, focalPointRatio:Number = 0):void
Specifies a gradient fill that Flash Player uses for subsequent calls to other Graphics methods. | YGraphics | ||
clear():void
Clears the graphics of the sprite this graphics context draws onto
and removes all children of the sprite that were created by this graphics context. | YGraphics | ||
curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void
Draws a curve using the given control and anchor point after applying the current
transformation to these points. | YGraphics | ||
drawCircle(x:Number, y:Number, radius:Number):void
Draws a circle at the given coordinate with the given radius after applying the
current graphics transformation to the given coordinate. | YGraphics | ||
drawEllipse(x:Number, y:Number, width:Number, height:Number):void
Draws an ellipse at the given coordinate with the given width and height after applying
the current transformations to the coordinate. | YGraphics | ||
drawImage(image:DisplayObject, x:Number = -1, y:Number = -1, w:Number = -1, h:Number = -1):void
Adds a display object to the sprite this graphics context belongs to. | YGraphics | ||
drawLine(x1:Number, y1:Number, x2:Number, y2:Number):void
Draws a line from (x1,y1) to (x2,y2). | YGraphics | ||
drawPath(path:GeneralPath):void
Draws a GeneralPath
| YGraphics | ||
drawRect(x:Number, y:Number, width:Number, height:Number):void
Draws a rectangle at the given location with the given width and height after
applying the current graphics transformation to the given location. | YGraphics | ||
drawRoundRect(x:Number, y:Number, width:Number, height:Number, ellipseWidth:Number, ellipseHeight:Number):void
Draws a rounded Rectangle. | YGraphics | ||
drawString(string:String, textFormat:TextFormat, x:Number, y:Number, width:Number = -1, height:Number = -1, showEllipsis:Boolean = true):void
Draws a String by adding a TextField as a child to the sprite. | YGraphics | ||
drawStyledString(string:String, styleSheet:StyleSheet, styleName:String, x:Number, y:Number, width:Number = -1, height:Number = -1, showEllipsis:Boolean = true):void
Draws a String by adding a TextField as a child to the sprite. | YGraphics | ||
drawTLFText(text:String, textFormat:TextLayoutFormat, x:Number, y:Number, width:Number = -1, height:Number = -1, textConverterType:String = plainTextFormat):void
Draws the given text into the YGraphics context using the Text Layout Framework. | YGraphics | ||
endFill(fill:IFill = null):void
Applies a fill to the lines and curves that were added since the last call
to the beginFill(), beginGradientFill(), or beginBitmapFill() method. | YGraphics | ||
getTextSize(text:String, textFormat:TextFormat, styleSheet:StyleSheet = null, styleName:String = null):ISize [static]
Calculates the size a TextField would need to render the given text
using the given textFormat. | YGraphics | ||
getTLFTextSize(text:String, textFormat:TextLayoutFormat, textConverterType:String = plainTextFormat):ISize [static]
Measures the size of the given text as if it was rendered with the given text format
and converted by the given text converter type. | YGraphics | ||
lineGradientStyle(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix = null, spreadMethod:String = pad, interpolationMethod:String = rgb, focalPointRatio:Number = 0):void
Specifies a gradient for the line style that Flash Player uses for subsequent calls to other Graphics methods. | YGraphics | ||
lineStyle(thickness:Number, color:uint = 0, alpha:Number = 1.0, pixelHinting:Boolean = false, scaleMode:String = normal, caps:String = null, joints:String = null, miterLimit:Number = 3):void
Specifies a line style that Flash uses for subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object. | YGraphics | ||
lineTo(x:Number, y:Number):void
Draws a line to given location after applying the current graphics transformation to the given location. | YGraphics | ||
moveTo(x:Number, y:Number):void
Moves the pen to the given location after applying the current graphics transformation
to the location. | YGraphics | ||
prependTransform(matrix:Matrix):void
Prepends the given matrix to the current graphics transformation. | YGraphics | ||
restore():void
Restores a graphics transformation that was saved using save(). | YGraphics | ||
rotate(angle:Number):void
Prepend a rotation to the current graphics transformation. | YGraphics | ||
save():void
Saves the current graphics transformation. | YGraphics | ||
scale(sx:Number, sy:Number):void
Prepend a scale transformation to the current graphics transformation. | YGraphics | ||
translate(tx:Number, ty:Number):void
Prepend a translation to the current graphics transformation. | YGraphics |
ALWAYS_USE_HTML_TEXT | property |
public static var ALWAYS_USE_HTML_TEXT:Boolean = true
Whether the text field's htmlText
property should always
be used in the drawString
implementations.
If false
, the text
property is used instead, unless
an XML tag is detected in the input string.
The default value is true
.
mainSprite | property |
mainSprite:Sprite
[read-only] public function get mainSprite():Sprite
matrix | property |
matrix:Matrix
The transformation matrix. Setting a value will set the matrix to the given value. Reading returns a clone of the current matrix.
public function get matrix():Matrix
public function set matrix(value:Matrix):void
SPRITE_ASSET_BOUNDS_MODE | property |
public static var SPRITE_ASSET_BOUNDS_MODE:Boolean = true
Whether to use the visible bounds of sprite assets to determine the location where sprite assets are drawn. The mode should be enabled to compensate for the fact that flash returns the visible width and height of embedded SVG images but includes potential offsets of the drawing code in SVGs.
The default value is true
.
YGraphics | () | Constructor |
public function YGraphics(sprite:Sprite)
Constructor.
Parameterssprite:Sprite — The sprite this graphics context will draw onto.
|
appendTransform | () | method |
public function appendTransform(matrix:Matrix):void
Appends the given matrix to the current graphics transformation.
Parameters
matrix:Matrix |
applyFill | () | method |
public function applyFill(fill:IFill, fillRect:IRectangle = null):void
Applies the given fill to the graphics context.
Parameters
fill:IFill — The fill to apply
| |
fillRect:IRectangle (default = null ) — The Rectangle object that defines the size of the fill inside the target.
If the dimensions of the Rectangle are larger than the dimensions of the target, the fill is clipped. If the dimensions of the Rectangle are smaller than the dimensions of the target, the fill expands to fill the entire target.
Can be omitted for simple fills such as |
applyStroke | () | method |
public function applyStroke(stroke:IStroke, bounds:Rectangle = null, origin:Point = null):void
Applies the given stroke to the graphics context.
If the provided stroke implements IAdvancedStroke
, the actual drawing methods
will forward the stroke drawing to the stroke implementation.
The bounds and origin of the shape, the stroke is applied to, are optional and may be used when applying a gradient stroke.
Parameters
stroke:IStroke — the stroke to apply
| |
bounds:Rectangle (default = null ) — the bounds of the shape that the stroke is applied to.
| |
origin:Point (default = null ) — the Point that defines the origin (0,0) of the shape in the coordinate system of target.
|
See also
beginFill | () | method |
public function beginFill(color:uint, alpha:Number = 1.0):void
Specifies a simple one-color fill that Flash Player uses for subsequent calls to other Graphics methods.
Please see the documentation in flash.display.Graphics
.
Parameters
color:uint — The color of the fill (0xRRGGBB).
| |
alpha:Number (default = 1.0 ) — The alpha value of the fill (0.0 to 1.0).
|
See also
beginGradientFill | () | method |
public function beginGradientFill(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix = null, spreadMethod:String = pad, interpolationMethod:String = rgb, focalPointRatio:Number = 0):void
Specifies a gradient fill that Flash Player uses for subsequent calls to other Graphics methods.
Please see the documentation in flash.display.Graphics
.
Parameters
type:String — A value from the GradientType class that specifies which gradient type to use: GradientType.LINEAR or GradientType.RADIAL.
| |
colors:Array — An array of RGB hexadecimal color values to be used in the gradient
| |
alphas:Array — An array of alpha values for the corresponding colors in the colors array
| |
ratios:Array — An array of color distribution ratios
| |
matrix:Matrix (default = null ) — A transformation matrix
| |
spreadMethod:String (default = pad ) — A value from the SpreadMethod class that specifies which spread method to use
| |
interpolationMethod:String (default = rgb ) — A value from the InterpolationMethod class that specifies which value to use
| |
focalPointRatio:Number (default = 0 ) — A number that controls the location of the focal point of the gradient
|
See also
clear | () | method |
public function clear():void
Clears the graphics of the sprite this graphics context draws onto and removes all children of the sprite that were created by this graphics context.
curveTo | () | method |
public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void
Draws a curve using the given control and anchor point after applying the current transformation to these points.
Parameters
controlX:Number — A number that specifies the horizontal position of the control point relative to the registration point of the parent display object.
| |
controlY:Number — A number that specifies the vertical position of the control point relative to the registration point of the parent display object.
| |
anchorX:Number — A number that specifies the horizontal position of the next anchor point relative to the registration point of the parent display object.
| |
anchorY:Number — A number that specifies the vertical position of the next anchor point relative to the registration point of the parent display object.
|
See also
drawCircle | () | method |
public function drawCircle(x:Number, y:Number, radius:Number):void
Draws a circle at the given coordinate with the given radius after applying the current graphics transformation to the given coordinate.
Parameters
x:Number — The x coordinate of the center
| |
y:Number — Thy y coordinate of the center
| |
radius:Number — The radius of the circle
|
See also
drawEllipse | () | method |
public function drawEllipse(x:Number, y:Number, width:Number, height:Number):void
Draws an ellipse at the given coordinate with the given width and height after applying the current transformations to the coordinate.
Currently, only the location of the ellipse is transformed.
Parameters
x:Number — The x location of the ellipse
| |
y:Number — The y location of the ellipse
| |
width:Number — The width
| |
height:Number — The height
|
See also
drawImage | () | method |
public function drawImage(image:DisplayObject, x:Number = -1, y:Number = -1, w:Number = -1, h:Number = -1):void
Adds a display object to the sprite this graphics context belongs to.
The display object is added as a child to the sprite. Subsequent calls to any drawing methods will draw onto a child above the image.
If w and h are -1, the given image is not transformed at all.
Parameters
image:DisplayObject — The image to add to the corresponding sprite.
| |
x:Number (default = -1 ) — The x-coordinate of the image.
| |
y:Number (default = -1 ) — The y-coordinate of the image.
| |
w:Number (default = -1 ) — The width of the image.
| |
h:Number (default = -1 ) — The height of the image.
|
drawLine | () | method |
public function drawLine(x1:Number, y1:Number, x2:Number, y2:Number):void
Draws a line from (x1,y1)
to (x2,y2)
.
If the current coordinates of this graphics instance are equal to the (x1,y1)
coordinates, only a lineTo(x2,y2)
will be used. Else, the lineTo is preceded
by a moveTo
.
Parameters
x1:Number — The x-coordinate of the line's start location
| |
y1:Number — The y-coordinate of the line's start location
| |
x2:Number — The x-coordinate of the line's end location
| |
y2:Number — The y-coordinate of the line's end location
|
drawPath | () | method |
public function drawPath(path:GeneralPath):void
Draws a GeneralPath
Parameters
path:GeneralPath — The GeneralPath to draw.
|
drawRect | () | method |
public function drawRect(x:Number, y:Number, width:Number, height:Number):void
Draws a rectangle at the given location with the given width and height after applying the current graphics transformation to the given location.
Currently, the width and height are not transformed.
Parameters
x:Number | |
y:Number | |
width:Number | |
height:Number |
See also
drawRoundRect | () | method |
public function drawRoundRect(x:Number, y:Number, width:Number, height:Number, ellipseWidth:Number, ellipseHeight:Number):void
Draws a rounded Rectangle.
Parameters
x:Number | |
y:Number | |
width:Number | |
height:Number | |
ellipseWidth:Number | |
ellipseHeight:Number |
See also
drawString | () | method |
public function drawString(string:String, textFormat:TextFormat, x:Number, y:Number, width:Number = -1, height:Number = -1, showEllipsis:Boolean = true):void
Draws a String by adding a TextField as a child to the sprite.
Subsequent calls to any drawing methods will draw onto a child above the created TextField.
If the font specified in textFormat
is not embedded,
the string is drawn unrotated, since TextFields rendered
using device fonts cannot be rotated.
Parameters
string:String — The text to draw.
| |
textFormat:TextFormat — The text format to use for the text.
| |
x:Number — The x-coordinate of the top left corner of the text location.
| |
y:Number — The y-coordinate of the top left corner of the text location.
| |
width:Number (default = -1 ) — The width of the TextField to be created.
If -1 , The TextField width will be set to the measured width of the given string.
| |
height:Number (default = -1 ) — The height of the TextField to be created.
If -1 , The TextField height will be set to the measured height of the given string.
| |
showEllipsis:Boolean (default = true ) — If true the text will be truncated if it is too large
for the given size and ellipsis ("...") will be displayed.
|
drawStyledString | () | method |
public function drawStyledString(string:String, styleSheet:StyleSheet, styleName:String, x:Number, y:Number, width:Number = -1, height:Number = -1, showEllipsis:Boolean = true):void
Draws a String by adding a TextField as a child to the sprite.
Uses a StyleSheet
for formatting.
Subsequent calls to any drawing methods will draw onto a child above the created TextField.
If the font specified in textFormat
is not embedded,
the string is drawn unrotated, since TextFields rendered
using device fonts cannot be rotated.
Parameters
string:String — The text to draw.
| |
styleSheet:StyleSheet — The style sheet to use for the text.
| |
styleName:String — The name of the style class to use as default.
| |
x:Number — The x-coordinate of the top left corner of the text location.
| |
y:Number — The y-coordinate of the top left corner of the text location.
| |
width:Number (default = -1 ) — The width of the TextField to be created.
If -1 , The TextField width will be set to the measured width of the given string.
| |
height:Number (default = -1 ) — The height of the TextField to be created.
If -1 , The TextField height will be set to the measured height of the given string
| |
showEllipsis:Boolean (default = true ) — If true the text will be truncated if it is too large
for the given size and ellipsis ("...") will be displayed.
|
drawTLFText | () | method |
public function drawTLFText(text:String, textFormat:TextLayoutFormat, x:Number, y:Number, width:Number = -1, height:Number = -1, textConverterType:String = plainTextFormat):void
Draws the given text into the YGraphics context using the Text Layout Framework.
This method is not available in the Flex 3 version of yFiles FLEX.
Parameters
text:String — The text to draw.
| |
textFormat:TextLayoutFormat — The text format to use.
| |
x:Number — The left border of the given text.
| |
y:Number — The top border of the given text.
| |
width:Number (default = -1 ) — The maximum width of the given text. If set smaller than 0 the width is unbound.
| |
height:Number (default = -1 ) — The maximum height of the given text. If set smaller than 0 the height is unbound.
| |
textConverterType:String (default = plainTextFormat ) — Determines how the given text is imported into a TextFlow .
One of the constants provided by flashx.textLayout.conversion.TextConverter .
|
endFill | () | method |
public function endFill(fill:IFill = null):void
Applies a fill to the lines and curves that were added since the last call to the beginFill(), beginGradientFill(), or beginBitmapFill() method.
Please see the documentation in flash.display.Graphics
.
Parameters
fill:IFill (default = null ) — The fill to end
|
See also
getTextSize | () | method |
public static function getTextSize(text:String, textFormat:TextFormat, styleSheet:StyleSheet = null, styleName:String = null):ISize
Calculates the size a TextField
would need to render the given text
using the given textFormat
.
Parameters
text:String — The text to calculate the size for.
| |
textFormat:TextFormat — The text format used for the text.
| |
styleSheet:StyleSheet (default = null )
| |
styleName:String (default = null )
|
ISize — The size a TextField would need to render the given text
using the given textFormat .
|
getTLFTextSize | () | method |
public static function getTLFTextSize(text:String, textFormat:TextLayoutFormat, textConverterType:String = plainTextFormat):ISize
Measures the size of the given text as if it was rendered with the given text format and converted by the given text converter type.
This method is not available in the Flex 3 version of yFiles FLEX.
Parameters
text:String — The text to measure.
| |
textFormat:TextLayoutFormat — The text format.
| |
textConverterType:String (default = plainTextFormat ) — The text converter type which is used to create a TextFlow
from the label's text. One of the constants provided by
flashx.textLayout.conversion.TextConverter .
|
ISize — The measured size.
|
lineGradientStyle | () | method |
public function lineGradientStyle(type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix = null, spreadMethod:String = pad, interpolationMethod:String = rgb, focalPointRatio:Number = 0):void
Specifies a gradient for the line style that Flash Player uses for subsequent calls to other Graphics methods.
Please see the documentation in flash.display.Graphics
.
Parameters
type:String — A value from the GradientType class that specifies which gradient type to use
| |
colors:Array — An array of RGB hex color values to be used in the gradient
| |
alphas:Array — An array of alpha values for the corresponding colors in the colors array
| |
ratios:Array — An array of color distribution ratios; valid values are from 0 to 255.
| |
matrix:Matrix (default = null ) — A transformation matrix as defined by the flash.geom.Matrix class.
| |
spreadMethod:String (default = pad ) — A value from the SpreadMethod class that specifies which spread method to use
| |
interpolationMethod:String (default = rgb ) — A value from the InterpolationMethod class that specifies which value to use.
| |
focalPointRatio:Number (default = 0 ) — A number that controls the location of the focal point of the gradient.
|
See also
lineStyle | () | method |
public function lineStyle(thickness:Number, color:uint = 0, alpha:Number = 1.0, pixelHinting:Boolean = false, scaleMode:String = normal, caps:String = null, joints:String = null, miterLimit:Number = 3):void
Specifies a line style that Flash uses for subsequent calls to other Graphics methods (such as lineTo() or drawCircle()) for the object.
Please see the documentation in flash.display.Graphics
.
Parameters
thickness:Number | |
color:uint (default = 0 )
| |
alpha:Number (default = 1.0 )
| |
pixelHinting:Boolean (default = false )
| |
scaleMode:String (default = normal )
| |
caps:String (default = null )
| |
joints:String (default = null )
| |
miterLimit:Number (default = 3 )
|
See also
lineTo | () | method |
public function lineTo(x:Number, y:Number):void
Draws a line to given location after applying the current graphics transformation to the given location.
Parameters
x:Number — The x coordinate of the new cursor position
| |
y:Number — Thy y coordinate of the new cursor position
|
See also
moveTo | () | method |
public function moveTo(x:Number, y:Number):void
Moves the pen to the given location after applying the current graphics transformation to the location.
Parameters
x:Number — The x coordinate of the new cursor position
| |
y:Number — Thy y coordinate of the new cursor position
|
See also
prependTransform | () | method |
public function prependTransform(matrix:Matrix):void
Prepends the given matrix to the current graphics transformation.
Parameters
matrix:Matrix — The matrix to prepend.
|
restore | () | method |
public function restore():void
Restores a graphics transformation that was saved using save()
.
IllegalOperationError — if save() has not been called before.
|
rotate | () | method |
public function rotate(angle:Number):void
Prepend a rotation to the current graphics transformation.
Parameters
angle:Number — The rotation angle.
|
save | () | method |
public function save():void
Saves the current graphics transformation. The state can be restored later
by calling restore()
.
scale | () | method |
public function scale(sx:Number, sy:Number):void
Prepend a scale transformation to the current graphics transformation.
Parameters
sx:Number — The scale factor in x-direction.
| |
sy:Number — The scale factor in y-direction.
|
setTextFormatDefaults | () | method |
yworks_internal static function setTextFormatDefaults(tf:TextFormat):void
Parameters
tf:TextFormat |
translate | () | method |
public function translate(tx:Number, ty:Number):void
Prepend a translation to the current graphics transformation.
Parameters
tx:Number — The translation on the x-axis.
| |
ty:Number — The translation on the y-axis.
|