Added better brushes params.

This commit is contained in:
Devine Lu Linvega 2016-11-12 09:49:45 -08:00
parent 8a99bc5bb7
commit 8ff8e8e7ec
7 changed files with 34 additions and 2 deletions

View File

@ -26,4 +26,7 @@ $ new_name.jpg
Cursors
= 10
] += 1
[ -= 1
[ -= 1
Formatting
; Split into multiple commands

View File

@ -2,6 +2,7 @@
<head>
<link rel="stylesheet" type="text/css" href="links/main.css"/>
<script type="text/javascript" src="scripts/position.js"></script>
<script type="text/javascript" src="scripts/color.js"></script>
<script type="text/javascript" src="scripts/pointer.js"></script>
<script type="text/javascript" src="scripts/brush.js"></script>
<script type="text/javascript" src="scripts/keyboard.js"></script>

View File

@ -3,6 +3,15 @@ function Brush()
this.position = new Position();
this.is_drawing = false;
// Commander
this.command = function(p)
{
var position = new Position(parseInt(p[0]),parseInt(p[1]));
var pointer = new Pointer(position);
brush.add_pointer(pointer);
}
// Pointers
this.pointers = [new Pointer(new Position(0,0))];

7
scripts/color.js Normal file
View File

@ -0,0 +1,7 @@
function Color()
{
this.hex = function()
{
return '#ff0000';
}
}

View File

@ -19,11 +19,17 @@ function Commander(element,element_input)
{
var parts = this.element_input.value.split(" ");
// Canvas
if(parts[0] == ":@"){
canvas.style.width = parts[1]+"px";
canvas.style.height = parts[2]+"px";
}
// Brush
if(parts[0] == ":+"){
brush.command(parts.shift());
}
this.hide();
}

View File

@ -1,6 +1,7 @@
function Pointer(offset = new Position())
function Pointer(offset = new Position(), color = new Color())
{
this.offset = offset;
this.color = color;
this.mirror = null;
this.position_prev = null;
@ -21,6 +22,10 @@ function Pointer(offset = new Position())
context.beginPath();
context.moveTo(this.position_prev.x,this.position_prev.y);
context.lineTo(this.position().x,this.position().y);
context.lineCap="round";
var thick = 100 - ((this.position().distance_to(this.position_prev)));
context.lineWidth = thick/20;
context.strokeStyle = this.color.hex();
context.stroke();
this.position_prev = this.position();

View File

@ -5,6 +5,7 @@ function Position(x = 0,y = 0)
this.distance_to = function(target)
{
if(!target){ return 0; }
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
}
}