annotate multipaint.pde @ 148:d80871032cdd

More change integration.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 14 Aug 2018 13:56:18 +0300
parents 5af8b5ddf349
children d7c13f427178
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 //
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
2 // Multipaint 1.8.2018
35
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
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
8 // Supported
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
9 final int C64 = 0, MSX = 5, SPECTRUM = 6, C64M = 10, PLUS4 = 9, PLUS4M = 19, CPC = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
10
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
11 // Experimental or incomplete
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
12 final int C64NOLIMIT = 32; // Commodore 64 without attribute limitations
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
13 final int C64FLI = 20, C64FLIM = 21; // incomplete FLI & AFLI modes
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
14 final int TIMEX = 7, JR200 = 8, AMIGA = 11, ATARIST = 12;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
15 final int PICO8 = 88;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
16 final int UNIA = 33;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
17 final int COCO3 = 34;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
18 final int BK0010 = 99;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
19 final int QLLOW = 66;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
20
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
21 // Reserved but completely unimplemented
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
22 final int VIC = 22; // VIC-20
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
23 final int CGA = 23; // 320 x 200 PC CGA screen with black, white, cyan, magenta
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
24 final int CGAX = 24; // 320 x 200 PC CGA screen with black, yellow, green, red-ish
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
25 final int EGA = 200; // 320 x 200 PC EGA screen, 16 colors of 64
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
26 final int VGA = 255; // 320 x 200 PC VGA screen, 256 colors of 65536
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
27 final int NES = 90; // 8-bit NES
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
28 final int SEGAM = 91; // 8-bit Sega Master System
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
29
16
f356d9c176a6 ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
30 final int PEESEE = 0, MACOSX = 1, PSJS = 2;
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
31 final int COMMAND = 157; // Marq's cmd/ctrl solution
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
32
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
33 int machine = -1; // change this to autoselect
16
f356d9c176a6 ProcessingJS does not provide "platform" variables, we need to define them ourselves.
Matti Hamalainen <ccr@tnsp.org>
parents: 15
diff changeset
34 int platform = PSJS;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
35
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
36 int g_active, g_tooltrigger, g_prevtool;
93
aadcd5f7e9dc Misc. cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 92
diff changeset
37 int g_rband, g_rbang, g_boxreconstruct, g_charlimit;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
38 int g_animx, g_animy, g_animframes, g_animno, g_animtime, g_animspeed;
114
019909b7ab6e Oops, g_dirty should've been boolean all the time.
Matti Hamalainen <ccr@tnsp.org>
parents: 113
diff changeset
39 int g_omag, g_bordh, g_bordv, g_keymacpos;
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
40 int g_wheelup = int(':'), g_wheeldown = int(';'), g_middlebutton = int(',');
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
41
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
42 boolean g_control = false, g_shift = false, g_dirty, g_inhibit_aspect = false;
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
43
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
44 String g_formatname, g_formatext,
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
45 filename = "", sfilename = "",
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
46 g_name, g_exportext = "",
110
ae324b1a020f Remove some unused globals.
Matti Hamalainen <ccr@tnsp.org>
parents: 104
diff changeset
47 g_exportname = "", g_keymacro = "";
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
48
133
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
49 final int OLD = 0;
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
50 final int NEW = 1;
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
51 int g_gridmode = OLD;
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
52 int g_pixelw = 1;
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
53 int[] g_grids = new int[16];
f5c32f6470d0 Begin integrating more changes from Multipaint 1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
54
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 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
57 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
58 int[] g_b = new int[266];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
59 int[] g_rgb = new int[266];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
60
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
61 byte[] g_map = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
62 byte[] g_fillmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
63 byte[] g_rmap = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
64 byte[] g_icons = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
65 byte[] g_brush = new byte[88000];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
66 byte[] g_template = new byte[16384];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
67 byte[] g_redo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
68 byte[] g_remdo = new byte[1024];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
69 int[] g_chaup = new int[64];
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
70 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
71 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
72 int[] g_magpiy = new int[64];
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
73
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
74 byte g_realfront, g_realback;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
75
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
76
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
77 //dimensions
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
78 int X, Y, MX, MY;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
79 //generic mouse
143
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
80 boolean g_klikkeri;
5e18cb16bc4b Booleanize.
Matti Hamalainen <ccr@tnsp.org>
parents: 142
diff changeset
81 int g_ofx, g_ofy, g_button, g_realbutton, g_mx, g_my, g_orx, g_ory, g_msx, g_msy;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
82 //rubberband,mouse
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
83 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
84 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
85 //window positioning
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
86 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
87 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
88 //icons & gui stuff
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
89 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
90 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
91 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
92 //machine related color properties
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
93 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
94 float g_palsteps;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
95 //brush, tool parameters
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
96 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
97 int g_bsize, g_btype;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
98
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
99
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
100 void setup()
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
101 {
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
102 //normi
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
103 g_magpix[0] = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
104 g_magpix[1] = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
105 g_magpix[2] = 16;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
106 g_magpiy[0] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
107 g_magpiy[1] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
108 g_magpiy[2] = 16;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
109
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
110 //mini
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
111 g_magpix[10] = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
112 g_magpix[11] = 6;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
113 g_magpix[12] = 16;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
114 g_magpiy[10] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
115 g_magpiy[11] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
116 g_magpiy[12] = 16;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
117
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
118 //maxi
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
119 g_magpix[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
120 g_magpix[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
121 g_magpix[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
122 g_magpiy[20] = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
123 g_magpiy[21] = 16;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
124 g_magpiy[22] = 32;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
125
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
126 //FLAT normi
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
127 g_magpix[100] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
128 g_magpix[101] = 9;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
129 g_magpix[102] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
130 g_magpiy[100] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
131 g_magpiy[101] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
132 g_magpiy[102] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
133
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
134 //FLAT mini
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
135 g_magpix[110] = 3;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
136 g_magpix[111] = 9;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
137 g_magpix[112] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
138 g_magpiy[110] = 2;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
139 g_magpiy[111] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
140 g_magpiy[112] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
141
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
142 //FLAT maxi
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
143 g_magpix[120] = 6;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
144 g_magpix[121] = 12;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
145 g_magpix[122] = 21;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
146 g_magpiy[120] = 4;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
147 g_magpiy[121] = 8;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
148 g_magpiy[122] = 14;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
149
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
150 g_omag = 1;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
151 g_bordh = 64;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
152 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
153
36
a39b3c9e5c3b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
154 // 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
155 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
156 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
157
36
a39b3c9e5c3b Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 35
diff changeset
158 // 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
159 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
160 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
161 else
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents: 24
diff changeset
162 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
163
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
164 switch (g_uizoom)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
165 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
166 case 1:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
167 g_wzoom = 2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
168 size(700, 468);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
169 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
170 case 2:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
171 g_wzoom = 3;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
172 size(1058, 708);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
173 break;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
174 case 3:
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
175 g_wzoom = 4;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
176 size(1460, 950);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
177 break;
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
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
180 if (g_inhibit_aspect)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
181 {
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
182 if (machine == QLLOW || machine == BK0010)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
183 Y = 256;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
184 }
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
185
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
186 if (g_uizoom >= 1 && g_uizoom <= 3)
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
187 g_wzoom = g_uizoom + 1;
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
188
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
189 g_hedge = 32 * g_uizoom;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
190 g_vedge = 32 * g_uizoom;
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 g_spare = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
193 g_bsize = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
194 g_btype = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
195 g_phase = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
196 g_button = LEFT;
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
197
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
198 g_data[int('f')] = 1; // fill on
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
199 g_data[int('g')] = 1; // grid on
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
200
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
201 g_icons = mpLoadBinaryFile("icons.bin");
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
202
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
203 set_tool(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
204
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
205 g_gridx = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
206 g_gridy = 8;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
207 g_multic = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
208 g_repanel = -2;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
209
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
210 //UI colors
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
211 makecolor(256, 0xff, 0, 0xff);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
212 makecolor(257, 180, 180, 180);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
213 g_rgb[257] = 0xff808080;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
214 makecolor(258, 0, 0, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
215 makecolor(259, 48, 48, 48);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
216 //R,G,B
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
217 makecolor(260, 255, 0, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
218 makecolor(261, 0, 255, 0);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
219 makecolor(262, 0, 0, 255);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
220
81
7ee5e0c590bd Clean set_machine() and rename to mpSetupMachine()
Matti Hamalainen <ccr@tnsp.org>
parents: 73
diff changeset
221 mpSetupMachine(machine);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
222 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
223 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
224 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
225 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
226
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
227 switcher(3);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
228
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
229 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
230 g_ofarge = g_farge;
7
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
231 MX = int(X / 8);
c848a6133cfc Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents: 4
diff changeset
232 MY = int(Y / 8);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
233 g_realfront = byte(g_farge);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
234 g_realback = byte(g_backg);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
235
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
236 for (int y = 0; y < Y; y++)
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
237 for (int x = 0; x < X; x++)
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
238 absolute_clearpoint(x, y);
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
239
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
240 switcher(2);
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
241 noStroke();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
242 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
243 sussborder();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
244 setup_raster();
83
6524e83c3ba7 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 82
diff changeset
245
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
246 message(" Multipaint| 2018|| v1.8.2018");
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
247 message("*");
89
09c1a4aba305 Set dirty flag on setup.
Matti Hamalainen <ccr@tnsp.org>
parents: 88
diff changeset
248 g_dirty = true;
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
249 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
250
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
251
101
e5c147a7bf98 Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents: 97
diff changeset
252 void mpSetTitle(String str)
e5c147a7bf98 Remove fexists(), it's not in use.
Matti Hamalainen <ccr@tnsp.org>
parents: 97
diff changeset
253 {
29
249c4f5742f3 Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents: 28
diff changeset
254 console.log("TITLE: '" + str + "'");
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
255 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
256
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
257
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
258 boolean mpHaveLocalStorage()
102
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
259 {
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
260 var test = 'mpLSTest';
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
261 try {
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
262 localStorage.setItem(test, test);
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
263 if (localStorage.getItem(test) == test)
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
264 {
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
265 localStorage.removeItem(test);
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
266 return true;
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
267 }
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
268 }
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
269 catch (e) {
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
270 return false;
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
271 }
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
272 return false;
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
273 }
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
274
287892b5eff8 Add function for checking availability of browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents: 101
diff changeset
275
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
276 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
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 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
279 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
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 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
282 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
283 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
284
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
285 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
286 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
287 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
288 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
289
54
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
290 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
291 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
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 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
294 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
295 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
296 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
297 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
298 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
299 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
300
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
301 freader.onloadend = (function(theFile) {
58
8c47708f0196 Oops, forgot to commit this.
Matti Hamalainen <ccr@tnsp.org>
parents: 56
diff changeset
302 fcallback(theFile, new Uint8Array(freader.result));
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
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
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
305 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
306 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
307 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
308 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
309 });
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 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
312
dee55b8f97a6 Use defined format extensions in the file selector. Also display format name
Matti Hamalainen <ccr@tnsp.org>
parents: 53
diff changeset
313 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
314 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
315 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
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 else
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
318 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
319 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
320
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
321
52
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
322 //
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
323 // Basically the same as Processing loadBytes(), but it seems
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
324 // 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
325 // 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
326 // our own design. --ccr
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
327 //
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
328 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
329 {
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
330 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
331 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
332 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
333 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
334 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
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 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
337 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
338
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
339 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
340 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
341
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
342 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
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 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
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 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
348 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
349
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
350
103
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
351 Blob mpMakeBinaryBlob(byte[] data)
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
352 {
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
353 var blob = null;
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
354 if (data == null)
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
355 return null;
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
356
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
357 if (typeof(data) == "string")
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
358 blob = new Blob([data], {type: "application/octet-stream"});
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
359 else
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
360 if (typeof(data) == "object")
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
361 blob = new Blob([new Uint8Array(data)], {type: "application/octet-stream"});
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
362
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
363 return blob;
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
364 }
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
365
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
366
52
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
367 //
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
368 // "Save" a byte array to file. Basically creates a blob URI
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
369 // and dumps it in the DOM, giving user a download.
4f998eb1700a Add some comments.
Matti Hamalainen <ccr@tnsp.org>
parents: 51
diff changeset
370 //
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
371 boolean mpSaveBinaryFile(String name, byte[] data)
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
372 {
103
7a889d59b405 Split Blob creation to mpMakeBinaryBlob().
Matti Hamalainen <ccr@tnsp.org>
parents: 102
diff changeset
373 var blob = mpMakeBinaryBlob(data);
96
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
374 if (blob == null)
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
375 {
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
376 console.log("Could not create BLOB from data.");
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
377 return false;
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
378 }
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
379
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
380 var url = window.URL.createObjectURL(blob);
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
381 if (url == null)
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
382 {
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
383 console.log("Could not create URL from BLOB object.");
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
384 return false;
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
385 }
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
386
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
387 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
388 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
389 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
390 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
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 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
393 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
394 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
395 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
396
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
397 window.URL.revokeObjectURL(url);
96
2d4b56e4d966 Improve mpSaveBinaryFile() to also handle string format data. Also improve
Matti Hamalainen <ccr@tnsp.org>
parents: 94
diff changeset
398 return true;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
399 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
400
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
401
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
402 void mpSavePNGImage(String name, int fmt, boolean border)
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
403 {
94
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
404 PImage simg = mpRenderImage(border);
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
405 // if (g_data[int('Q')] == 0)
88
03823fa2cb01 Refactor export_image() and export_image_sans_border() to use common code,
Matti Hamalainen <ccr@tnsp.org>
parents: 84
diff changeset
406
94
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
407 if (simg !== null)
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
408 {
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
409 // XXX TODO .. actually save the image, something like ..
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
410 //simg.canvas.toBlob(function(idata){ mpSaveBinaryFile(name, idata); }, "image/png", 0.95);
6e74d45ea620 More work towards jpeg/png image export/import.
Matti Hamalainen <ccr@tnsp.org>
parents: 93
diff changeset
411 }
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
412 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
413
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
414
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
415 int mpLoadPNGImage(String name)
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
416 {
92
4161d798cb64 Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
417 PImage simg = null;
4161d798cb64 Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
418 if (simg == null)
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
419 return -1;
92
4161d798cb64 Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
420
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
421 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
422 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
423 storeparameters();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
424
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
425 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
426 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
427 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
428
92
4161d798cb64 Clean up/refactor image (jpeg/png) importing a bit and rename function.
Matti Hamalainen <ccr@tnsp.org>
parents: 90
diff changeset
429 if (!mpImportFromImage(simg))
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
430 return -2;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
431
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
432 restoreparameters();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
433 refreshpalette();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
434 refresh();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
435 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
436 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
437 selectcolor(1, righth);
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
438 return 0;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
439 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
440
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
441
104
73a8773466ae Change mpSaveNativeImage() to mpGetNativeImage().
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
442 byte[] mpGetNativeImage()
53
c551029a7086 Cosmetic.
Matti Hamalainen <ccr@tnsp.org>
parents: 52
diff changeset
443 {
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
444 //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
445 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
446 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
447 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
448
104
73a8773466ae Change mpSaveNativeImage() to mpGetNativeImage().
Matti Hamalainen <ccr@tnsp.org>
parents: 103
diff changeset
449 return g_map;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
450 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
451
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
452
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
453 int mpSetNativeImage(byte[] data, boolean noError)
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
454 {
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
455 if (data == null)
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
456 return -1;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
457
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
458 if (data[3] != machine && !noError)
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
459 return -2;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
460
111
044e3371d44b Do store_undo() in mpSetNativeImage() when supposedly successfully loading
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
461 store_undo();
044e3371d44b Do store_undo() in mpSetNativeImage() when supposedly successfully loading
Matti Hamalainen <ccr@tnsp.org>
parents: 110
diff changeset
462
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
463 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
464
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
465 refreshpalette();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
466 consistency();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
467 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
468 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
469 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
470 sussborder();
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
471
97
65e6cacd068c Make PRG export work. Also some improvements in overall error handling.
Matti Hamalainen <ccr@tnsp.org>
parents: 96
diff changeset
472 return 0;
28
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
473 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
474
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
475
117
44a07b1c620d Rename 'bool' -> 'boolean'.
Matti Hamalainen <ccr@tnsp.org>
parents: 114
diff changeset
476 int mpLoadNativeImage(String name, boolean noError)
55
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
477 {
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
478 return mpSetNativeImage(
7194cdcc9dab Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 54
diff changeset
479 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
480 }
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
481
edcf9039552b Add several new helper functions for loading and saving formats using Javascript facilities.
Matti Hamalainen <ccr@tnsp.org>
parents: 27
diff changeset
482
69
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
483 void draw()
3d40683b367a Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 60
diff changeset
484 {
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
485 if (!focused)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
486 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
487 g_control = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
488 g_shift = false;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
489 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
490
72
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
491 // If there should be no update, do not update.
73
d2a89e88f958 When in rubberband mode, do not delay screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 72
diff changeset
492 if (!g_dirty && !g_rubbermode)
72
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
493 return;
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
494 g_dirty = false;
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
495
5e7553e9aee0 Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 69
diff changeset
496 // Animate animbrush
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
497 if (g_data[int('n')] == 1)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
498 {
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
499 if (++g_animtime > 8 - g_animspeed * 2)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
500 {
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
501 animbrush_do();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
502 g_animtime = 0;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
503 }
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
504 }
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
505
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
506 // Update some mouse variables
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
507 if (g_data[int('m')] == 0 && g_data[int('M')] == 0)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
508 {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
509 g_mx = g_msx - g_windowx;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
510 g_my = g_msy - g_windowy;
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
511 }
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
512 else
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
513 {
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
514 g_mx = mouseX;
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
515 g_my = mouseY;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
516 }
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
517
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
518 g_msx = mouseX;
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
519 g_msy = mouseY;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
520
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
521 // Actual tool drawing
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
522 if (g_tooltrigger == 1 &&
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
523 g_mx <= width - g_hedge &&
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
524 g_my <= height - g_vedge)
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
525 do_tool(g_mx, g_my, g_button);
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
526
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
527 switcher(0);
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
528
142
1ec3488bfd1e Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 136
diff changeset
529 for (int i = 0; i < 1024; i++)
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
530 g_remdo[i] = 0;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
531
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
532 // Tool drawing for shows
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
533 int savebut = g_button;
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
534 if (tool() != 5)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
535 {
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
536 if (g_phase == 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
537 g_button = LEFT;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
538 do_tool(g_mx, g_my, LEFT);
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
539 }
148
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
540 else
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
541 storecoords(g_mx, g_my);
d80871032cdd More change integration.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
542
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
543 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
544 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
545 if (tool() == 8) rectangle(g_rx, g_ry, g_rx2, g_ry2);
135
72ae62f2036b Cosmetic cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 133
diff changeset
546 g_button = savebut;
39
5e0306ac3575 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 36
diff changeset
547
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
548 // Screen update stuff
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
549 loadPixels();
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
550 viewport();
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
551 switcher(1);
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
552
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
553 if (g_pgrab)
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
554 preview_box_drag();
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
555
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 143
diff changeset
556 preview_window();
136
12cf30907f26 More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 135
diff changeset
557 update_ui(false);
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
558 updatePixels();
11
c1667eb54808 Cosmetics and indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 9
diff changeset
559
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
560 // Message control
40
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
561 if (g_msgctr > 0)
8d2362b6ac12 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 39
diff changeset
562 g_msgctr--;
2
5eb3559e1778 Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents: 0
diff changeset
563
113
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
564 // Macro handling
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
565 if (g_keymacro.length() > g_keymacpos)
f87c6577e696 Cleanups and few comments added.
Matti Hamalainen <ccr@tnsp.org>
parents: 112
diff changeset
566 {
0
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
567 macro_command(g_keymacro.charAt(g_keymacpos));
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
568 g_keymacpos++;
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
569 }
ebd5689e2985 Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff changeset
570 }