-
Notifications
You must be signed in to change notification settings - Fork 0
/
jtextbox.js
103 lines (93 loc) · 2.34 KB
/
jtextbox.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
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
autowatch = 1
mgraphics.init();
mgraphics.relative_coords = 0;
mgraphics.autofill = 0;
// Include the JTextBox class definition
include("JTextBox_class.js");
// Define text for text box. Using the \ character to split multiple
// linse only for readbility - has no effect on the text rendering
var text = "<h1>JSUI Text Renderer\
<bd>A <st>response<bd> to the effort required to manually display JSUI text \
if you want to use <st>multiple fonts <bd>and/or font sizes or <rd>colors. \
<bd>This will also <em>word-wrap the text to a defined 'text box'! \
<cr>This is an example of a Dynamic JTextBox."
var plainText = "<h1>A HEADING<bd>A response to the effort <st>required to manually display JSUI text \
if you want to use multiple fonts and/or <bd>font sizes or colors. \
This will also word-wrap the text to a defined text box."
var text2 = "Jaded zombies acted quaintly but kept driving their oxen forward."
var text3 = "A mad boxer shot a quick, gloved jab to the jaw of his dizzy opponent."
var staticText = "This is an example of a Static JTextBox."
var styles = {
"none" : {},
"basic" : {
"padding": 12,
"background" : [0.8, 0.8, 0.8, 1.0],
"color": [0.3, 0.3, 0.3, 1.0],
"font": "Arial",
"size": 20,
"lineheight": 1.2,
"align": "right",
"bd" : {
"size": 20
},
"em": {
"font" : "Arial Italic"
},
"rd": {
"color": [1.0, 0,0,1.0],
"size" : 20
},
"st": {
"color": [0,0,0.5,1],
"size" : 20,
},
"h1": {
"font": "Arial Bold",
"size": 24,
"lineheight": 1.4,
"color": [0, 0,0,1.0],
}
},
"style2" : {
"background" : [0.9, 0.8, 0.0, 1.0],
"color": [0.0, 0.0, 0.0, 1.0],
"padding": 0,
"font": "American Typewriter",
"size": 16,
"lineheight": 1.2,
"align": "center",
"bd": {
},
"st": {
},
"em": {
},
"h1": {
"font": "Ableton Regular Bold",
"size": 24,
"lineheight": 1.2,
},
"h2": {
"size": 14,
"lineheight": 1.1
}
}
}
// Create a couple of text boxes
var myTextBox = new JTextBox(this, text, styles["basic"], 0, 0, 0, 0);
var tb2 = new JTextBox(this, text3, styles["style2"], 100, 250, 200, 150, 4.0);
// JSUI Paint Function - call your text box paint function here
function paint() {
if (myTextBox) {
myTextBox.paint();
}
tb2.paint();
}
function onresize(w, h) {
this.box.size(w, h);
if (myTextBox) {
myTextBox.calcWindow()
}
tb2.calcWindow();
refresh();
}