Skip to content

Commit 660e3ad

Browse files
committed
initial commit
0 parents  commit 660e3ad

File tree

16 files changed

+6687
-0
lines changed

16 files changed

+6687
-0
lines changed

demo.odin

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package demo
2+
3+
import "lena"
4+
5+
WHITE :: 1
6+
CYAN :: 9
7+
BLUE :: 10
8+
NAVY :: 11
9+
YELLOW :: 15
10+
ORANGE :: 16
11+
12+
CLOVER :: #load("demo.png")
13+
14+
main :: proc() {
15+
lena.init("Hello, Lena!", 128, 128, flags = {.HIDE_WINDOW, .HIDE_CURSOR})
16+
defer lena.destroy()
17+
18+
lena.set_window_background(BLUE)
19+
20+
lena.set_text_color(WHITE)
21+
lena.set_bold_color(YELLOW)
22+
23+
// if yellow is drawn over white, substitute orange
24+
// and don't let yellow on yellow disappear
25+
lena.set_blend_palette_pair(WHITE, YELLOW, ORANGE)
26+
lena.set_blend_palette_pair(YELLOW, YELLOW, ORANGE)
27+
28+
// if the cyan text is drawn over the navy background
29+
// or the yellow cursor, flip it to white and orange
30+
lena.set_blend_palette_pair(CYAN, NAVY, WHITE)
31+
lena.set_blend_palette_pair(CYAN, YELLOW, ORANGE)
32+
33+
// make a blank image to capture drawing
34+
canvas := lena.create_image(128, 128)
35+
defer lena.destroy_image(canvas)
36+
37+
// convert our clover PNG into a Lena image
38+
clover := lena.create_image_from_png(CLOVER)
39+
defer lena.destroy_image(clover)
40+
41+
lena.show_window()
42+
43+
for _ in lena.step() {
44+
if lena.key_pressed(.F11) {
45+
lena.toggle_fullscreen()
46+
}
47+
48+
if lena.key_pressed(.ESCAPE) {
49+
lena.quit()
50+
}
51+
52+
mx, my := lena.get_cursor()
53+
54+
lena.clear_screen(CYAN)
55+
56+
if lena.mouse_held(.LEFT) {
57+
// draw paint to canvas
58+
lena.draw_circle_to_image(canvas, mx, my, 14, YELLOW, true)
59+
60+
// copy clovers to canvas but clipped to canvas alpha
61+
lena.set_draw_state({.LOCK_ALPHA})
62+
lena.draw_image_to_image(clover, canvas, 0, 0)
63+
}
64+
65+
// draw composited canvas to screen
66+
lena.set_draw_state({.BLEND})
67+
lena.draw_image(canvas, 0, 0)
68+
69+
// draw yellow cursor
70+
lena.draw_circle(mx, my, 14, YELLOW, true)
71+
72+
// draw both sets of text
73+
lena.set_text_color(WHITE)
74+
lena.draw_text("Welcome to |*Lena*!", 10, 54 - 47)
75+
76+
lena.set_text_color(CYAN)
77+
lena.draw_text("Hold down |left click...", 10, 66 - 47)
78+
}
79+
}

demo.png

1.72 KB
Loading

0 commit comments

Comments
 (0)