-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathalignment.js
55 lines (51 loc) · 1.48 KB
/
alignment.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
46
47
48
49
50
51
52
53
54
55
'use strict';
// fraction of some size to get to a named position
module.exports = {
// from bottom left: this is the origin of our paper-reference
// positioning system
FROM_BL: {
left: 0,
center: 0.5,
right: 1,
bottom: 0,
middle: 0.5,
top: 1
},
// from top left: this is the screen pixel positioning origin
FROM_TL: {
left: 0,
center: 0.5,
right: 1,
bottom: 1,
middle: 0.5,
top: 0
},
// from bottom right: sometimes you just need the opposite of ^^
FROM_BR: {
left: 1,
center: 0.5,
right: 0,
bottom: 0,
middle: 0.5,
top: 1
},
// multiple of fontSize to get the vertical offset between lines
LINE_SPACING: 1.3,
// multiple of fontSize to shift from the baseline
// to the cap (captical letter) line
// (to use when we don't calculate this shift from Drawing.bBox)
// This is an approximation since in reality cap height can differ
// from font to font. However, according to Wikipedia
// an "average" font might have a cap height of 70% of the em
// https://en.wikipedia.org/wiki/Em_(typography)#History
CAP_SHIFT: 0.70,
// half the cap height (distance between baseline and cap line)
// of an "average" font (for more info see above).
MID_SHIFT: 0.35,
OPPOSITE_SIDE: {
left: 'right',
right: 'left',
top: 'bottom',
bottom: 'top'
}
};