-
Notifications
You must be signed in to change notification settings - Fork 0
/
show-path-properties.js
45 lines (39 loc) · 1.09 KB
/
show-path-properties.js
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
//@strict on
//@target Illustrator
const localized = {
emptySelection: {
en: 'Select path',
fr: 'Choisissez un tracé',
},
error: {
en: 'Error',
fr: 'Erreur',
},
itemType: {
en: 'Unsupported item of type %1',
fr: 'Élément non supporté de type %1',
},
}
/**
* showProperties :: PathItem -> void
*/
function showProperties(item) {
var infos = []
infos.push('name: ' + item.name)
infos.push('total length: ' + item.length + ' pt')
infos.push('area: ' + item.area + ' pt')
infos.push('bounds: ' + item.controlBounds.join(', '))
infos.push('is closed: ' + item.closed)
infos.push('is clipping: ' + item.clipping)
alert(infos.join('\n'))
}
if (documents.length > 0 && selection.length > 0) {
if (selection[0].typename === 'PathItem') {
showProperties(selection[0])
} else {
alert(selection[0].name)
alert(localize(localized.itemType, selection[0].typename), localize(localized.error))
}
} else {
alert(localize(localized.emptySelection), localize(localized.error))
}