diff --git a/README.md b/README.md
index 8abaaee..942cb43 100644
--- a/README.md
+++ b/README.md
@@ -39,6 +39,11 @@ $ ! ; Clear temporary storage
| ! ; Remove all guides
```
+##Stroke*
+```
+- 0,0 0,10 10,10 10,0 0,0 ; Draw a square
+```
+
##Filters*
```
: saturation 0.5 ; Set image saturation to 0.5
@@ -72,8 +77,9 @@ $ ! ; Clear temporary storage
5,7 ; position: 5x 7y
7x9 ; rect: 7w 9h
#ff0000 ; color: red
-?5 ; random: 0..5
+0..5 ; random: 0.0-5.0
45' ; degree: 45/365
+rate:10 ; variable: rate = 10
```
#Presets
@@ -104,7 +110,5 @@ $ ! ; Clear temporary storage
##Noise Brush
```
# Tight
-> 0,0.1 ?5;> 0,-0.1 ?5;> 0.1,0 ?5;> -0.1,0 ?5
-# Glitch
-> ?10;> ?10;> ?10;> ?10;> ?10;> ?10;> ?10;> ?10;
+> 4;> osc_rate:10 osc_scale:10;> osc_rate:15 osc_scale:12;> osc_rate:10 osc_scale:14;> osc_rate:10 osc_scale:10;
```
\ No newline at end of file
diff --git a/index.html b/index.html
index f8fe29e..93484c9 100644
--- a/index.html
+++ b/index.html
@@ -10,11 +10,12 @@
+
-
-
+
+
diff --git a/scripts/commander.js b/scripts/commander.js
index 78d9590..4968688 100644
--- a/scripts/commander.js
+++ b/scripts/commander.js
@@ -38,6 +38,9 @@ function Commander(element,element_input)
case "|":
ronin.overlay.active(cmd);
break;
+ case "-":
+ ronin.stroke.active(cmd);
+ break;
case "^": // TODO
ronin.translate.active(cmd);
break;
diff --git a/scripts/ronin.brush.js b/scripts/ronin.brush.js
index 3eec2bc..e1065c4 100644
--- a/scripts/ronin.brush.js
+++ b/scripts/ronin.brush.js
@@ -24,13 +24,14 @@ function Brush()
if(cmd.rect()){
pointer.mirror = cmd.rect();
}
- if(cmd.noise()){
- pointer.noise = cmd.noise();
+ if(cmd.variable("osc_scale") && cmd.variable("osc_rate")){
+ pointer.osc_rate = parseFloat(cmd.variable("osc_rate"));
+ pointer.osc_scale = parseFloat(cmd.variable("osc_scale"));
}
if(cmd.angle()){
pointer.angle = cmd.angle();
}
- if(cmd.rect() || cmd.position() || cmd.noise() || cmd.angle()){
+ if(cmd.rect() || cmd.position() || cmd.variable("osc_rate") || cmd.angle()){
this.add_pointer(pointer);
}
if(cmd.color()){
@@ -62,9 +63,9 @@ function Brush()
var hint_position = (cmd.position() ? "Position "+cmd.position().x+","+cmd.position().y+" " : "");
var hint_color = (cmd.color() ? "Color "+cmd.color().hex+" " : "");
var hint_rect = (cmd.rect() ? "Mirror "+cmd.rect().width+"/"+cmd.rect().height+" " : "");
- var hint_noise = (cmd.noise() ? "Noise 0.."+cmd.noise()+" " : "");
+ var hint_random = (cmd.random() ? "Random 0.."+cmd.random()+" " : "");
- return "Brush: "+hint_value+hint_position+hint_color+hint_rect+hint_noise;
+ return "Brush: "+hint_value+hint_position+hint_color+hint_rect+hint_random;
}
this.add_pointer = function(pointer)
diff --git a/scripts/ronin.brush.pointer.js b/scripts/ronin.brush.pointer.js
index 4202d9d..494eae8 100644
--- a/scripts/ronin.brush.pointer.js
+++ b/scripts/ronin.brush.pointer.js
@@ -2,11 +2,13 @@ function Pointer(offset = new Position(), color = new Color('000000'))
{
this.offset = offset;
this.mirror = null;
- this.noise = null;
this.position_prev = null;
this.angle = null;
this.distance = 0;
+ this.osc_scale = null;
+ this.osc_rate = null;
+
this.draw = function()
{
if(!this.position_prev){this.position_prev = this.position(); }
@@ -16,9 +18,10 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.distance += position.distance_to(this.position_prev);
- if(this.noise){
- position.x += (Math.sin(this.distance/100) * this.noise) - (this.noise/2);
- position.y += (Math.sin(this.distance/100) * this.noise) - (this.noise/2);
+ // Osc experiment
+ if(this.osc_rate && this.osc_scale){
+ // position.x += (Math.sin(this.distance/(25 * this.osc_rate)) * this.osc_scale) - (this.osc_scale/2);
+ position.y += (Math.sin(this.distance/(25 * this.osc_rate)) * this.osc_scale) - (this.osc_scale/2);
}
ronin.canvas.context().beginPath();
diff --git a/scripts/ronin.js b/scripts/ronin.js
index dc3c11c..26a3346 100644
--- a/scripts/ronin.js
+++ b/scripts/ronin.js
@@ -6,4 +6,5 @@ function Ronin()
this.file = new File();
this.hint = new Hint();
this.filter = new Filter();
+ this.stroke = new Stroke();
}
\ No newline at end of file
diff --git a/scripts/ronin.stroke.js b/scripts/ronin.stroke.js
new file mode 100644
index 0000000..5a9b9f4
--- /dev/null
+++ b/scripts/ronin.stroke.js
@@ -0,0 +1,36 @@
+function Stroke(element)
+{
+ Module.call(this);
+
+ // Module
+
+ this.passive = function(cmd)
+ {
+ }
+
+ this.active = function(cmd)
+ {
+ // TODO
+
+ var origin = new Position(cmd.content[0]);
+ var destination = new Position(cmd.content[1]);
+
+ var e = {};
+ e.clientX = origin.x;
+ e.clientY = origin.y;
+
+ ronin.brush.is_drawing = true;
+ ronin.brush.draw(e);
+
+ e.clientX = destination.x;
+ e.clientY = destination.y;
+
+ ronin.brush.draw(e);
+ ronin.brush.is_drawing = false;
+ }
+
+ this.hint = function(cmd)
+ {
+ }
+
+}
\ No newline at end of file
diff --git a/scripts/unit.command.js b/scripts/unit.command.js
index 152dcc4..6c1b2f2 100644
--- a/scripts/unit.command.js
+++ b/scripts/unit.command.js
@@ -43,10 +43,10 @@ function Command(content)
return null;
}
- this.noise = function()
+ this.random = function()
{
for (i = 0; i < this.content.length; i++) {
- if(this.content[i].indexOf("?") >= 0){ return parseInt(this.content[i].replace('?','')); }
+ if(this.content[i].indexOf("..") >= 0){ (Math.random() * this.content[i].split("..")[1]) + this.content[i].split("..")[0]; }
}
return null;
}
@@ -66,4 +66,12 @@ function Command(content)
}
return null;
}
+
+ this.variable = function(name)
+ {
+ for (i = 0; i < this.content.length; i++) {
+ if(this.content[i].indexOf(name+":") >= 0){ return this.content[i].split(":")[1]; }
+ }
+ return null;
+ }
}
\ No newline at end of file