Mercurial > hg > forks > multipaint-js
annotate multipaint.pde @ 172:e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
This also removes conflict from the keycode defs.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 23 Aug 2018 11:09:20 +0300 |
parents | 1166505afd5f |
children | 3ddf4d799fe6 |
rev | line source |
---|---|
35 | 1 // |
159 | 2 // Multipaint.JS 1.8.2018 |
35 | 3 // Tero Heikkinen (Dr. TerrorZ) |
4 // ProcessingJS port and changes by Matti Hämäläinen (ccr/TNSP) | |
5 // processing setup draw and file things here | |
6 // | |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
7 |
148 | 8 // Supported |
9 final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10, PLUS4 = 9, PLUS4M = 19, CPC = 2; | |
10 | |
11 // Experimental or incomplete | |
12 final int C64NOLIMIT = 32; // Commodore 64 without attribute limitations | |
13 final int C64FLI = 20, C64FLIM = 21; // incomplete FLI & AFLI modes | |
14 final int TIMEX = 7, JR200 = 8, AMIGA = 11, ATARIST = 12; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
15 final int PICO8 = 88; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
16 final int UNIA = 33; |
148 | 17 final int COCO3 = 34; |
18 final int BK0010 = 99; | |
19 final int QLLOW = 66; | |
20 | |
21 // Reserved but completely unimplemented | |
22 final int VIC = 22; // VIC-20 | |
23 final int CGA = 23; // 320 x 200 PC CGA screen with black, white, cyan, magenta | |
24 final int CGAX = 24; // 320 x 200 PC CGA screen with black, yellow, green, red-ish | |
25 final int EGA = 200; // 320 x 200 PC EGA screen, 16 colors of 64 | |
26 final int VGA = 255; // 320 x 200 PC VGA screen, 256 colors of 65536 | |
27 final int NES = 90; // 8-bit NES | |
28 final int SEGAM = 91; // 8-bit Sega Master System | |
29 | |
16
f356d9c176a6
ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
30 final int PEESEE = 0, MACOSX = 1, PSJS = 2; |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
31 final int COMMAND = 157; // Marq's cmd/ctrl solution |
69 | 32 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
33 int machine = -1; // change this to autoselect |
16
f356d9c176a6
ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
34 int platform = PSJS; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
35 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
36 int g_active, g_tooltrigger, g_prevtool; |
93 | 37 int g_rband, g_rbang, g_boxreconstruct, g_charlimit; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
38 int g_animx, g_animy, g_animframes, g_animno, g_animtime, g_animspeed; |
114
019909b7ab6e
Oops, g_dirty should've been boolean all the time.
Matti Hamalainen <ccr@tnsp.org>
parents:
113
diff
changeset
|
39 int g_omag, g_bordh, g_bordv, g_keymacpos; |
136
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
40 int g_wheelup = int(':'), g_wheeldown = int(';'), g_middlebutton = int(','); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
41 |
148 | 42 boolean g_control = false, g_shift = false, g_dirty, g_inhibit_aspect = false; |
69 | 43 |
133
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
44 String g_formatname, g_formatext, |
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
45 filename = "", sfilename = "", |
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
46 g_name, g_exportext = "", |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
47 g_exportname = "", g_keymacro = "", |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
48 g_forcedpalette = ""; |
69 | 49 |
172
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
50 final int GRIDMODE_OLD = 0; |
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
51 final int GRIDMODE_NEW = 1; |
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
52 final int AR_FLAT = 1; |
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
53 final int AR_SQUARE = 0; |
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
54 int g_gridmode = GRIDMODE_OLD; |
133
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
55 int g_pixelw = 1; |
172
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
56 int g_aspect = AR_SQUARE; |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
57 |
133
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
58 int[] g_grids = new int[16]; |
f5c32f6470d0
Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
131
diff
changeset
|
59 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 int[] g_r = new int[266]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
61 int[] g_g = new int[266]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
62 int[] g_b = new int[266]; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
63 int[] g_rgb = new int[266]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
64 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
65 byte[] g_map = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
66 byte[] g_fillmap = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
67 byte[] g_rmap = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
68 byte[] g_icons = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
69 byte[] g_brush = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
70 byte[] g_template = new byte[16384]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
71 byte[] g_redo = new byte[1024]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
72 byte[] g_remdo = new byte[1024]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
73 int[] g_chaup = new int[64]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
74 byte[] g_data = new byte[1024]; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 int[] g_magpix = new int[64]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
76 int[] g_magpiy = new int[64]; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
77 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
78 byte g_realfront, g_realback; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
79 |
69 | 80 |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
81 //dimensions |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 int X, Y, MX, MY; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
83 //generic mouse |
154 | 84 boolean g_klikkeri, g_iconmode = false; |
143 | 85 int g_ofx, g_ofy, g_button, g_realbutton, g_mx, g_my, g_orx, g_ory, g_msx, g_msy; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
86 //rubberband,mouse |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
87 int g_phase, g_rx, g_ry, g_rx2, g_ry2, g_rubbermode; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
88 int g_prex, g_prey, g_storedcoordx, g_storedcoordy; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
89 //window positioning |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
90 int g_windowx, g_windowy, g_maglocx, g_maglocy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
91 int g_hedge, g_vedge, g_uizoom, g_wzoom; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
92 //icons & gui stuff |
154 | 93 int g_iconx, g_icony, g_piconx, g_picony; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
94 int g_gridx, g_gridy, g_spare; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
95 int g_farge, g_backg, g_ofarge, g_repanel, g_msgctr; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
96 //machine related color properties |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 int g_attrimode, g_britemode, g_multic, g_backmode, g_maxcolors, g_hzoomer; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
98 float g_palsteps; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
99 //brush, tool parameters |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
100 int g_bsourcex, g_bsourcey, g_bsourcex2, g_bsourcey2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
101 int g_bsize, g_btype; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
102 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
103 |
83 | 104 void setup() |
105 { | |
148 | 106 //normi |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 g_magpix[0] = 3; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 g_magpix[1] = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 g_magpix[2] = 16; |
148 | 110 g_magpiy[0] = 3; |
111 g_magpiy[1] = 8; | |
112 g_magpiy[2] = 16; | |
113 | |
114 //mini | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 g_magpix[10] = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 g_magpix[11] = 6; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 g_magpix[12] = 16; |
148 | 118 g_magpiy[10] = 2; |
119 g_magpiy[11] = 6; | |
120 g_magpiy[12] = 16; | |
121 | |
122 //maxi | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 g_magpix[20] = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 g_magpix[21] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 g_magpix[22] = 32; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 g_magpiy[20] = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 g_magpiy[21] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
128 g_magpiy[22] = 32; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 |
148 | 130 //FLAT normi |
131 g_magpix[100] = 3; | |
132 g_magpix[101] = 9; | |
133 g_magpix[102] = 12; | |
134 g_magpiy[100] = 2; | |
135 g_magpiy[101] = 6; | |
136 g_magpiy[102] = 8; | |
137 | |
138 //FLAT mini | |
139 g_magpix[110] = 3; | |
140 g_magpix[111] = 9; | |
141 g_magpix[112] = 12; | |
142 g_magpiy[110] = 2; | |
143 g_magpiy[111] = 6; | |
144 g_magpiy[112] = 8; | |
145 | |
146 //FLAT maxi | |
147 g_magpix[120] = 6; | |
148 g_magpix[121] = 12; | |
149 g_magpix[122] = 21; | |
150 g_magpiy[120] = 4; | |
151 g_magpiy[121] = 8; | |
152 g_magpiy[122] = 14; | |
153 | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
154 g_omag = 1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
155 g_bordh = 64; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
156 g_bordv = 32; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
157 |
36 | 158 // Set up UI |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
159 g_uizoom = 2; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
160 g_animspeed = 1; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
161 |
36 | 162 // Get machine from Javascript runner, or default to C64 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
163 if (mpMachine) |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
164 machine = mpMachine; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
165 else |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
166 machine = C64; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
167 |
148 | 168 if (g_inhibit_aspect) |
169 { | |
170 if (machine == QLLOW || machine == BK0010) | |
171 Y = 256; | |
172 } | |
173 | |
174 if (g_uizoom >= 1 && g_uizoom <= 3) | |
175 g_wzoom = g_uizoom + 1; | |
176 | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
177 g_hedge = 32 * g_uizoom; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
178 g_vedge = 32 * g_uizoom; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
179 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
180 g_spare = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
181 g_bsize = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
182 g_btype = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
183 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
184 g_button = LEFT; |
148 | 185 |
186 g_data[int('f')] = 1; // fill on | |
187 g_data[int('g')] = 1; // grid on | |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
188 g_data[int('m')] = 0; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
189 g_data[int('M')] = 0; // mags off |
148 | 190 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
191 g_icons = mpLoadBinaryFile("icons.bin"); |
148 | 192 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
193 set_tool(3); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
194 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
195 g_gridx = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
196 g_gridy = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
197 g_multic = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
198 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
199 |
150 | 200 |
162 | 201 mpSetUIColors(); |
81
7ee5e0c590bd
Clean set_machine() and rename to mpSetupMachine()
Matti Hamalainen <ccr@tnsp.org>
parents:
73
diff
changeset
|
202 mpSetupMachine(machine); |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
203 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
204 if (g_forcedpalette.length() > 3) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
205 mpLoadPalette(g_forcedpalette); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
206 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
207 int truwinsizex = X * g_magpix[magmode()]; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
208 int truwinsizey = Y * g_magpiy[magmode()]; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
209 /* |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
210 if (g_forcex == 0 || g_forcey == 0) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
211 { |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
212 */ |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
213 g_hadjust = 0; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
214 g_vadjust = 0; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
215 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
216 int hsize = truwinsizex + g_hedge + (22) * g_wzoom; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
217 int vsize = truwinsizey + g_vedge + (14) * g_wzoom; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
218 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
219 while (vsize - g_vedge < (12 * 16) * g_wzoom) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
220 vsize += 2; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
221 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
222 while (hsize - g_hedge < (17 * 16) * g_wzoom) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
223 hsize += 2; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
224 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
225 size(hsize, vsize); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
226 /* |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
227 } |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
228 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
229 if (g_forcex > 800 && g_forcey > 600) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
230 size(g_forcex, g_forcey); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
231 */ |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
232 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
233 if (g_inhibit_aspect) |
172
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
234 g_aspect = AR_SQUARE; |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
235 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
236 int paspect = g_wzoom; |
172
e77a726a587e
Rename FLATRATIO/SQUARERATIO and gridmode OLD/NEW constants to something more sane.
Matti Hamalainen <ccr@tnsp.org>
parents:
168
diff
changeset
|
237 if (g_aspect == AR_FLAT) |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
238 { |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
239 if (g_wzoom == 2) paspect = 1; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
240 if (g_wzoom == 3) paspect = 2; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
241 if (g_wzoom == 4) paspect = 3; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
242 } |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
243 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
244 g_windowx = width - (g_hedge) - (truwinsizex); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
245 g_windowx = g_windowx / 2; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
246 g_windowy = height - (g_vedge) - (truwinsizey); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
247 g_windowy = g_windowy / 2; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
248 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
249 if (g_hadjust > 0) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
250 g_windowx = width - (g_hedge) - (g_wzoom * X) - g_hadjust; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
251 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
252 if (g_vadjust > 0) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
253 g_windowy = height - (g_vedge) - (paspect * Y) - g_vadjust; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
254 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
255 switcher(3); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
256 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
257 g_map[4] = byte(g_maxcolors - 1); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
258 g_ofarge = g_farge; |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
259 MX = int(X / 8); |
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
260 MY = int(Y / 8); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
261 g_realfront = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
262 g_realback = byte(g_backg); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
263 |
83 | 264 for (int y = 0; y < Y; y++) |
265 for (int x = 0; x < X; x++) | |
69 | 266 absolute_clearpoint(x, y); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
267 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
268 switcher(2); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
269 noStroke(); |
150 | 270 background(g_r[263], g_g[263], g_b[263]); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
271 sussborder(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
272 setup_raster(); |
83 | 273 |
159 | 274 message(" Multipaint| - 2018 -||v1.8.2018.JS"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
275 message("*"); |
89 | 276 g_dirty = true; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
277 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
278 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
279 |
162 | 280 void mpSetUIColors() |
281 { | |
282 // UI colors | |
283 makecolor(256, 0xff, 0, 0xff); | |
284 makecolor(257, 180, 180, 180); | |
285 // g_rgb[257] = 0xff808080; | |
286 makecolor(258, 0, 0, 0); | |
287 makecolor(259, 48, 48, 48); | |
288 | |
289 // R,G and B for the palette sliders | |
290 makecolor(260, 255, 0, 0); | |
291 makecolor(261, 0, 255, 0); | |
292 makecolor(262, 0, 0, 255); | |
293 makecolor(263, 48, 48, 48); //backest UI background | |
294 | |
295 } | |
296 | |
101
e5c147a7bf98
Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
297 void mpSetTitle(String str) |
e5c147a7bf98
Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents:
97
diff
changeset
|
298 { |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
299 console.log("TITLE: '" + str + "'"); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
300 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
301 |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
302 |
117
44a07b1c620d
Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
303 boolean mpHaveLocalStorage() |
102
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
304 { |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
305 var test = 'mpLSTest'; |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
306 try { |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
307 localStorage.setItem(test, test); |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
308 if (localStorage.getItem(test) == test) |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
309 { |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
310 localStorage.removeItem(test); |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
311 return true; |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
312 } |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
313 } |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
314 catch (e) { |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
315 return false; |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
316 } |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
317 return false; |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
318 } |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
319 |
287892b5eff8
Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
101
diff
changeset
|
320 |
54
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
321 function mpLoadFileSelector(fmtname, fmtexts, fcallback) |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
322 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
323 var mpUI = stGE("mpUI"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
324 if (mpUI) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
325 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
326 stClearChildren(mpUI); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
327 mpUI.style.background = "red"; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
328 mpUI.style.padding = "0.5em"; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
329 |
54
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
330 mobj = stCE("input", "mpFileSelector"); |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
331 mobj.type = "file"; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
332 mobj.name = "name"; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
333 mobj.multiple = false; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
334 |
54
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
335 if (fmtexts != null) |
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
336 mobj.accept = fmtexts; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
337 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
338 stAddEventOb(mobj.name, mobj, "change", |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
339 function(evt) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
340 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
341 var files = evt.target.files; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
342 if (files.length > 0) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
343 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
344 var freader = new FileReader(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
345 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
346 freader.onloadend = (function(theFile) { |
58
8c47708f0196
Oops, forgot to commit this.
Matti Hamalainen <ccr@tnsp.org>
parents:
56
diff
changeset
|
347 fcallback(theFile, new Uint8Array(freader.result)); |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
348 }); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
349 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
350 freader.readAsArrayBuffer(files[0]); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
351 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
352 stClearChildren(mpUI); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
353 mpUI.style.background = null; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
354 }); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
355 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
356 mpUI.appendChild(mobj); |
54
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
357 |
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
358 mobj = stCE("span", "mpFileInfo"); |
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
359 mobj.innerHTML = "Load / import an '<b>"+ fmtname +"</b>' file."; |
dee55b8f97a6
Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents:
53
diff
changeset
|
360 mpUI.appendChild(mobj); |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
361 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
362 else |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
363 return null; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
364 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
365 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
366 |
52 | 367 // |
368 // Basically the same as Processing loadBytes(), but it seems | |
369 // that Processing.JS's loadBytes() is broken at least in v1.4.8 | |
370 // and does not return byte-clean data. So roll a replacement of | |
371 // our own design. --ccr | |
372 // | |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
373 byte[] mpLoadBinaryFile(String url) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
374 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
375 var xhr = new XMLHttpRequest(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
376 xhr.open("GET", url, false); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
377 xhr.overrideMimeType("text/plain; charset=x-user-defined"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
378 xhr.setRequestHeader("If-Modified-Since", "Fri, 01 Jan 1960 00:00:00 GMT"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
379 xhr.send(null); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
380 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
381 if (xhr.status !== 200 && xhr.status !== 0) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
382 return null; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
383 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
384 var string = xhr.responseText; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
385 byte[] ret = new byte[string.length]; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
386 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
387 for (var i = 0; i < string.length; i++) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
388 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
389 ret[i] = string.charCodeAt(i) & 0xff; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
390 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
391 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
392 return ret; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
393 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
394 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
395 |
103
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
396 Blob mpMakeBinaryBlob(byte[] data) |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
397 { |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
398 var blob = null; |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
399 if (data == null) |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
400 return null; |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
401 |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
402 if (typeof(data) == "string") |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
403 blob = new Blob([data], {type: "application/octet-stream"}); |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
404 else |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
405 if (typeof(data) == "object") |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
406 blob = new Blob([new Uint8Array(data)], {type: "application/octet-stream"}); |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
407 |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
408 return blob; |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
409 } |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
410 |
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
411 |
52 | 412 // |
413 // "Save" a byte array to file. Basically creates a blob URI | |
414 // and dumps it in the DOM, giving user a download. | |
415 // | |
117
44a07b1c620d
Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
416 boolean mpSaveBinaryFile(String name, byte[] data) |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
417 { |
103
7a889d59b405
Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents:
102
diff
changeset
|
418 var blob = mpMakeBinaryBlob(data); |
96
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
419 if (blob == null) |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
420 { |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
421 console.log("Could not create BLOB from data."); |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
422 return false; |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
423 } |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
424 |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
425 var url = window.URL.createObjectURL(blob); |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
426 if (url == null) |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
427 { |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
428 console.log("Could not create URL from BLOB object."); |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
429 return false; |
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
430 } |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
431 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
432 var alink = stCE("a"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
433 var mpUI = stGE("mpUI"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
434 stClearChildren(mpUI); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
435 mpUI.appendChild(alink); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
436 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
437 alink.style = "display: none"; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
438 alink.href = url; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
439 alink.download = name; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
440 alink.click(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
441 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
442 window.URL.revokeObjectURL(url); |
96
2d4b56e4d966
Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents:
94
diff
changeset
|
443 return true; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
444 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
445 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
446 |
117
44a07b1c620d
Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
447 void mpSavePNGImage(String name, int fmt, boolean border) |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
448 { |
94
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
449 PImage simg = mpRenderImage(border); |
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
450 // if (g_data[int('Q')] == 0) |
88
03823fa2cb01
Refactor export_image() and export_image_sans_border() to use common code,
Matti Hamalainen <ccr@tnsp.org>
parents:
84
diff
changeset
|
451 |
94
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
452 if (simg !== null) |
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
453 { |
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
454 // XXX TODO .. actually save the image, something like .. |
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
455 //simg.canvas.toBlob(function(idata){ mpSaveBinaryFile(name, idata); }, "image/png", 0.95); |
6e74d45ea620
More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents:
93
diff
changeset
|
456 } |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
457 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
458 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
459 |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
460 int mpLoadPNGImage(String name) |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
461 { |
92
4161d798cb64
Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
462 PImage simg = null; |
4161d798cb64
Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
463 if (simg == null) |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
464 return -1; |
92
4161d798cb64
Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
465 |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
466 int lefth = g_farge; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
467 int righth = g_backg; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
468 storeparameters(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
469 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
470 g_data[int('d')] = 0; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
471 g_data[int('t')] = 0; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
472 g_data[int('b')] = 1; //old IQ |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
473 |
92
4161d798cb64
Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents:
90
diff
changeset
|
474 if (!mpImportFromImage(simg)) |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
475 return -2; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
476 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
477 restoreparameters(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
478 refreshpalette(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
479 refresh(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
480 g_boxreconstruct = 2; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
481 selectcolor(0, lefth); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
482 selectcolor(1, righth); |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
483 return 0; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
484 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
485 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
486 |
104
73a8773466ae
Change mpSaveNativeImage() to mpGetNativeImage().
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
487 byte[] mpGetNativeImage() |
53 | 488 { |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
489 //save the picture page g_map[], make sure some essential parameters are correct |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
490 g_map[3] = byte(machine); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
491 g_map[5] = byte(MX); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
492 g_map[7] = byte(MY); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
493 |
104
73a8773466ae
Change mpSaveNativeImage() to mpGetNativeImage().
Matti Hamalainen <ccr@tnsp.org>
parents:
103
diff
changeset
|
494 return g_map; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
495 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
496 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
497 |
117
44a07b1c620d
Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
498 int mpSetNativeImage(byte[] data, boolean noError) |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
499 { |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
500 if (data == null) |
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
501 return -1; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
502 |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
503 if (data[3] != machine && !noError) |
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
504 return -2; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
505 |
111
044e3371d44b
Do store_undo() in mpSetNativeImage() when supposedly successfully loading
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
506 store_undo(); |
044e3371d44b
Do store_undo() in mpSetNativeImage() when supposedly successfully loading
Matti Hamalainen <ccr@tnsp.org>
parents:
110
diff
changeset
|
507 |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
508 g_map = data; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
509 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
510 refreshpalette(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
511 consistency(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
512 g_farge = int(g_realfront); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
513 g_ofarge = g_farge; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
514 g_backg = int(g_realback); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
515 sussborder(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
516 |
97
65e6cacd068c
Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
96
diff
changeset
|
517 return 0; |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
518 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
519 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
520 |
117
44a07b1c620d
Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents:
114
diff
changeset
|
521 int mpLoadNativeImage(String name, boolean noError) |
55 | 522 { |
523 return mpSetNativeImage( | |
524 mpLoadBinaryFile(name), noError); | |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
525 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
526 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
527 |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
528 boolean mpLoadPalette(String fname) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
529 { |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
530 if (g_map[13] != C64) |
162 | 531 { |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
532 return false; |
162 | 533 } |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
534 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
535 byte fdata[] = mpLoadbinaryFile(fname); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
536 if (fdata == null || |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
537 fdata.length != 772 || |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
538 fdata[0x301] != byte(0x10) || |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
539 fdata[0x302] != byte(0xff) || |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
540 fdata[0x303] != byte(0xff)) |
162 | 541 { |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
542 return false; |
162 | 543 } |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
544 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
545 for (int n = 0; n < 16; n++) |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
546 { |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
547 makecolor(n, |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
548 int(fdata[n * 3]), |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
549 int(fdata[n * 3 + 1]), |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
550 int(fdata[n * 3 + 2])); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
551 } |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
552 |
162 | 553 mpSetUIColors(); |
153
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
554 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
555 sussborder(); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
556 refresh_all(); |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
557 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
558 return true; |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
559 } |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
560 |
9f4e6f888120
Integrate more changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
150
diff
changeset
|
561 |
69 | 562 void draw() |
563 { | |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
564 if (!focused) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
565 { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
566 g_control = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
567 g_shift = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
568 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
569 |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
570 // If there should be no update, do not update. |
73
d2a89e88f958
When in rubberband mode, do not delay screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents:
72
diff
changeset
|
571 if (!g_dirty && !g_rubbermode) |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
572 return; |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
573 g_dirty = false; |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
574 |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
69
diff
changeset
|
575 // Animate animbrush |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
576 if (g_data[int('n')] == 1) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
577 { |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
578 if (++g_animtime > 8 - g_animspeed * 2) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
579 { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
580 animbrush_do(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
581 g_animtime = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
582 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
583 } |
9
dfdc18b62fab
Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
584 |
40 | 585 // Update some mouse variables |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
586 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
587 { |
39 | 588 g_mx = g_msx - g_windowx; |
589 g_my = g_msy - g_windowy; | |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
590 } |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
591 else |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
592 { |
39 | 593 g_mx = mouseX; |
594 g_my = mouseY; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
595 } |
11 | 596 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
597 g_msx = mouseX; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
598 g_msy = mouseY; |
39 | 599 |
40 | 600 // Actual tool drawing |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
601 if (g_tooltrigger == 1 && |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
602 g_mx <= width - g_hedge && |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
603 g_my <= height - g_vedge) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
604 do_tool(g_mx, g_my, g_button); |
39 | 605 |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
606 switcher(0); |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
607 |
142 | 608 for (int i = 0; i < 1024; i++) |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
609 g_remdo[i] = 0; |
39 | 610 |
40 | 611 // Tool drawing for shows |
135 | 612 int savebut = g_button; |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
613 if (tool() != 5) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
614 { |
40 | 615 if (g_phase == 0) |
616 g_button = LEFT; | |
39 | 617 do_tool(g_mx, g_my, LEFT); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
618 } |
148 | 619 else |
620 storecoords(g_mx, g_my); | |
621 | |
150 | 622 if (tool() == 6) do_line(g_rx, g_ry, g_rx2, g_ry2, 0); |
623 if (tool() == 7) do_circle(g_rx, g_ry, g_rx2, g_ry2); | |
624 if (tool() == 8) do_rectangle(g_rx, g_ry, g_rx2, g_ry2); | |
135 | 625 g_button = savebut; |
39 | 626 |
40 | 627 // Screen update stuff |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
628 loadPixels(); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
629 viewport(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
630 switcher(1); |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
631 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
632 if (g_pgrab) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
633 preview_box_drag(); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
634 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
635 preview_window(); |
136
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
636 update_ui(false); |
40 | 637 updatePixels(); |
11 | 638 |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
639 // Message control |
40 | 640 if (g_msgctr > 0) |
641 g_msgctr--; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
642 |
113
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
643 // Macro handling |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
644 if (g_keymacro.length() > g_keymacpos) |
f87c6577e696
Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
645 { |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
646 macro_command(g_keymacro.charAt(g_keymacpos)); |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
647 g_keymacpos++; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
648 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
649 } |