Adobe 27510753 Scripting Guide - Page 75

Converting pixel and percentage values, UnitValue object properties

Page 75 highlights

Adobe InDesign CS2 Scripting Guide Using ExtendScript Tools and Features 67 tpc traditional pica traditional picas 12 tpt ci cicero ciceros 12.7872 pt px pixel pixels baseless (see below) % percent percent baseless (see below) If an unknown unit type is supplied, the type is set to "?", and the UnitValue object prints as "UnitValue 0.00000". For example, all of the following formats are equivalent: myVal = new UnitValue (12, "cm"); myVal = new UnitValue ("12 cm"); myVal = UnitValue ("12 centimeters"); UnitValue object properties baseUnit type value UnitValue String Number A UnitValue Object that defines the size of one pixel, or a total size to use as a base for percentage values. This is used as the base conversion unit for pixels and percentages; see the "Converting pixel and percentage values" section . Default is 0.013889 inches (1/72 in), which is the base conversion unit for pixels at 72 dpi. Set to null to restore the default. The unit type in abbreviated form; for example, "cm" or "in". The numeric measurement value. UnitValue object functions as unitValueObj.as (unit) Returns the numeric value of this object in the given unit. If the unit is unknown or cannot be computed, generates a run-time error. unit The unit type in abbreviated form; for example, "cm" or "in". convert unitValueObj.convert (unit) Converts this object to the given unit, resetting the type and value accordingly. Returns true if the conversion is successful. If the unit is unknown or the object cannot be converted, generates a run-time error and returns false. unit The unit type in abbreviated form; for example, "cm" or "in". Converting pixel and percentage values Converting measurements among different units requires a common base unit. For example, for length, the meter is the base unit. All length units can be converted into meters, which makes it possible to convert any length unit into any other length unit. Pixels and percentages do not have a standard common base unit. Pixel measurements are relative to display resolution , and percentages are relative to an absolute total size.

  • 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
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

Adobe InDesign CS2 Scripting Guide
Using ExtendScript Tools and Features
67
tpc
traditional pica
traditional picas
12 tpt
ci
cicero
ciceros
12.7872 pt
px
pixel
pixels
baseless (see below)
%
percent
percent
baseless (see below)
If an unknown unit type is supplied, the type is set to
“?”
, and the
UnitValue
object prints as “UnitValue
0.00000”.
For example, all of the following formats are equivalent:
myVal = new UnitValue (12, "cm");
myVal = new UnitValue ("12 cm");
myVal = UnitValue ("12 centimeters");
UnitValue object properties
baseUnit
UnitValue
A
UnitValue
Object that defines the size of one pixel, or a total size to use
as a base for percentage values. This is used as the base conversion unit for
pixels and percentages; see the “Converting pixel and percentage values”
section .
Default is 0.013889 inches (1/72 in), which is the base conversion unit for
pixels at 72 dpi. Set to
null
to restore the default.
type
String
The unit type in abbreviated form; for example, “cm” or “in”.
value
Number
The numeric measurement value.
UnitValue object functions
as
unitValueObj
.as (
unit
)
Returns the numeric value of this object in the given unit.
If the unit is unknown or cannot be computed, generates a run-time
error.
unit
The unit type in abbreviated form; for example, “cm” or “in”.
convert
unitValueObj
.convert
(
unit
)
Converts this object to the given unit, resetting the
type
and
value
accordingly. Returns
true
if the conversion is successful. If the unit
is unknown or the object cannot be converted, generates a run-time
error and returns
false
.
unit
The unit type in abbreviated form; for example, “cm” or “in”.
Converting pixel and percentage values
Converting measurements among different units requires a common base unit. For example, for length, the
meter is the base unit. All length units can be converted into meters, which makes it possible to convert any
length unit into any other length unit.
Pixels and percentages do not have a standard common base unit. Pixel measurements are relative to display
resolution , and percentages are relative to an absolute total size.