Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created October 12, 2011 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/1281477 to your computer and use it in GitHub Desktop.
Save zeffii/1281477 to your computer and use it in GitHub Desktop.
descriptor test
var textblock_one = new Array("Line 1", "Line 2", "Line 3", "Line 4");
var textblock_two = new Array("Line 01", "Line 02", "Line 03", "Line 04", "more lines");
var textblock_three = new Array("Line 001", "Line 002", "Line 003", "Line 004");
var thisLineHeight = 18;
var fontSizeValue = 16;
var myDecoratorColour = '#555555';
var myTextColour = '#333333';
// take multiple arguments as variables
function drawDecorator(myDecoratorColour, locX, locY){
var path = new Path();
path.strokeColor = myDecoratorColour;
path.strokeWidth = 5;
var start = new Point(locX, locY);
path.moveTo(start);
path.lineTo(start + [ 140, 0 ]); // Note the plus operator on Point objects.
}
function maketextBlock(myTextArray, locX, locY){
// draw init decorator
drawDecorator(myDecoratorColour, locX, locY-20);
// draw typography
var i = 0;
for (i; i < myTextArray.length; i++){
var text = new PointText(new Point(locX, locY));
text.content = myTextArray[i];
text.characterStyle = {
fontSize: fontSizeValue,
fillColor: myTextColour};
locY += thisLineHeight;
}
// draw end decorator
drawDecorator(myDecoratorColour, locX, locY-12);
}
// these three function calls pass an Array of text and x, y coordinates
maketextBlock(textblock_one, 50, 100);
maketextBlock(textblock_two, 200, 100);
maketextBlock(textblock_three, 350, 100);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment