Progress on radial brush.
This commit is contained in:
parent
b473437de5
commit
fd4428aafa
@ -28,6 +28,7 @@ $ ! ; Clear temporary storage
|
|||||||
> 10,0 ; Add pointer at pos
|
> 10,0 ; Add pointer at pos
|
||||||
> 400x0 ; Add mirror pointer, at 400x
|
> 400x0 ; Add mirror pointer, at 400x
|
||||||
> 4 #ff0000 ; Red brush, Size 4
|
> 4 #ff0000 ; Red brush, Size 4
|
||||||
|
> 100,100 45' ; Radial brush from position x,y and 45 degrees
|
||||||
> ! ; Remove all pointers
|
> ! ; Remove all pointers
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ function Brush()
|
|||||||
var pointer = new Pointer();
|
var pointer = new Pointer();
|
||||||
|
|
||||||
if(cmd.position()){
|
if(cmd.position()){
|
||||||
pointer.position = cmd.position();
|
pointer.offset = cmd.position();
|
||||||
}
|
}
|
||||||
if(cmd.rect()){
|
if(cmd.rect()){
|
||||||
pointer.mirror = cmd.rect();
|
pointer.mirror = cmd.rect();
|
||||||
@ -27,7 +27,10 @@ function Brush()
|
|||||||
if(cmd.noise()){
|
if(cmd.noise()){
|
||||||
pointer.noise = 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);
|
this.add_pointer(pointer);
|
||||||
}
|
}
|
||||||
if(cmd.color()){
|
if(cmd.color()){
|
||||||
|
@ -4,6 +4,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
|||||||
this.mirror = null;
|
this.mirror = null;
|
||||||
this.noise = null;
|
this.noise = null;
|
||||||
this.position_prev = null;
|
this.position_prev = null;
|
||||||
|
this.angle = null;
|
||||||
|
|
||||||
this.draw = function()
|
this.draw = function()
|
||||||
{
|
{
|
||||||
@ -43,7 +44,18 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
|||||||
|
|
||||||
this.position = function()
|
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));
|
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){
|
else if(this.mirror && this.mirror.height > 0){
|
||||||
|
@ -58,4 +58,12 @@ function Command(content)
|
|||||||
}
|
}
|
||||||
return null;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user