Added better brushes params.
This commit is contained in:
		@@ -26,4 +26,7 @@ $ new_name.jpg
 | 
				
			|||||||
  Cursors
 | 
					  Cursors
 | 
				
			||||||
= 10
 | 
					= 10
 | 
				
			||||||
] += 1
 | 
					] += 1
 | 
				
			||||||
[ -= 1
 | 
					[ -= 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Formatting
 | 
				
			||||||
 | 
					; Split into multiple commands
 | 
				
			||||||
@@ -2,6 +2,7 @@
 | 
				
			|||||||
  <head>
 | 
					  <head>
 | 
				
			||||||
    <link rel="stylesheet" type="text/css" href="links/main.css"/>
 | 
					    <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/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/pointer.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="scripts/brush.js"></script>
 | 
					    <script type="text/javascript" src="scripts/brush.js"></script>
 | 
				
			||||||
    <script type="text/javascript" src="scripts/keyboard.js"></script>
 | 
					    <script type="text/javascript" src="scripts/keyboard.js"></script>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,6 +3,15 @@ function Brush()
 | 
				
			|||||||
  this.position = new Position();
 | 
					  this.position = new Position();
 | 
				
			||||||
  this.is_drawing = false;
 | 
					  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
 | 
					  // Pointers
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  this.pointers = [new Pointer(new Position(0,0))];
 | 
					  this.pointers = [new Pointer(new Position(0,0))];
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								scripts/color.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								scripts/color.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					function Color()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  this.hex = function()
 | 
				
			||||||
 | 
					  {
 | 
				
			||||||
 | 
					    return '#ff0000';
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -19,11 +19,17 @@ function Commander(element,element_input)
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    var parts = this.element_input.value.split(" ");
 | 
					    var parts = this.element_input.value.split(" ");
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    // Canvas
 | 
				
			||||||
    if(parts[0] == ":@"){
 | 
					    if(parts[0] == ":@"){
 | 
				
			||||||
      canvas.style.width = parts[1]+"px";
 | 
					      canvas.style.width = parts[1]+"px";
 | 
				
			||||||
      canvas.style.height = parts[2]+"px";
 | 
					      canvas.style.height = parts[2]+"px";
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
 | 
					    // Brush
 | 
				
			||||||
 | 
					    if(parts[0] == ":+"){
 | 
				
			||||||
 | 
					      brush.command(parts.shift());
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    this.hide();
 | 
					    this.hide();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
function Pointer(offset = new Position())
 | 
					function Pointer(offset = new Position(), color = new Color())
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  this.offset = offset;
 | 
					  this.offset = offset;
 | 
				
			||||||
 | 
					  this.color = color;
 | 
				
			||||||
  this.mirror = null;
 | 
					  this.mirror = null;
 | 
				
			||||||
  this.position_prev = null;
 | 
					  this.position_prev = null;
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -21,6 +22,10 @@ function Pointer(offset = new Position())
 | 
				
			|||||||
    context.beginPath();
 | 
					    context.beginPath();
 | 
				
			||||||
    context.moveTo(this.position_prev.x,this.position_prev.y);
 | 
					    context.moveTo(this.position_prev.x,this.position_prev.y);
 | 
				
			||||||
    context.lineTo(this.position().x,this.position().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();
 | 
					    context.stroke();
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    this.position_prev = this.position();
 | 
					    this.position_prev = this.position();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,6 +5,7 @@ function Position(x = 0,y = 0)
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  this.distance_to = function(target)
 | 
					  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) );
 | 
					    return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user