Removed shapes, fixes #69

This commit is contained in:
Devine Lu Linvega
2019-07-22 15:56:35 +09:00
parent 8f54f954d2
commit b694d6c8db
14 changed files with 7 additions and 10 deletions

View File

@@ -1,13 +0,0 @@
; basics
; define a variable
(def a 25)
(echo a)
; define a function
(defn add-two (a) (add 2 a))
(echo (add-two 4))
; use a lambda
(times 5
(λ (a) (echo (concat "time:" a))))

View File

@@ -1,68 +0,0 @@
; benchmark
; Basics
(test "add" (add 8 4 2) 14)
(test "sub" (sub 8 4 2) 2)
(test "mul" (mul 8 4 2) 64)
(test "div" (div 8 4 2) 1)
; Others
(test "mod" (mod 6 4) 2)
(test "clamp" (clamp 12 4 8) 8)
(test "step" (step 12 10) 10)
(test "PI" TWO_PI (mul 2 PI))
; Logic
(test "lt" (lt 3 4) true)
(test "gt" (gt 3 4) false)
(test "and - true" (and 1 2 true 4) 4)
(test "and - false" (and 1 false 2) false)
(test "or - true" (or false false 2 false) 2)
(test "if - branch 1" (if (gt 3 2) ("branch 1") ("branch 2")) "branch 1")
(test "if - branch 2" (if (lt 3 2) ("branch 1") ("branch 2")) "branch 2")
(test "if - no else" (if (lt 3 2) ("branch 1")) ())
; Arrays
(test "first" (first ("a" "b" "c")) "a")
(test "rest" (rest ("a" "b" "c")) ("b" "c"))
(test "last" (last ("a" "b" "c")) "c")
(test "range simple" (range 0 4) (0 1 2 3 4))
(test "range with step" (range 0 4 2) (0 2 4))
(test "range with negative step" (range 0 -4 -1) (0 -1 -2 -3 -4))
(test "map" (map (λ (a) (add 1 a)) (1 2 3)) (2 3 4))
(test "filter" (filter (λ (a) (eq 0 (mod a 2))) (2 3 4 5 6)) (2 4 6))
(test "reduce" (reduce (λ (acc val) (add acc val)) (1 2 3) 4) 10)
; Scope
(def aaa 123)
(def addOne (λ (a) (add a 1)))
(test "def - value" aaa 123)
(test "def - func" (addOne 4) 5)
(defn addTwo (a) (add 2 a))
(test "defn" (addTwo 4) 6)
(defn mulTwo "multiplies by two" (a) (mul 2 a))
(test "docstring" (mulTwo 4) 8)
; Generics
(test "concat" (concat 1 4 "-" (add 3 4) ".jpg") "14-7.jpg")
; Interop
(test "interop" ((of (of (js) "Math") "max") 2 4) 4)
(test "recursive key selector" ((of (js) "Math" "max") 2 4) 4)
; fs
; filesystem
(echo (filepath))
(echo (dirpath))
(echo (file))
(echo (dir))

View File

@@ -1,5 +0,0 @@
; crop
(clear)
(open "../static/crystal.jpg")
(crop (rect 100 100 400 400))

View File

@@ -1,33 +0,0 @@
; dejong attractor
(clear)
(defn point (x y color)
(fill (rect x y 1 1) color))
(defn _dejong (x y a b c d)
(rest ((point
(add 300 (mul 100 x))
(add 400 (mul 100 y))
"red")
(add (sin (mul a y)) (mul x (cos (mul b x))))
(add (mul x (sin (mul x c))) (cos (mul d y)))
))
)
(defn dejong (r a b c d)
(reduce
(λ (acc val)
(first (
(_dejong (first acc) (last acc) a b c d)
)))
(range 0 r)
(2 1)
)
)
(benchmark
'(dejong 12800
(random -2 2)
(random -2 2)
(random -2 2)
(random -2 2)
))

View File

@@ -1,18 +0,0 @@
; Glitch
(clear)
(defn glitch
(rec)
(if (gt rec 1)
(
(translate
(rect (random 400) (random 400) (random 10) (random 10))
(pos (random 400) (random 400)))
(glitch (sub rec 1)))))
(import
"../static/crystal.jpg"
(rect 0 0 400 400))
(glitch 500)

View File

@@ -1,7 +0,0 @@
; saturate image
(open "../static/crystal.jpg")
(pixels
(frame)
saturation
12)

View File

@@ -1,7 +0,0 @@
; pixels
(clear)
(import "../../PREVIEW.jpg"
(frame))
(pixels
(rect 0 0 500 500) saturation 0.5)

View File

@@ -1,17 +0,0 @@
; random
(clear)
(defn place
(rec)
(if
(gt rec 0)
(
(import "../static/crystal.jpg"
(rect
(random 200)
(random 200)
(random 200)
(random 200)))
(place
(sub rec 1)))))
(place 30)

View File

@@ -1,16 +0,0 @@
; recursive
(clear)
(defn rec
(v)
(if
(gt v 0)
(
(stroke
(circle
(mul 5 v)
(mul 5 v)
(mul 5 v)) 1 "red")
(rec
(sub v 5)))))
(rec 100)

View File

@@ -1,24 +0,0 @@
; Shapes
(clear)
; variables
(def center-w (div (of (frame) "w") 2))
(def center-h (div (of (frame) "h") 2))
(def rad (div (of (frame) "h") 4))
; draw circle
(stroke
(circle center-w center-h rad) 2 "white")
; draw rect
(stroke
(rect
(sub center-w rad) (sub center-h rad) center-h center-h) 2 "white")
; draw line
(stroke
(line
(pos (sub center-w rad) center-h)
(pos (add center-w rad) center-h)))
(stroke (text 10 170 200 "HELL") 2 "pink")

View File

@@ -1,30 +0,0 @@
; animated recusive spiral
; by @local_guru
(clear)
(defn rec
(v)
(if
(gt v 0)
(
(stroke
(circle
(add 375
(mul
(cos
(add
(div v 17)
(div
(time) 2000)))
(div v 2)))
(add 300
(mul
(sin
(div v 11))
(div v 2)))
(div v 2)) 1 "rgba(114,222, 194,0.1)")
(rec
(sub v 0.3)))))
; set false to stop
(animate true)
(rec 300)

View File

@@ -1,8 +0,0 @@
(clear)
; ronin path
(stroke
(svg "M60,60 L195,60 A45,45 0 0,1 240,105 A45,45 0 0,1 195,150 L60,150 M195,150 A45,45 0 0,1 240,195 L240,240 ") 2 "white")
; outline
(stroke
(svg "M15,15 L15,15 L285,15 L285,285 L15,285 Z") 1 "#555")