Adobe Photoshop CS5 Object Library JS: Selection

Photoshop CS5

Class

Selection

 The selected area of the document or layer.

QuickLinks

clear, contract, copy, cut, deselect, expand, feather, fill, grow, invert, load, makeWorkPath, resize, resizeBoundary, rotate, rotateBoundary, select, selectAll, selectBorder, similar, smooth, store, stroke, translate, translateBoundary

Hierarchy

Object
Selection

Properties

PropertyTypeAccessDescription
boundsUnitRect readonlyThe bounding rectangle of the entire selection.
parentObject readonlyThe object's container.
solidbool readonlyIf true, the bounding rectangle a solid rectangle.
typenamestring readonlyThe class name of the object.

Methods

Instances

void clear ()
Clears the selection and does not copy it to the clipboard.

void contract (by: UnitValue)
Contracts the selection.

ParameterTypeDescription
byUnitValueThe amount to contract the selection.

void copy ([merge: bool])
Copies the selection to the clipboard.

ParameterTypeDescription
mergeboolIf true the copy includes all visible layers. If false, copies only from the current layer. (Optional)

void cut ()
Cuts the current selection to the clipboard.

void deselect ()
Deselects the current selection.

void expand (by: UnitValue)
Expands the selection.

ParameterTypeDescription
byUnitValueThe amount to expand the selection.

void feather (by: UnitValue)
Feathers the edges of the selection.

ParameterTypeDescription
byUnitValueThe amount to feather the edge.

void fill (fillType: any[, mode: ColorBlendMode=ColorBlendMode.NORMAL][, opacity: int=100][, preserveTransparency: bool])
Fills the selection.

ParameterTypeDescription
fillType any The color or history state with which to fill the object.
modeColorBlendMode:
ColorBlendMode.NORMAL
ColorBlendMode.DISSOLVE
ColorBlendMode.BEHIND
ColorBlendMode.CLEAR
ColorBlendMode.DARKEN
ColorBlendMode.MULTIPLY
ColorBlendMode.COLORBURN
ColorBlendMode.LINEARBURN
ColorBlendMode.LIGHTEN
ColorBlendMode.SCREEN
ColorBlendMode.COLORDODGE
ColorBlendMode.LINEARDODGE
ColorBlendMode.OVERLAY
ColorBlendMode.SOFTLIGHT
ColorBlendMode.HARDLIGHT
ColorBlendMode.VIVIDLIGHT
ColorBlendMode.LINEARLIGHT
ColorBlendMode.PINLIGHT
ColorBlendMode.DIFFERENCE
ColorBlendMode.EXCLUSION
ColorBlendMode.HUE
ColorBlendMode.SATURATION
ColorBlendMode.COLOR
ColorBlendMode.LUMINOSITY
ColorBlendMode.HARDMIXBLEND
The color blend mode. (default: ColorBlendMode.NORMAL) (Optional)
opacityintThe opacity as a percentage. Range: 1 to 100. (default: 100) (Optional)
preserveTransparencyboolIf true, perserves transparencies. (Optional)

void grow (tolerance: int, antiAlias: bool)
Grows the selection to include all adjacent pixels falling within the specified tolerance range.

ParameterTypeDescription
toleranceint (range: 0 - 255)The tolerance range. Range: 0 to 255.
antiAliasboolIf true, anti-aliasing is used.

void invert ()
Inverts the selection.

void load (from: Channel[, combination: SelectionType=SelectionType.REPLACE][, inverting: bool=false])
Loads the selection from the specified channel.

ParameterTypeDescription
fromChannelThe channel to load the selection from.
combinationSelectionType:
SelectionType.REPLACE
SelectionType.EXTEND
SelectionType.DIMINISH
SelectionType.INTERSECT
How to combine the channel contents with the existing selection. (default: SelectionType.REPLACE) (Optional)
invertingboolIf true, selects the inverse of the channel contents. (default: false) (Optional)

void makeWorkPath ([tolerance: number])
Makes this selection item the workpath for this document.

ParameterTypeDescription
tolerancenumberThe tolerance in pixels. (Optional)

void resize ([horizontal: number=100][, vertical: number=100][, anchor: AnchorPosition=AnchorPosition.MIDDLECENTER])
Resizes the selected area to the specified dimensions and anchor position.

ParameterTypeDescription
horizontalnumberThe amount to scale the selection horizontally (as a percentage). (default: 100) (Optional)
verticalnumberThe amount to scale the selection vertically (as a percentage). (default: 100) (Optional)
anchorAnchorPosition:
AnchorPosition.TOPLEFT
AnchorPosition.TOPCENTER
AnchorPosition.TOPRIGHT
AnchorPosition.MIDDLELEFT
AnchorPosition.MIDDLECENTER
AnchorPosition.MIDDLERIGHT
AnchorPosition.BOTTOMLEFT
AnchorPosition.BOTTOMCENTER
AnchorPosition.BOTTOMRIGHT
The point to scale around. (default: AnchorPosition.MIDDLECENTER) (Optional)

void resizeBoundary ([horizontal: number=100][, vertical: number=100][, anchor: AnchorPosition=AnchorPosition.MIDDLECENTER])
Scales the boundary of the selection.

ParameterTypeDescription
horizontalnumberThe amount to scale the object horizontally (as a percentage). (default: 100) (Optional)
verticalnumberThe amount to scale the object vertically (as a percentage). (default: 100) (Optional)
anchorAnchorPosition:
AnchorPosition.TOPLEFT
AnchorPosition.TOPCENTER
AnchorPosition.TOPRIGHT
AnchorPosition.MIDDLELEFT
AnchorPosition.MIDDLECENTER
AnchorPosition.MIDDLERIGHT
AnchorPosition.BOTTOMLEFT
AnchorPosition.BOTTOMCENTER
AnchorPosition.BOTTOMRIGHT
The point to scale around. (default: AnchorPosition.MIDDLECENTER) (Optional)

void rotate (angle: number[, anchor: AnchorPosition=AnchorPosition.MIDDLECENTER])
Rotates the object.

ParameterTypeDescription
anglenumberThe number of degrees to rotate the object.
anchorAnchorPosition:
AnchorPosition.TOPLEFT
AnchorPosition.TOPCENTER
AnchorPosition.TOPRIGHT
AnchorPosition.MIDDLELEFT
AnchorPosition.MIDDLECENTER
AnchorPosition.MIDDLERIGHT
AnchorPosition.BOTTOMLEFT
AnchorPosition.BOTTOMCENTER
AnchorPosition.BOTTOMRIGHT
The point to rotate about. (default: AnchorPosition.MIDDLECENTER) (Optional)

void rotateBoundary (angle: number[, anchor: AnchorPosition=AnchorPosition.MIDDLECENTER])
Rotates the boundary of the selection.

ParameterTypeDescription
anglenumberThe rotation angle (in degrees)
anchorAnchorPosition:
AnchorPosition.TOPLEFT
AnchorPosition.TOPCENTER
AnchorPosition.TOPRIGHT
AnchorPosition.MIDDLELEFT
AnchorPosition.MIDDLECENTER
AnchorPosition.MIDDLERIGHT
AnchorPosition.BOTTOMLEFT
AnchorPosition.BOTTOMCENTER
AnchorPosition.BOTTOMRIGHT
The point to rotate about. (default: AnchorPosition.MIDDLECENTER) (Optional)

void select (region: Array of any[, type: SelectionType=SelectionType.REPLACE][, feather: number=0][, antiAlias: bool=true])
Selects the specified region.

ParameterTypeDescription
region Array of any Array of x and y coordinates that describe the corners of the selection, in the format [[x1, y1], [x2,y2],[x3, y3], [x4,y4]]
typeSelectionType:
SelectionType.REPLACE
SelectionType.EXTEND
SelectionType.DIMINISH
SelectionType.INTERSECT
The method for combining the new selection with the existing selection. (default: SelectionType.REPLACE) (Optional)
feathernumberThe feather amount. (default: 0) (Optional)
antiAliasboolIf true, anti-aliasing is used. (default: true) (Optional)

void selectAll ()
Selects the entire layer.

void selectBorder (width: UnitValue)
Selects the selection border only (in the specified width); subsequent actions do not affect the selected area within the borders.

ParameterTypeDescription
widthUnitValueThe width of the border selection.

void similar (tolerance: int, antiAlias: bool)
Grows the selection to include pixels throughout the image falling within the tolerance range.

ParameterTypeDescription
toleranceintThe tolerance range. Range: 0 to 255.
antiAliasboolIf true, anti-aliasing is used.

void smooth (radius: int)
Cleans up stray pixels left inside or outside a color-based selection (within the radius specified in pixels).

ParameterTypeDescription
radiusint (range: 0 - 100)The sample radius in pixels. Range: 0 to 100.

void store (into: Channel[, combination: SelectionType=SelectionType.REPLACE])
Saves the selection as a channel.

ParameterTypeDescription
intoChannelThe channel to save the selection to.
combinationSelectionType:
SelectionType.REPLACE
SelectionType.EXTEND
SelectionType.DIMINISH
SelectionType.INTERSECT
How to add the selection to the existing contents of the channel. (default: SelectionType.REPLACE) (Optional)

void stroke (strokeColor: any, width: int[, location: StrokeLocation=StrokeLocation.CENTER][, mode: ColorBlendMode=ColorBlendMode.NORMAL][, opacity: int=100][, preserveTransparency: bool])
Strokes the selection.

ParameterTypeDescription
strokeColor any The color to stroke the selection with.
widthintThe stroke width.
locationStrokeLocation:
StrokeLocation.INSIDE
StrokeLocation.CENTER
StrokeLocation.OUTSIDE
The stroke location. (default: StrokeLocation.CENTER) (Optional)
modeColorBlendMode:
ColorBlendMode.NORMAL
ColorBlendMode.DISSOLVE
ColorBlendMode.BEHIND
ColorBlendMode.CLEAR
ColorBlendMode.DARKEN
ColorBlendMode.MULTIPLY
ColorBlendMode.COLORBURN
ColorBlendMode.LINEARBURN
ColorBlendMode.LIGHTEN
ColorBlendMode.SCREEN
ColorBlendMode.COLORDODGE
ColorBlendMode.LINEARDODGE
ColorBlendMode.OVERLAY
ColorBlendMode.SOFTLIGHT
ColorBlendMode.HARDLIGHT
ColorBlendMode.VIVIDLIGHT
ColorBlendMode.LINEARLIGHT
ColorBlendMode.PINLIGHT
ColorBlendMode.DIFFERENCE
ColorBlendMode.EXCLUSION
ColorBlendMode.HUE
ColorBlendMode.SATURATION
ColorBlendMode.COLOR
ColorBlendMode.LUMINOSITY
ColorBlendMode.HARDMIXBLEND
The color blend mode. (default: ColorBlendMode.NORMAL) (Optional)
opacityintThe opacity of the stroke color as a percentage. Range: 1 to 100. (default: 100) (Optional)
preserveTransparencyboolIf true, preserves transparency. (Optional)

void translate ([deltaX: UnitValue][, deltaY: UnitValue])
Moves the object relative to its current position.

ParameterTypeDescription
deltaXUnitValueThe amount to move the object horizontally. (Optional)
deltaYUnitValueThe amount to move the object vertically. (Optional)

void translateBoundary ([deltaX: UnitValue][, deltaY: UnitValue])
Moves the boundary of selection relative to its current position.

ParameterTypeDescription
deltaXUnitValueThe amount to move the object horizontally. (Optional)
deltaYUnitValueThe amount to move the object vertically. (Optional)

Element of

Document.selection

Jongware, 28-Aug-2012 v3.0.3iContents :: Index