-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcrumbicon.crumb
57 lines (49 loc) · 1.72 KB
/
crumbicon.crumb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
(use "./usables/colors.crumb" {
// argument is assumed to be a relative path.
path_to_file = (if (is (length arguments) 1) {
<- (get arguments 0)
} {
<- "favicon.svg"
})
// get data from file or create blank
from_file = (use "./src/import.crumb" "./usables/tui.crumb" "./src/splash.crumb" {
<- (crumbicon path_to_file)
})
// when file exist, but is not a crumbicon file, the program will terminate
(if (not (is from_file void)) {
// state access constants
APP_XY = 0
PAINTBRUSH = 1
CANDIDATE = 2
DATA = 3
PALETTE = 4
SIZE = 5
SAVE = 6
X = 0
Y = 1
PALETTE_INDEX = 0
PALETTE_COLORS = 1
//state after user manipulation via UI
state = (use "./usables/tui.crumb" "./src/elements.crumb" {
x = (integer (divide (subtract (columns) app_width) 2)) // center position on x
y = (integer (divide (subtract (rows) app_height) 2)) // center position on y
// initial state
state = (list
(list x y) // screen anchor
(get (get from_file 1) 0) // paintbrush color from first position in palette
(subtract 0 1) // candidate color set to -1 which is nothing (not transparent and not color)
(get from_file 0) // canvas data
(list (ideal_palette_index -1 (get from_file 1)) (get from_file 1)) // palette
(get from_file 2) // size
void // save or abort?
)
<- (start state elements void)
})
// after UI is exited, check if save is needed.
(if (is (get state SAVE) 1) {
(use "./src/export.crumb" "./usables/tui.crumb" "./src/splash.crumb" {
(svg (get state DATA) (list (get state SIZE) (get state SIZE) 30) (get (get state PALETTE) 1) path_to_file)
})
})
})
})