Added new units, adding stroke.
This commit is contained in:
parent
7b6c629e1e
commit
fddc967c61
12
README.md
12
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;
|
||||
```
|
@ -10,11 +10,12 @@
|
||||
<script type="text/javascript" src="scripts/ronin.module.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.canvas.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.filter.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.stroke.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.overlay.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.file.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.hint.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.brush.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.brush.pointer.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.file.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.hint.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/keyboard.js"></script>
|
||||
<script type="text/javascript" src="scripts/commander.js"></script>
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
@ -6,4 +6,5 @@ function Ronin()
|
||||
this.file = new File();
|
||||
this.hint = new Hint();
|
||||
this.filter = new Filter();
|
||||
this.stroke = new Stroke();
|
||||
}
|
36
scripts/ronin.stroke.js
Normal file
36
scripts/ronin.stroke.js
Normal file
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user