Adobe 23101764 Scripting Guide - Page 98

History object

Page 98 highlights

Scripting Photoshop 3 History object 3.15.3 Comparing Colors Using the equal colors (IsEqual/isEqual) commands, you can easily compare colors. These methods will return true if the colors are visually equal to each other and false otherwise. The examples below compare the foreground color to the background color. AS: if equal colors foreground color with background color then VB: If (appRef.ForegroundColor.IsEqual(appRef.BackgroundColor)) Then JS: if (app.foregroundColor.isEqual(backgroundColor)) 3.15.4 Getting a Web Safe Color To convert a color to a web safe color use the web safe color command on AppleScript and the NearestWebColor/nearestWebColor property on the SolidColor object for Visual Basic and JavaScript. The web safe color returned is an RGB color. AS: set myWebSafeColor to web safe color for foreground color VB: Dim myWebSafeColor As Photoshop.RGBColor Set myWebSafeColor = appRef.ForegroundColor.NearestWebColor JS: var webSafeColor = new RGBColor(); webSafeColor = app.foregroundColor.nearestWebColor; 3.16 History object Photoshop keeps a history of the actions that affect the appearance of documents. Each entry in the Photoshop History palette is considered a "History State." These states are accessable from document object and can be used to reset the document to a previous state. A history state can also be used to fill a selection. To set your document back to a particular state, set the document's current history state: AS: set current history state of current document to history state 1 ¬ of current document VB: docRef.ActiveHistoryState = docRef.HistoryStates(1) JS: docRef.activeHistoryState = docRef.historyStates[0]; Photoshop CS Scripting Guide 94

  • 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
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
94
Scripting Photoshop
History object
3
3.15.3
Comparing Colors
Using the
equal colors (IsEqual/isEqual)
commands, you can easily compare
colors. These methods will return
true
if the colors are visually equal to each other and
false
otherwise. The examples below compare the foreground color to the background color.
AS:
if equal colors foreground color with background color then
VB:
If (appRef.ForegroundColor.IsEqual(appRef.BackgroundColor)) Then
JS:
if (app.foregroundColor.isEqual(backgroundColor))
3.15.4
Getting a Web Safe Color
To convert a color to a web safe color use the
web safe color
command on AppleScript
and the
NearestWebColor/nearestWebColor
property on the
SolidColor
object for
Visual Basic and JavaScript. The web safe color returned is an RGB color.
AS:
set myWebSafeColor to web safe color for foreground color
VB:
Dim myWebSafeColor As Photoshop.RGBColor
Set myWebSafeColor = appRef.ForegroundColor.NearestWebColor
JS:
var webSafeColor = new RGBColor();
webSafeColor = app.foregroundColor.nearestWebColor;
3.16 History object
Photoshop keeps a history of the actions that affect the appearance of documents. Each entry
in the Photoshop History palette is considered a “History State.” These states are accessable
from document object and can be used to reset the document to a previous state. A history state
can also be used to
ll a selection.
To set your document back to a particular state, set the document's current history state:
AS:
set current history state of current document to history state 1 ¬
of current document
VB:
docRef.ActiveHistoryState = docRef.HistoryStates(1)
JS:
docRef.activeHistoryState = docRef.historyStates[0];