From 39b2e558bd6b7eaac829909274b23d458e5b94d1 Mon Sep 17 00:00:00 2001
From: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Mon, 22 Jul 2019 15:36:16 +0900
Subject: [PATCH] Moving examples

---
 desktop/sources/scripts/library.js       | 28 ++++++++++++------------
 desktop/sources/scripts/surface.js       | 26 +++++++++++++++++-----
 examples/{ => archives}/arrays.lisp      |  0
 examples/{ => archives}/basics.lisp      |  0
 examples/{ => archives}/benchmark.lisp   |  0
 examples/{ => archives}/crop.lisp        |  0
 examples/{ => archives}/dejong.lisp      |  0
 examples/{ => archives}/glitch.lisp      |  0
 examples/{ => archives}/gradient.lisp    |  0
 examples/{ => archives}/guides.lisp      |  0
 examples/{ => archives}/import.lisp      |  0
 examples/{ => archives}/include.lisp     |  0
 examples/{ => archives}/objects.lisp     |  0
 examples/{ => archives}/open.lisp        |  0
 examples/{ => archives}/pixels.lisp      |  0
 examples/{ => archives}/random.file.lisp |  0
 examples/{ => archives}/random.lisp      |  0
 examples/{ => archives}/recursive.lisp   |  0
 examples/{ => archives}/resize.lisp      |  0
 examples/{ => archives}/shapes.lisp      |  0
 examples/{ => archives}/spiral.lisp      |  0
 examples/{ => archives}/stars.lisp       |  0
 examples/{ => archives}/svg.lisp         |  0
 examples/{ => archives}/theme.lisp       |  0
 examples/{ => archives}/transform.lisp   |  0
 examples/{ => events}/on-animate.lisp    |  0
 examples/{ => events}/on-mouse.lisp      |  0
 examples/{ => events}/on-osc.lisp        |  0
 28 files changed, 34 insertions(+), 20 deletions(-)
 rename examples/{ => archives}/arrays.lisp (100%)
 rename examples/{ => archives}/basics.lisp (100%)
 rename examples/{ => archives}/benchmark.lisp (100%)
 rename examples/{ => archives}/crop.lisp (100%)
 rename examples/{ => archives}/dejong.lisp (100%)
 rename examples/{ => archives}/glitch.lisp (100%)
 rename examples/{ => archives}/gradient.lisp (100%)
 rename examples/{ => archives}/guides.lisp (100%)
 rename examples/{ => archives}/import.lisp (100%)
 rename examples/{ => archives}/include.lisp (100%)
 rename examples/{ => archives}/objects.lisp (100%)
 rename examples/{ => archives}/open.lisp (100%)
 rename examples/{ => archives}/pixels.lisp (100%)
 rename examples/{ => archives}/random.file.lisp (100%)
 rename examples/{ => archives}/random.lisp (100%)
 rename examples/{ => archives}/recursive.lisp (100%)
 rename examples/{ => archives}/resize.lisp (100%)
 rename examples/{ => archives}/shapes.lisp (100%)
 rename examples/{ => archives}/spiral.lisp (100%)
 rename examples/{ => archives}/stars.lisp (100%)
 rename examples/{ => archives}/svg.lisp (100%)
 rename examples/{ => archives}/theme.lisp (100%)
 rename examples/{ => archives}/transform.lisp (100%)
 rename examples/{ => events}/on-animate.lisp (100%)
 rename examples/{ => events}/on-mouse.lisp (100%)
 rename examples/{ => events}/on-osc.lisp (100%)

diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js
index 8145d8a..7b7d06f 100644
--- a/desktop/sources/scripts/library.js
+++ b/desktop/sources/scripts/library.js
@@ -54,32 +54,32 @@ function Library (ronin) {
 
   // Shapes
 
-  this.pos = (x, y, t = 'pos') => { // Returns a position shape.
-    return { x, y, t }
+  this.pos = (x, y) => { // Returns a position shape.
+    return { x, y }
   }
 
-  this.size = (w, h, t = 'size') => { // Returns a size shape.
-    return { w, h, t }
+  this.size = (w, h) => { // Returns a size shape.
+    return { w, h }
   }
 
-  this.rect = (x, y, w, h, t = 'rect') => { // Returns a rect shape.
-    return { x, y, w, h, t }
+  this.rect = (x, y, w, h) => { // Returns a rect shape.
+    return { x, y, w, h }
   }
 
-  this.circle = (cx, cy, r, t = 'circle') => { // Returns a circle shape.
-    return { cx, cy, r, t }
+  this.circle = (cx, cy, r) => { // Returns a circle shape.
+    return { cx, cy, r }
   }
 
-  this.line = (a, b, t = 'line') => { // Returns a line shape.
-    return { a, b, t }
+  this.line = (a, b) => { // Returns a line shape.
+    return { a, b }
   }
 
-  this.text = (x, y, g, s, f = 'Arial', t = 'text') => { // Returns a text shape.
-    return { x, y, g, s, f, t }
+  this.text = (x, y, p, t, f = 'Arial') => { // Returns a text shape.
+    return { x, y, p, t, f }
   }
 
-  this.svg = (d, t = 'svg') => { // Returns a svg shape.
-    return { d, t }
+  this.svg = (d) => { // Returns a svg shape.
+    return { d }
   }
 
   // Actions
diff --git a/desktop/sources/scripts/surface.js b/desktop/sources/scripts/surface.js
index bbb3b27..206637c 100644
--- a/desktop/sources/scripts/surface.js
+++ b/desktop/sources/scripts/surface.js
@@ -28,10 +28,10 @@ function Surface (ronin) {
     this.trace(shape, context)
     context.lineWidth = width
     context.strokeStyle = color
-    if (shape.t === 'text') {
-      context.font = `${shape.g}px ${shape.f}`
-      context.strokeText(shape.s, shape.x, shape.y)
-    } else if (shape.t === 'svg') {
+    if (isText(shape)) {
+      context.font = `${shape.p}px ${shape.f}`
+      context.strokeText(shape.t, shape.x, shape.y)
+    } else if (isSvg(shape)) {
       context.lineWidth = width
       context.strokeStyle = color
       context.stroke(new Path2D(shape.d))
@@ -47,10 +47,10 @@ function Surface (ronin) {
     context.beginPath()
     context.fillStyle = color
     this.trace(shape, context)
-    if (shape.t === 'text') {
+    if (isText(shape)) {
       context.font = `${shape.g}px ${shape.f}`
       context.fillText(shape.s, shape.x, shape.y)
-    } else if (shape.t === 'svg') {
+    } else if (isSvg(shape)) {
       context.fillStyle = color
       context.fill(new Path2D(shape.d))
     } else {
@@ -71,6 +71,7 @@ function Surface (ronin) {
   // Tracers
 
   this.trace = function (shape, context) {
+    console.log(this.findType(shape))
     if (shape.t === 'rect') {
       this.traceRect(shape, context)
     } else if (shape.t === 'line') {
@@ -234,4 +235,17 @@ function Surface (ronin) {
       }
     })
   }
+
+  function isRect (shape) {
+    return shape.x && shape.y && shape.w && shape.h
+  }
+  function isCircle (shape) {
+    return shape.cx && shape.cy && shape.r
+  }
+  function isSvg (shape) {
+    return shape.d
+  }
+  function isLine (shape) {
+    return shape.a && shape.a.x && shape.a.y && shape.b && shape.b.x && shape.b.y
+  }
 }
diff --git a/examples/arrays.lisp b/examples/archives/arrays.lisp
similarity index 100%
rename from examples/arrays.lisp
rename to examples/archives/arrays.lisp
diff --git a/examples/basics.lisp b/examples/archives/basics.lisp
similarity index 100%
rename from examples/basics.lisp
rename to examples/archives/basics.lisp
diff --git a/examples/benchmark.lisp b/examples/archives/benchmark.lisp
similarity index 100%
rename from examples/benchmark.lisp
rename to examples/archives/benchmark.lisp
diff --git a/examples/crop.lisp b/examples/archives/crop.lisp
similarity index 100%
rename from examples/crop.lisp
rename to examples/archives/crop.lisp
diff --git a/examples/dejong.lisp b/examples/archives/dejong.lisp
similarity index 100%
rename from examples/dejong.lisp
rename to examples/archives/dejong.lisp
diff --git a/examples/glitch.lisp b/examples/archives/glitch.lisp
similarity index 100%
rename from examples/glitch.lisp
rename to examples/archives/glitch.lisp
diff --git a/examples/gradient.lisp b/examples/archives/gradient.lisp
similarity index 100%
rename from examples/gradient.lisp
rename to examples/archives/gradient.lisp
diff --git a/examples/guides.lisp b/examples/archives/guides.lisp
similarity index 100%
rename from examples/guides.lisp
rename to examples/archives/guides.lisp
diff --git a/examples/import.lisp b/examples/archives/import.lisp
similarity index 100%
rename from examples/import.lisp
rename to examples/archives/import.lisp
diff --git a/examples/include.lisp b/examples/archives/include.lisp
similarity index 100%
rename from examples/include.lisp
rename to examples/archives/include.lisp
diff --git a/examples/objects.lisp b/examples/archives/objects.lisp
similarity index 100%
rename from examples/objects.lisp
rename to examples/archives/objects.lisp
diff --git a/examples/open.lisp b/examples/archives/open.lisp
similarity index 100%
rename from examples/open.lisp
rename to examples/archives/open.lisp
diff --git a/examples/pixels.lisp b/examples/archives/pixels.lisp
similarity index 100%
rename from examples/pixels.lisp
rename to examples/archives/pixels.lisp
diff --git a/examples/random.file.lisp b/examples/archives/random.file.lisp
similarity index 100%
rename from examples/random.file.lisp
rename to examples/archives/random.file.lisp
diff --git a/examples/random.lisp b/examples/archives/random.lisp
similarity index 100%
rename from examples/random.lisp
rename to examples/archives/random.lisp
diff --git a/examples/recursive.lisp b/examples/archives/recursive.lisp
similarity index 100%
rename from examples/recursive.lisp
rename to examples/archives/recursive.lisp
diff --git a/examples/resize.lisp b/examples/archives/resize.lisp
similarity index 100%
rename from examples/resize.lisp
rename to examples/archives/resize.lisp
diff --git a/examples/shapes.lisp b/examples/archives/shapes.lisp
similarity index 100%
rename from examples/shapes.lisp
rename to examples/archives/shapes.lisp
diff --git a/examples/spiral.lisp b/examples/archives/spiral.lisp
similarity index 100%
rename from examples/spiral.lisp
rename to examples/archives/spiral.lisp
diff --git a/examples/stars.lisp b/examples/archives/stars.lisp
similarity index 100%
rename from examples/stars.lisp
rename to examples/archives/stars.lisp
diff --git a/examples/svg.lisp b/examples/archives/svg.lisp
similarity index 100%
rename from examples/svg.lisp
rename to examples/archives/svg.lisp
diff --git a/examples/theme.lisp b/examples/archives/theme.lisp
similarity index 100%
rename from examples/theme.lisp
rename to examples/archives/theme.lisp
diff --git a/examples/transform.lisp b/examples/archives/transform.lisp
similarity index 100%
rename from examples/transform.lisp
rename to examples/archives/transform.lisp
diff --git a/examples/on-animate.lisp b/examples/events/on-animate.lisp
similarity index 100%
rename from examples/on-animate.lisp
rename to examples/events/on-animate.lisp
diff --git a/examples/on-mouse.lisp b/examples/events/on-mouse.lisp
similarity index 100%
rename from examples/on-mouse.lisp
rename to examples/events/on-mouse.lisp
diff --git a/examples/on-osc.lisp b/examples/events/on-osc.lisp
similarity index 100%
rename from examples/on-osc.lisp
rename to examples/events/on-osc.lisp