Adobe 65010248 Scripting Guide - Page 47

Creating a rectangle, Creating a polygon, method to create a polygon with these properties

Page 47 highlights

CHAPTER 5: Scripting with JavaScript Creating paths and shapes 47 Creating a rectangle Consider the following sample var myDocument = app.documents.add() var artLayer = myDocument.layers.add() var rect = artLayer.pathItems.rectangle( 144, 144, 72, 216 ); The sample uses the pathItems object's rectangle() method to create a rectangle with these properties: ➤ The top of the rectangle is 2 inches (144 points) from the bottom edge of the page. ➤ The left edge is 2 inches (144 points) from the left edge of the page. ➤ The rectangle is 1 inch (72 points) wide and 3 inches (216 points) long. Creating a polygon Consider the following sample: var myDocument = app.documents.add() var artLayer = myDocument.layers.add() var poly = artLayer.pathItems.polygon( 144, 288, 72.0, 7 ); The sample uses the polygon() method to create a polygon with these properties: ➤ The center point of the object is inset is 2 inches (144 points) on the horizontal axis and 4 inches (288 points) on the vertical axis. ➤ The length of the radius from the center point to each corner is 1 inch (72 points). ➤ The polygon has 7 sides.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

C
HAPTER
5: Scripting with JavaScript
Creating paths and shapes
47
Creating a rectangle
Consider the following sample
var myDocument = app.documents.add()
var artLayer = myDocument.layers.add()
var rect = artLayer.pathItems.rectangle( 144, 144, 72, 216 );
The sample uses the
pathItems
object’s
rectangle()
method to create a rectangle with these properties:
The top of the rectangle is 2 inches (144 points) from the bottom edge of the page.
The left edge is 2 inches (144 points) from the left edge of the page.
The rectangle is 1 inch (72 points) wide and 3 inches (216 points) long.
Creating a polygon
Consider the following sample:
var myDocument = app.documents.add()
var artLayer = myDocument.layers.add()
var poly = artLayer.pathItems.polygon( 144, 288, 72.0, 7 );
The sample uses the
polygon()
method to create a polygon with these properties:
The center point of the object is inset is 2 inches (144 points) on the horizontal axis and 4 inches (288
points) on the vertical axis.
The length of the radius from the center point to each corner is 1 inch (72 points).
The polygon has 7 sides.