Mercurial > hg > forks > multipaint-js
annotate multipaint.pde @ 36:a39b3c9e5c3b
Add some comments.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 04 Jul 2018 10:50:42 +0300 |
parents | eb9157c6a067 |
children | 5e0306ac3575 |
rev | line source |
---|---|
35 | 1 // |
2 // Multipaint Metal Edition 22.5.2017 | |
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 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
8 PrintWriter exwriter; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
9 final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10, PLUS4 = 9, PLUS4M = 19, CPC = 2; // supported |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
10 final int TIMEX = 7, JR200 = 8, AMIGA = 11; // experimental or incomplete |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
11 final int C64FLI = 20, C64FLIM = 21; // experimental |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
12 final int PICO8 = 88; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
13 final int FAKEX = 32; // Commodore 64 without attribute limitations |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
14 final int UNIA = 33; |
16
f356d9c176a6
ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents:
15
diff
changeset
|
15 final int PEESEE = 0, MACOSX = 1, PSJS = 2; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
16 //-1 & -1 for normal operation |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
17 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
|
18 int platform = PSJS; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
19 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
20 final int COMMAND = 157; // Marq's cmd/ctrl solution |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
21 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
22 int g_active, g_tooltrigger, g_prevtool; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
23 int g_rband, g_rbang, g_boxreconstruct, g_sorsaa, g_charlimit; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
24 int g_animx, g_animy, g_animframes, g_animno, g_animtime, g_animspeed; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
25 int g_omag, g_bordh, g_bordv, g_keymacpos, g_framec; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
26 |
17
480ada584d8a
Remove the use of 'gui' variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
16
diff
changeset
|
27 boolean fileselect = false, saveas = false, refselect = false, g_control = false, g_shift = false, exporttxt = false, importfmt = false, exportemu = false, exportfmt = false; |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
28 String path = "", refpath = "", filename = "", elename = "", sfilename = "", refname = "", g_expname = ""; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
29 String g_keymacro = ""; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
30 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
31 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
|
32 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
|
33 int[] g_b = new int[266]; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
34 int[] g_rgb = new int[266]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
35 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
36 byte[] g_map = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
37 byte[] g_fillmap = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
38 byte[] g_sparepage = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
39 byte[] g_swappage = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
40 byte[] g_rmap = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
41 byte[] g_icons = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
42 byte[] g_brush = new byte[88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
43 byte[][] g_undob = new byte[11][88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
44 byte[][] g_undobs = new byte[11][88000]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
45 byte[] g_template = new byte[16384]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
46 byte[] g_redo = new byte[1024]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
47 byte[] g_remdo = new byte[1024]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
48 int[] g_chaup = new int[64]; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
49 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
|
50 int[] g_uindex = new int[8]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
51 int[] g_ubottom = new int[8]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 int[] g_utop = new int[8]; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 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
|
54 int[] g_magpiy = new int[64]; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
55 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
56 byte g_realfront, g_realback; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
57 PImage output, outputsans; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
58 String g_name; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
59 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
60 //dimensions |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
61 int X, Y, MX, MY; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
62 //generic mouse |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
63 int g_ofx, g_ofy, g_button, g_realbutton, g_klikkeri, 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
|
64 //rubberband,mouse |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
65 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
|
66 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
|
67 //window positioning |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
68 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
|
69 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
|
70 //icons & gui stuff |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 int g_iconx, g_icony, g_piconx, g_picony, g_iconmode; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
72 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
|
73 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
|
74 //machine related color properties |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 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
|
76 float g_palsteps; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
77 //brush, tool parameters |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
78 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
|
79 int g_bsize, g_btype; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
80 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
81 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
82 void setup() { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
83 int i, x, y; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
84 |
22
a8e56d4f947b
Attempt to limit CPU usage by using frameRate().
Matti Hamalainen <ccr@tnsp.org>
parents:
21
diff
changeset
|
85 frameRate(40); |
31
3723a6fc767d
Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
86 |
3723a6fc767d
Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
87 for (i = 0; i < g_data.length; i++) |
3723a6fc767d
Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
88 g_data[i] = 0; |
3723a6fc767d
Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents:
30
diff
changeset
|
89 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
90 g_magpix[0] = 3; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
91 g_magpix[1] = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
92 g_magpix[2] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
93 g_magpix[10] = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
94 g_magpix[11] = 6; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
95 g_magpix[12] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
96 g_magpix[20] = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
97 g_magpix[21] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
98 g_magpix[22] = 32; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
99 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
100 g_magpiy[0] = 3; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
101 g_magpiy[1] = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
102 g_magpiy[2] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 g_magpiy[10] = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
104 g_magpiy[11] = 6; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
105 g_magpiy[12] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
106 g_magpiy[20] = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
107 g_magpiy[21] = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
108 g_magpiy[22] = 32; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
109 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
110 g_omag = 1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
111 g_bordh = 64; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
112 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
|
113 |
36 | 114 // 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
|
115 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
|
116 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
|
117 |
36 | 118 // 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
|
119 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
|
120 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
|
121 else |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
24
diff
changeset
|
122 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
|
123 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 switch (g_uizoom) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
125 case 1: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
126 g_wzoom = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
127 size(700, 468); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
128 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
129 case 2: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
130 g_wzoom = 3; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
131 size(1058, 708); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
132 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
133 case 3: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
134 g_wzoom = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
135 size(1460, 950); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
136 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
137 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
138 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
139 g_hedge = 32 * g_uizoom; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
140 g_vedge = 32 * g_uizoom; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
141 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
142 g_uindex[0] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
143 g_utop[0] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
144 g_ubottom[0] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
145 g_uindex[1] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
146 g_utop[1] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
147 g_ubottom[1] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
148 g_spare = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
149 g_bsize = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
150 g_btype = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
151 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
152 g_button = LEFT; |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
153 g_data[int('f')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
154 g_data[int('g')] = 1; |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
155 g_icons = mpLoadBinaryFile("icons.bin"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
156 set_tool(3); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
157 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
158 g_gridx = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
159 g_gridy = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
160 g_multic = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
161 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
162 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
163 //UI colors |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
164 makecolor(256, 0xff, 0, 0xff); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
165 makecolor(257, 180, 180, 180); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
166 g_rgb[257] = 0xff808080; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
167 makecolor(258, 0, 0, 0); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
168 makecolor(259, 48, 48, 48); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
169 //R,G,B |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
170 makecolor(260, 255, 0, 0); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
171 makecolor(261, 0, 255, 0); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
172 makecolor(262, 0, 0, 255); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
173 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
174 set_machine(machine); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
175 g_windowx = width - (g_hedge) - (g_wzoom * X); |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
176 g_windowx = int(g_windowx / 2); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
177 g_windowy = height - (g_vedge) - (g_wzoom * Y); |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
178 g_windowy = int(g_windowy / 2); |
2
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 switcher(3); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
181 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
182 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
|
183 g_ofarge = g_farge; |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
184 MX = int(X / 8); |
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
185 MY = int(Y / 8); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
186 g_realfront = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
187 g_realback = byte(g_backg); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
188 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
189 output = createImage(X * g_omag + g_bordh * g_omag, Y * g_omag + g_bordv * g_omag, RGB); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
190 outputsans = createImage(X * g_omag, Y * g_omag, RGB); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
191 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
192 for (y = 0; y < Y; y++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
193 for (x = 0; x < X; x++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
194 absolute_clearpoint(x, y); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
195 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
196 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
197 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
198 switcher(2); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
199 noStroke(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
200 background(g_r[259], g_g[259], g_b[259]); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
201 sussborder(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
202 setup_raster(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
203 message("Multipaint|Metal|v22.5.2017"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
204 message("*"); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
205 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
206 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
207 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
208 void mpSetTitle(String str) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
209 console.log("TITLE: '" + str + "'"); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
210 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
211 |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
212 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
213 boolean fexists(String fname) { |
27
f9bffb2fbb2c
Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
214 // File f = new File(fname); |
f9bffb2fbb2c
Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
215 // if (f.exists())return true; |
f9bffb2fbb2c
Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents:
25
diff
changeset
|
216 return true; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
217 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
218 |
28
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
219 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
220 function mpLoadFileSelector(ftypes, callback) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
221 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
222 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
|
223 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
|
224 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
225 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
|
226 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
|
227 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
|
228 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
229 var mobj = stCE("input", "mpFileSelector"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
230 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
|
231 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
|
232 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
|
233 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
234 if (ftypes != null) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
235 mobj.accept = ftypes; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
236 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
237 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
|
238 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
|
239 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
240 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
|
241 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
|
242 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
243 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
|
244 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
245 freader.onloadend = (function(theFile) { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
246 callback(theFile, new Uint8Array(freader.result)); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
247 }); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
248 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
249 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
|
250 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
251 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
|
252 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
|
253 }); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
254 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
255 mpUI.appendChild(mobj); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
256 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
257 else |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
258 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
|
259 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
260 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
261 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
262 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
|
263 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
264 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
|
265 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
|
266 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
|
267 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
|
268 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
|
269 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
270 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
|
271 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
|
272 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
273 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
|
274 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
|
275 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
276 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
|
277 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
278 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
|
279 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
280 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
281 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
|
282 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
283 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
284 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
285 void mpSaveBinaryFile(String name, byte[] data) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
286 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
287 var blob = new Blob([new Uint8Array(data)], {type: "application/octet-stream"}), |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
288 url = window.URL.createObjectURL(blob); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
289 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
290 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
|
291 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
|
292 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
|
293 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
|
294 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
295 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
|
296 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
|
297 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
|
298 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
|
299 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
300 window.URL.revokeObjectURL(url); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
301 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
302 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
303 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
304 void mpSavePNGImage(String name) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
305 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
306 if (g_data[int('Q')] == 0) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
307 export_image_sans_border(name); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
308 else |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
309 export_image(name); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
310 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
311 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
312 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
313 void mpLoadPNGImage(String name) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
314 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
315 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
|
316 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
|
317 storeparameters(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
318 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
319 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
|
320 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
|
321 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
|
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 import_image(name); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
324 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
325 restoreparameters(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
326 refreshpalette(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
327 refresh(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
328 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
|
329 message("Image|loaded"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
330 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
|
331 selectcolor(1, righth); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
332 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
333 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
334 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
335 void mpSaveNativeImage(String name) { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
336 //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
|
337 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
|
338 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
|
339 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
|
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 mpSaveBinaryFile(name, g_map); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
342 } |
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 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
345 void mpSetNativeImage(byte[] data, bool noError) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
346 { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
347 if (data == null) { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
348 message("NO FILE"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
349 return false; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
350 } |
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 if (data[3] != machine && !noError) { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
353 message("Wrong|machine!"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
354 return false; |
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 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
357 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
|
358 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
359 refreshpalette(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
360 consistency(); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
361 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
|
362 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
|
363 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
|
364 sussborder(); |
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 return true; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
367 } |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
368 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
369 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
370 bool mpLoadNativeImage(String name, bool noError) { |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
371 //load the picture page g_map[] with parameters |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
372 byte[] data = mpLoadBinaryFile(name); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
373 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
374 if (!mpSetNativeImage(data, noError)) |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
375 return false; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
376 |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
377 message("Page|loaded"); |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
378 return true; |
edcf9039552b
Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents:
27
diff
changeset
|
379 } |
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 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
382 void draw() { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
383 int msx, msy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
384 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
385 if (!focused) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
386 g_control = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
387 g_shift = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
388 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
389 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
390 if (g_data[int('n')] == 1) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
391 g_animtime++; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
392 if (g_animtime > 8 - g_animspeed * 2) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
393 animbrush_do(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
394 g_animtime = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
395 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
396 } |
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
|
397 |
dfdc18b62fab
Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
398 if (moicon(16 * 16 * g_uizoom, height - 32 * g_uizoom, 16 * g_uizoom, 24 * g_uizoom)) help(int('<')); |
dfdc18b62fab
Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents:
7
diff
changeset
|
399 if (moicon(16 * 16 * g_uizoom, height - 8 * g_uizoom, 16 * g_uizoom, 8 * g_uizoom)) help(int('>')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
400 if (moicon(0, height - 32 * g_uizoom, 15 * 16 * g_uizoom, 32 * g_uizoom)) help(TAB); |
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
|
401 if (moicon(width - 32 * g_uizoom, 0, 32 * g_uizoom, 16 * g_uizoom)) help(int('.')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
402 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
403 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
404 msx = mouseX - g_windowx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
405 msy = mouseY - g_windowy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
406 msx = g_msx - g_windowx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
407 msy = g_msy - g_windowy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
408 } else { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
409 msx = mouseX; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
410 msy = mouseY; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
411 //msx=g_msx;msy=g_msy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
412 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
413 g_mx = msx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
414 g_my = msy; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
415 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
416 //actual tool drawing |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
417 if (g_tooltrigger == 1) { // comes from mousepressed, or mousedragged |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
418 if (g_mx <= width - g_hedge && g_my <= height - g_vedge) do_tool(msx, msy, g_button); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
419 } |
11 | 420 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
421 g_msx = mouseX; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
422 g_msy = mouseY; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
423 switcher(0); |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
424 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
425 for (int i = 0; i < 1024; i++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
426 g_remdo[i] = 0; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
427 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
428 int lipo = g_button; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
429 //tool drawing for shows |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
430 if (tool() != 5) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
431 if (g_phase == 0) g_button = LEFT; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
432 do_tool(msx, msy, LEFT); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
433 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
434 if (tool() == 6) doline(g_rx, g_ry, g_rx2, g_ry2, 0); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
435 if (tool() == 7) docircle(g_rx, g_ry, g_rx2, g_ry2); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
436 if (tool() == 8) rectangle(g_rx, g_ry, g_rx2, g_ry2); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
437 g_button = lipo; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
438 loadPixels(); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
439 viewport(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
440 //magport(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
441 switcher(1); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
442 update_ui(); |
11 | 443 |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
444 updatePixels(); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
445 if (g_msgctr > 0) g_msgctr--; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
446 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
447 // UI file operations |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
448 if (fileselect) // Fileselect "event" for Load |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
449 { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
450 mpLoadFileSelector(".mpe, .MPE", |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
451 function (fh, fdata) |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
452 { |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
453 if (mpSetNativeImage(fdata)) |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
454 { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
455 store_undo(); |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
456 mpSetTitle(fh.name); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
457 if (g_spare == 0) |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
458 filename = fh.name; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
459 else |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
460 sfilename = fh.name; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
461 |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
462 refresh(); |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
463 } |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
464 }); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
465 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
466 fileselect = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
467 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
468 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
469 } |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
470 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
471 if (saveas) // Fileselect "event" for Save as |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
472 { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
473 String s = fileselector(path, SAVEIMG); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
474 String orig = ""; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
475 int kuva = 0; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
476 if (g_spare == 0) orig = filename; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
477 if (g_spare == 1) orig = sfilename; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
478 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
479 if (s != null) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
480 // Add extension if needed |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
481 if (s.length() <= 2) s += ".bin"; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
482 s = s + ".dummy.dummy"; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
483 String[] l = split(s, '.'); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
484 String[] m1 = match(l[1], "png"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
485 String[] m2 = match(l[1], "PNG"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
486 String[] m3 = match(l[1], "bin"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
487 String[] m4 = match(l[1], "BIN"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
488 if (m1 != null || m2 != null) kuva = 1; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
489 if (m1 == null && m2 == null && m3 == null && m4 == null) l[1] = "bin"; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
490 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
491 if (g_spare == 0) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
492 filename = l[0] + "." + l[1]; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
493 mpSavePNGImage(filename); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
494 if (kuva == 1) filename = orig; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
495 mpSetTitle(filename); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
496 } else { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
497 sfilename = l[0] + "." + l[1]; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
498 mpSavePNGImage(sfilename); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
499 if (kuva == 1) sfilename = orig; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
500 mpSetTitle(sfilename); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
501 } |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
502 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
503 message("SAVED"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
504 if (kuva == 1) message("EXPORTED|PNG"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
505 } |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
506 saveas = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
507 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
508 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
509 } |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
510 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
511 if (exporttxt) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
512 if (g_spare == 0) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
513 exportemuname = filename + "." + l[1]; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
514 } else { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
515 exportemuname = sfilename + "." + l[1]; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
516 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
517 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
518 machine_export(exportemuname, 1); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
519 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
520 exporttxt = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
521 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
522 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
523 } |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
524 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
525 if (exportemu) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
526 if (g_spare == 0) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
527 exportemuname = filename + "." + l[1]; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
528 } else { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
529 exportemuname = sfilename + "." + l[1]; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
530 } |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
531 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
532 machine_export(exportemuname, 0); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
533 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
534 exportemu = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
535 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
536 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
537 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
538 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
539 if (importfmt) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
540 mpLoadFileSelector(".aas, .AAS", |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
541 function (fh, fdata) |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
542 { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
543 store_undo(); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
544 filename = fh.name; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
545 format_import(fdata); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
546 refresh(); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
547 }); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
548 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
549 importfmt = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
550 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
551 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
552 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
553 |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
554 if (exportfmt) { |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
555 format_export(filename +"_"+ (g_spare ? "spare" : "main") +".aas"); |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
556 |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
557 exportfmt = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
558 g_shift = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
559 g_control = false; |
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
28
diff
changeset
|
560 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
561 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
562 //if(g_framec==1){saveFrame("frames/out-######.png");} |
23 | 563 //g_framec++;if(g_framec>1)g_framec=0; |
564 | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
565 if (g_keymacro.length() > g_keymacpos) { |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
566 macro_command(g_keymacro.charAt(g_keymacpos)); |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
567 g_keymacpos++; |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
568 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
569 } |