StrokeCodeGenerator

An encapsulation of code generation for a graphical stroke.

Summary
StrokeCodeGeneratorAn encapsulation of code generation for a graphical stroke.
Code generation
generateCodeGenerates script code for methods creating a stroke sprite, shape or a path.
generateGraphicsCodeGenerate AS3 code for a method creating a sprite or a shape.
generateActionCodeGenerate AS3 code for a graphics drawing action.
generatePathCodeGenerate AS3 code for a method creating a value or motion path.
Static helpers
approximateEqualChekcs if two values are almost the same.

Code generation

generateCode

public static function generateCode(stroke: Stroke,
title: String,
indent: String,
codeStyle: Object):String

Generates script code for methods creating a stroke sprite, shape or a path.

Parameters

strokegraphics stroke object
titleversion decorated identification of the generating application
indentstring with spaces to indent each line of code
codeStyledynamic object with properties describing the desired code style

Returns

a script snippet

generateGraphicsCode

private static function generateGraphicsCode(stroke: Stroke,
title: String,
shapeName: String,
tempName: String,
indent: String,
appendCode: String,
scaleXFunc: Function,
scaleYFunc: Function):String

Generate AS3 code for a method creating a sprite or a shape.

Parameters

strokegraphics stroke object
titleversion decorated identification of the generating application
shapeNameasset name of the asset being generated
tempNamename of the temporary variable used in the method
indentstring with spaces to indent each line of code
appendCodecode snippet string inserted after the graphics code
scaleXFunca function for scaling X values
scaleYFunca function for scaling Y values

Returns

An AS3 code snippet

generateActionCode

private static function generateActionCode(item: StrokeItem,
itemPrev: StrokeItem,
scaleXFunc: Function,
scaleYFunc: Function):String

Generate AS3 code for a graphics drawing action.

Parameters

itemthe StrokeItem to generate code for
itemPrevthe StrokeItem before the current item, can be null
scaleXFunca function for scaling X values
scaleYFunca function for scaling Y values

Returns

An AS3 method code snippet

generatePathCode

private static function generatePathCode(stroke: Stroke,
title: String,
shapeName: String,
tempName: String,
indent: String):String

Generate AS3 code for a method creating a value or motion path.

Parameters

strokegraphics stroke object
titleversion decorated identification of the generating application
shapeNameasset name of the path being generated
tempNamename of the temporary variable used in the method
indentstring with spaces to indent each line of code

Returns

An AS3 code snippet

Static helpers

approximateEqual

private static function approximateEqual(val1: Number,
val2: Number):Boolean

Chekcs if two values are almost the same.

’Almost’ is here defined as one percent to either side.

Parameters

val1, val2numbers to compare

Returns

True if the values are approximately equal, false otherwise.

public static function generateCode(stroke: Stroke,
title: String,
indent: String,
codeStyle: Object):String
Generates script code for methods creating a stroke sprite, shape or a path.
private static function generateGraphicsCode(stroke: Stroke,
title: String,
shapeName: String,
tempName: String,
indent: String,
appendCode: String,
scaleXFunc: Function,
scaleYFunc: Function):String
Generate AS3 code for a method creating a sprite or a shape.
private static function generateActionCode(item: StrokeItem,
itemPrev: StrokeItem,
scaleXFunc: Function,
scaleYFunc: Function):String
Generate AS3 code for a graphics drawing action.
private static function generatePathCode(stroke: Stroke,
title: String,
shapeName: String,
tempName: String,
indent: String):String
Generate AS3 code for a method creating a value or motion path.
private static function approximateEqual(val1: Number,
val2: Number):Boolean
Chekcs if two values are almost the same.
Defines a stroke item structure, that is a curve or line segment point or an object such as a circle, ellipse or rectangle.
Close