(frame) and (theme) are now interpreted on run()

This commit is contained in:
Devine Lu Linvega
2019-08-03 15:40:26 +09:00
parent 46bf50f663
commit ff261c33e2
23 changed files with 147 additions and 199 deletions

View File

@@ -1,4 +1,5 @@
; benchmark
; this file is used to test the library.
; Basics

View File

@@ -1,24 +0,0 @@
; open every file in a folder.
(defn filter-jpg
(file-name)
(eq
(last
(split file-name ".")) "jpg"))
;
(def images
(filter
(dir) filter-jpg))
;
(debug
(concat "Found: "
(len images)))
;
(defn image-operation
(file-name)
(
(def file-path
(concat
(dirpath) "/" file-name))
(open file-path)))
;
(each images image-operation)

View File

@@ -1,26 +1,19 @@
; gradients
(clear)
;
(def frame-rect (frame))
(def radius
(frame-rect:m))
;
(def gradient-line
(line frame-rect:c 0 frame-rect:c frame-rect:h))
;
(def gl
(line 0 0 frame:h frame:h))
(def cl1
(gradient gl
(theme:b_med theme:b_high)))
(def cl2
(gradient gl
(theme:b_high theme:b_med)))
(guide gl)
(fill
(circle frame-rect:c frame-rect:m radius)
(gradient gradient-line
("#72dec2" "white")))
;
(circle frame:m frame:m frame:m) cl1)
(fill
(circle frame-rect:c frame-rect:m
(mul radius 0.75))
(gradient gradient-line
("white" "#72dec2")))
;
(circle frame:m frame:m
(mul frame:m 0.75)) cl2)
(fill
(circle frame-rect:c frame-rect:m
(mul radius 0.5))
(gradient gradient-line
("#72dec2" "white")))
(circle frame:m frame:m
(mul frame:m 0.5)) cl1)

View File

@@ -1,42 +1,42 @@
; shapes
; display a collection of all shapes.
(clear)
(stroke
(rect 0 0 300 300) "red")
(rect 0 0 300 300) theme:b_high)
(stroke
(circle 150 150 150) "white")
(circle 150 150 150) theme:b_med)
(stroke
(ellipse 150 150 75 150) "red")
(ellipse 150 150 75 150) theme:b_high)
(stroke
(line 0 150 300 150) "red")
(line 0 150 300 150) theme:b_high)
(stroke
(text 600 300 60 "hell") "white")
(text 600 300 60 "hell") theme:b_med)
(stroke
(arc 600 298 296
(rad 180)
(rad -90)) "white")
(rad -90)) theme:b_med)
(stroke
(poly
(pos 300 300)
(pos 600 0)
(pos 600 300)) "red")
(pos 600 300)) theme:b_high)
(transform:move 0 300)
(fill
(rect 0 0 300 300) "red")
(rect 0 0 300 300) theme:b_high)
(fill
(circle 150 150 150) "white")
(circle 150 150 150) theme:b_med)
(fill
(ellipse 150 150 75 150) "red")
(ellipse 150 150 75 150) theme:b_high)
(fill
(line 0 150 300 150) "red")
(line 0 150 300 150) theme:b_high)
(fill
(text 600 300 60 "hell") "white")
(text 600 300 60 "hell") theme:b_med)
(fill
(arc 600 298 296
(rad 180)
(rad -90)) "white")
(rad -90)) theme:b_med)
(fill
(poly
(pos 300 300)
(pos 600 0)
(pos 600 300)) "red")
(transform:reset)
(pos 600 300)) theme:b_high)
(transform:reset)

View File

@@ -0,0 +1,38 @@
; animated recusive spiral
; by @local_guru
(defn rec
(v)
(if
(gt v 0)
(
; params
(def spiral-x
(add frame:c
(mul
(cos
(add
(div v 17)
(time 0.001)))
(div v 2))))
(def spiral-y
(add frame:m
(mul
(sin
(div v 11))
(div v 2))))
(def spiral-r
(div v 2))
; draw
(stroke
(circle spiral-x spiral-y spiral-r)
(color 114 222 194 0.1) 1)
(rec
(sub v 0.3)))))
;
(defn redraw
()
(
(clear)
(rec 300)))
;
(on "animate" redraw)

View File

@@ -0,0 +1,58 @@
; stars
(clear)
; times
(defn times
(v f)
(
(f v)
(if
(gt v 1)
(times
(sub v 1) f))))
; convert deg to radians
(defn deg-rad
(deg)
(mul deg
(div PI 180)))
; position on a circle from angle
(defn circle-pos
(cx cy r a) {:x
(add cx
(mul r
(cos a))) :y
(add cy
(mul r
(sin a)))})
; draw
(defn draw-spoke
(cx cy r a)
(
(stroke
(line cx cy
(:x
(circle-pos cx cy r a))
(:y
(circle-pos cx cy r a))) "white" 2)))
;
(defn draw-star
(cx cy r c)
(
(times c
(λ
(i)
(
(draw-spoke cx cy r
(deg-rad
(mul i
(div 360 c)))))))))
; main
(times 100
(λ
()
(
(draw-star
(random 100 frame:w)
(random 100 frame:h)
(random 10 100)
(floor
(random 3 32))))))

View File

@@ -1,12 +1,9 @@
; display color from the theme.
; ex: theme:f_high
(clear)
(fill
(frame) theme:background)
(fill frame theme:background)
(def color-box
(div
(:h
(frame)) 10))
(div frame:h 10))
(defn print-value
(item id)
(
@@ -18,12 +15,12 @@
(circle color-box box-y
(div color-box 2)) item)
(fill
(text 140 box-y 30 id) "white")
(text 140 box-y 30 id) theme:f_high)
(fill
(text 200 box-y 30
(of
(keys theme) id)) "white")
(keys theme) id)) theme:f_high)
(fill
(text 400 box-y 30 item) "white")))
(text 400 box-y 30 item) theme:f_high)))
(map
(values theme) print-value)

View File

@@ -0,0 +1,24 @@
(clear)
(defn branch
(v)
(if
(gt v 0)
(
(transform:scale 0.95)
(stroke
(line 0 0 100 100) theme:b_high 2)
(transform:move 100 100)
(transform:push)
(transform:rotate
(div v 50))
(branch
(sub v 1))
(transform:pop)
(transform:push)
(transform:rotate
(div v -50))
(branch
(sub v 1))
(transform:pop))))
(branch 10)
(transform:reset)

View File

@@ -2,18 +2,18 @@
(clear)
(transform:move 150 150)
(fill
(circle 0 0 150) "#ffb545")
(circle 0 0 150) theme:b_inv)
(transform:move 300 0)
(transform:rotate
(rad 90))
(fill
(circle 0 0 150) "white")
(circle 0 0 150) theme:b_high)
(transform:move 300 0)
(transform:rotate
(rad 90))
(fill
(circle 0 0 150) "#72dec2")
(circle 0 0 150) theme:b_med)
(transform:move 300 0)
(fill
(circle 0 0 150) "#555")
(circle 0 0 150) theme:b_low)
(transform:reset)