annotate multipaint.pde @ 56:4eb9ebde8c20

Some more interface cleanupping.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 04 Jul 2018 20:44:56 +0300
parents 7194cdcc9dab
children 8c47708f0196
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
1 //
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
2 // Multipaint Metal Edition 22.5.2017
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
3 // Tero Heikkinen (Dr. TerrorZ)
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
4 // ProcessingJS port and changes by Matti Hämäläinen (ccr/TNSP)
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
5 // processing setup draw and file things here
eb9157c6a067 Update author blurb.
Matti Hamalainen <ccr@tnsp.org>
parents: 31
diff changeset
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;
51
f9da5fe9a891 Define g_exportname for name of the format that the export is done in.
Matti Hamalainen <ccr@tnsp.org>
parents: 50
diff changeset
28 String path = "", refpath = "", filename = "", elename = "", sfilename = "", refname = "", g_exportext = "", g_exportname = "", g_keymacro = "";
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
29
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
30 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
31 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
32 int[] g_b = new int[266];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
33 int[] g_rgb = new int[266];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
34
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
35 byte[] g_map = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
36 byte[] g_fillmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
37 byte[] g_sparepage = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
38 byte[] g_swappage = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
39 byte[] g_rmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
40 byte[] g_icons = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
41 byte[] g_brush = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
42 byte[][] g_undob = new byte[11][88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
43 byte[][] g_undobs = new byte[11][88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
44 byte[] g_template = new byte[16384];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
45 byte[] g_redo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
46 byte[] g_remdo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
47 int[] g_chaup = new int[64];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
48 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
49 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
50 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
51 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
52 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
53 int[] g_magpiy = new int[64];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
54
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
55 byte g_realfront, g_realback;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
56 PImage output, outputsans;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
57 String g_name;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
58
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
59 //dimensions
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
60 int X, Y, MX, MY;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
61 //generic mouse
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
62 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
63 //rubberband,mouse
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
64 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
65 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
66 //window positioning
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
67 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
68 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
69 //icons & gui stuff
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
70 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
71 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
72 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
73 //machine related color properties
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
74 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
75 float g_palsteps;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
76 //brush, tool parameters
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
77 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
78 int g_bsize, g_btype;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
79
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
80
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
81 void setup() {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
82 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
83
22
a8e56d4f947b Attempt to limit CPU usage by using frameRate().
Matti Hamalainen <ccr@tnsp.org>
parents: 21
diff changeset
84 frameRate(40);
31
3723a6fc767d Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
85
3723a6fc767d Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
86 for (i = 0; i < g_data.length; i++)
3723a6fc767d Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
87 g_data[i] = 0;
3723a6fc767d Initialize g_data, to be sure ..
Matti Hamalainen <ccr@tnsp.org>
parents: 30
diff changeset
88
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 g_magpix[0] = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
90 g_magpix[1] = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
91 g_magpix[2] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
92 g_magpix[10] = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 g_magpix[11] = 6;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
94 g_magpix[12] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
95 g_magpix[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
96 g_magpix[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
97 g_magpix[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
98
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
99 g_magpiy[0] = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
100 g_magpiy[1] = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
101 g_magpiy[2] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
102 g_magpiy[10] = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 g_magpiy[11] = 6;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 g_magpiy[12] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 g_magpiy[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
106 g_magpiy[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
107 g_magpiy[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
108
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
109 g_omag = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
110 g_bordh = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 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
112
36
a39b3c9e5c3b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
113 // 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
114 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
115 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
116
36
a39b3c9e5c3b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
117 // 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
118 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
119 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
120 else
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
121 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
122
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
123 switch (g_uizoom) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
124 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
125 g_wzoom = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
126 size(700, 468);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
127 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
128 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
129 g_wzoom = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
130 size(1058, 708);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
131 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
132 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
133 g_wzoom = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
134 size(1460, 950);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
135 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
136 }
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 g_hedge = 32 * g_uizoom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
139 g_vedge = 32 * g_uizoom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
140
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
141 g_uindex[0] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
142 g_utop[0] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
143 g_ubottom[0] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
144 g_uindex[1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
145 g_utop[1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
146 g_ubottom[1] = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
147 g_spare = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
148 g_bsize = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
149 g_btype = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
150 g_phase = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
151 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
152 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
153 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
154 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
155 set_tool(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
156
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
157 g_gridx = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
158 g_gridy = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
159 g_multic = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
160 g_repanel = -2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
161
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
162 //UI colors
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
163 makecolor(256, 0xff, 0, 0xff);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
164 makecolor(257, 180, 180, 180);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
165 g_rgb[257] = 0xff808080;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166 makecolor(258, 0, 0, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167 makecolor(259, 48, 48, 48);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
168 //R,G,B
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
169 makecolor(260, 255, 0, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
170 makecolor(261, 0, 255, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171 makecolor(262, 0, 0, 255);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
172
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
173 set_machine(machine);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
174 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
175 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
176 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
177 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
178
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
179 switcher(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
180
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
181 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
182 g_ofarge = g_farge;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
183 MX = int(X / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
184 MY = int(Y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
185 g_realfront = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
186 g_realback = byte(g_backg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
187
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
188 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
189 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
190
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
191 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
192 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
193 absolute_clearpoint(x, y);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
194 }
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
195 }
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 switcher(2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
198 noStroke();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
199 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
200 sussborder();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
201 setup_raster();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
202 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
203 message("*");
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
204 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
205
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
206
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
207 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
208 console.log("TITLE: '" + str + "'");
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
209 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
210
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
211
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
212 boolean fexists(String fname) {
27
f9bffb2fbb2c Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
213 // File f = new File(fname);
f9bffb2fbb2c Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
214 // if (f.exists())return true;
f9bffb2fbb2c Make fexists() return always true.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
215 return true;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
216 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
217
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
218
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
219 function mpLoadFileSelector(fmtname, fmtexts, fcallback)
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
220 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
221 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
222 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
223 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
224 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
225 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
226 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
227
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
228 mobj = stCE("input", "mpFileSelector");
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
229 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
230 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
231 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
232
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
233 if (fmtexts != null)
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
234 mobj.accept = fmtexts;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
235
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
236 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
237 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
238 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
239 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
240 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
241 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
242 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
243
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
244 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
245 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
246 });
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 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
249 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
250 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
251 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
252 });
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 mpUI.appendChild(mobj);
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
255
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
256 mobj = stCE("span", "mpFileInfo");
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
257 mobj.innerHTML = "Load / import an '<b>"+ fmtname +"</b>' file.";
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
258 mpUI.appendChild(mobj);
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
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 else
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
261 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
262 }
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
52
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
265 //
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
266 // Basically the same as Processing loadBytes(), but it seems
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
267 // that Processing.JS's loadBytes() is broken at least in v1.4.8
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
268 // and does not return byte-clean data. So roll a replacement of
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
269 // our own design. --ccr
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
270 //
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
271 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
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 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
274 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
275 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
276 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
277 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
278
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
279 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
280 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
281
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
282 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
283 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
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 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
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 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
288 }
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 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
291 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
292
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
293
52
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
294 //
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
295 // "Save" a byte array to file. Basically creates a blob URI
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
296 // and dumps it in the DOM, giving user a download.
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
297 //
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
298 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
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 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
301 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
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 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
304 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
305 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
306 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
307
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
308 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
309 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
310 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
311 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
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 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
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
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
316
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
317 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
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 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
320 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
321 else
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
322 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
323 }
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
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
326 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
327 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
328 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
329 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
330 storeparameters();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
331
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
332 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
333 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
334 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
335
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
336 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
337
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
338 restoreparameters();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
339 refreshpalette();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
340 refresh();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
341 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
342 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
343 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
344 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
345 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
346
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
347
53
c551029a7086 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
348 void mpSaveNativeImage(String name)
c551029a7086 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
349 {
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
350 //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
351 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
352 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
353 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
354
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
355 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
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
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 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
360 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
361 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
362 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
363 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
364 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
365
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
366 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
367 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
368 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
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
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
371 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
372
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
373 refreshpalette();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
374 consistency();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
375 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
376 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
377 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
378 sussborder();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
379
55
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
380 message("Page|loaded");
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
381
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
382 return true;
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
383 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
384
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
385
55
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
386 bool mpLoadNativeImage(String name, bool noError)
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
387 {
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
388 return mpSetNativeImage(
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
389 mpLoadBinaryFile(name), noError);
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
390 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
391
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
392
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
393 void draw() {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
394 if (!focused) {
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
395 g_control = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
396 g_shift = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
397 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
398
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
399 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
400 g_animtime++;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
401 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
402 animbrush_do();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
403 g_animtime = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
404 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
405 }
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
406
dfdc18b62fab Change the help() function and its usage to have more than one parameter to
Matti Hamalainen <ccr@tnsp.org>
parents: 7
diff changeset
407 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
408 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
409 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
410 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
411
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
412 // Update some mouse variables
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
413 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
414 g_mx = g_msx - g_windowx;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
415 g_my = g_msy - g_windowy;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
416 } else {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
417 g_mx = mouseX;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
418 g_my = mouseY;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
419 }
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
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;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
423
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
424 // Actual tool drawing
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
425 if (g_tooltrigger == 1) { // comes from mousepressed, or mousedragged
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
426 if (g_mx <= width - g_hedge && g_my <= height - g_vedge)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
427 do_tool(g_mx, g_my, g_button);
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
428 }
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
429
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
430 switcher(0);
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
431
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
432 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
433 g_remdo[i] = 0;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
434 }
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
435
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
436 // Tool drawing for shows
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
437 int lipo = g_button;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
438 if (tool() != 5) {
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
439 if (g_phase == 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
440 g_button = LEFT;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
441 do_tool(g_mx, g_my, LEFT);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
442 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
443 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
444 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
445 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
446 g_button = lipo;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
447
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
448 // Screen update stuff
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
449 loadPixels();
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
450 viewport();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
451 //magport();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
452 switcher(1);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
453 update_ui();
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
454 updatePixels();
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
455
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
456 if (g_msgctr > 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
457 g_msgctr--;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
458
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
459 // 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
460 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
461 {
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
462 mpLoadFileSelector("Multipaint image", ".mp",
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
463 function (fh, fdata)
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
464 {
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
465 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
466 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
467 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
468 mpSetTitle(fh.name);
43
df6eecdf1cd4 Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
469 if (g_spare)
df6eecdf1cd4 Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
470 sfilename = fh.name;
df6eecdf1cd4 Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents: 40
diff changeset
471 else
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
472 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
473
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
474 refresh();
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
475 }
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
476 });
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
477
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
478 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
479 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
480 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
481 }
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
482
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
483 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
484 {
56
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
485 mpSaveNativeImage(filename +"_"+ (g_spare ? "spare" : "main") +".mp");
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
486
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
487 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
488 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
489 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
490 }
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
491
56
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
492 if (exporttxt)
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
493 {
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
494 exportemuname = g_spare ? sfilename : filename;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
495
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
496 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
497
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
498 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
499 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
500 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
501 }
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
502
56
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
503 if (exportemu)
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
504 {
4eb9ebde8c20 Some more interface cleanupping.
Matti Hamalainen <ccr@tnsp.org>
parents: 55
diff changeset
505 exportemuname = g_spare ? sfilename : filename;
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
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
507 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
508
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
509 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
510 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
511 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
512 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
513
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
514 if (importfmt)
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
515 {
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
516 mpLoadFileSelector(g_formatname, g_formatext,
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
517 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
518 {
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
519 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
520 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
521 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
522 refresh();
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
523 });
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
524
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
525 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
526 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
527 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
528 }
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
529
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
530 if (exportfmt)
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
531 {
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
532 format_export(filename +"_"+
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
533 (g_spare ? "spare" : "main") +
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
534 g_formatext);
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
535
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
536 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
537 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
538 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
539 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
540
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
541 //if(g_framec==1){saveFrame("frames/out-######.png");}
23
a076de42c2fc Remove dead code.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
542 //g_framec++;if(g_framec>1)g_framec=0;
a076de42c2fc Remove dead code.
Matti Hamalainen <ccr@tnsp.org>
parents: 22
diff changeset
543
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
544 if (g_keymacro.length() > g_keymacpos) {
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
545 macro_command(g_keymacro.charAt(g_keymacpos));
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
546 g_keymacpos++;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
547 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
548 }