Progress on radial brush.

This commit is contained in:
Devine Lu Linvega 2016-11-15 11:16:06 -08:00
parent b473437de5
commit fd4428aafa
4 changed files with 27 additions and 3 deletions

View File

@ -28,6 +28,7 @@ $ ! ; Clear temporary storage
> 10,0 ; Add pointer at pos
> 400x0 ; Add mirror pointer, at 400x
> 4 #ff0000 ; Red brush, Size 4
> 100,100 45' ; Radial brush from position x,y and 45 degrees
> ! ; Remove all pointers
```

View File

@ -19,7 +19,7 @@ function Brush()
var pointer = new Pointer();
if(cmd.position()){
pointer.position = cmd.position();
pointer.offset = cmd.position();
}
if(cmd.rect()){
pointer.mirror = cmd.rect();
@ -27,7 +27,10 @@ function Brush()
if(cmd.noise()){
pointer.noise = cmd.noise();
}
if(cmd.rect() || cmd.position() || cmd.noise()){
if(cmd.angle()){
pointer.angle = cmd.angle();
}
if(cmd.rect() || cmd.position() || cmd.noise() || cmd.angle()){
this.add_pointer(pointer);
}
if(cmd.color()){

View File

@ -4,6 +4,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.mirror = null;
this.noise = null;
this.position_prev = null;
this.angle = null;
this.draw = function()
{
@ -43,7 +44,18 @@ function Pointer(offset = new Position(), color = new Color('000000'))
this.position = function()
{
if(this.mirror && this.mirror.width > 0){
if(this.angle){
var deltaX = ronin.brush.position.x - this.offset.x;
var deltaY = ronin.brush.position.y - this.offset.y;
var t = Math.atan2(deltaY, deltaX);
var radius = 45;
var x = Math.cos(t) * radius;
var y = Math.sin(t) * radius;
return new Position(x + this.offset.x,y + this.offset.y);
}
else if(this.mirror && this.mirror.width > 0){
return new Position(this.mirror.width - (ronin.brush.position.x + this.offset.x), 0 + (ronin.brush.position.y + this.offset.y));
}
else if(this.mirror && this.mirror.height > 0){

View File

@ -58,4 +58,12 @@ function Command(content)
}
return null;
}
this.angle = function()
{
for (i = 0; i < this.content.length; i++) {
if(this.content[i].indexOf("'") >= 0){ return parseFloat(this.content[i].replace('\'','')); }
}
return null;
}
}