Progress on magnet
This commit is contained in:
parent
22e364ef5a
commit
85d0b4b3a2
@ -7,11 +7,6 @@ function Cursor(rune)
|
|||||||
|
|
||||||
this.mode = "vertex";
|
this.mode = "vertex";
|
||||||
|
|
||||||
// default vertex
|
|
||||||
// shift rect
|
|
||||||
// alt -> arc_to_clockwise
|
|
||||||
// ctrl -> arc_to_counterclockwise
|
|
||||||
|
|
||||||
this.mouse_down = function(e)
|
this.mouse_down = function(e)
|
||||||
{
|
{
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -4,27 +4,27 @@ function Grid()
|
|||||||
|
|
||||||
this.el.id = "grid";
|
this.el.id = "grid";
|
||||||
|
|
||||||
this.draw = function()
|
this.draw = function(size = 60, step = 5)
|
||||||
{
|
{
|
||||||
var size = 60;
|
|
||||||
var x = 1;
|
var x = 1;
|
||||||
while(x < this.el.width/size){
|
while(x < this.el.width/size){
|
||||||
var y = 1;
|
var y = 1;
|
||||||
while(y < (this.el.height/size)-1){
|
while(y < (this.el.height/size)-1){
|
||||||
this.draw_vertex(x * size,y * size)
|
var is_marker = (x % step == 0 && y % step == 0)
|
||||||
|
this.draw_vertex(x * size,y * size,is_marker)
|
||||||
y += 1;
|
y += 1;
|
||||||
}
|
}
|
||||||
x += 1;
|
x += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.draw_vertex = function(x,y)
|
this.draw_vertex = function(x,y,is_marker)
|
||||||
{
|
{
|
||||||
var ctx = this.context();
|
var ctx = this.context();
|
||||||
var r = 1.5;
|
var r = 1.5;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(x, y, 1.5, 0, 2 * Math.PI, false);
|
ctx.arc(x, y, 1.5, 0, 2 * Math.PI, false);
|
||||||
ctx.fillStyle = '#ccc';
|
ctx.fillStyle = is_marker ? '#000' : '#ccc';
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,19 @@ function Magnet()
|
|||||||
|
|
||||||
this.settings = {size:15,rate:4};
|
this.settings = {size:15,rate:4};
|
||||||
|
|
||||||
this.methods.lock = function()
|
this.methods.lock = function(q)
|
||||||
{
|
{
|
||||||
|
var size = parseInt(q);
|
||||||
|
|
||||||
|
if(size < 5){ return; }
|
||||||
|
|
||||||
|
console.log(size)
|
||||||
|
|
||||||
|
ronin.grid.draw(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.methods.unlock = function(q)
|
||||||
|
{
|
||||||
|
console.log(q)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -69,6 +69,7 @@ function Ronin()
|
|||||||
this.guide.update();
|
this.guide.update();
|
||||||
|
|
||||||
// this.commander.input_el.value = "io import:~/Desktop/test.png anchor=$";
|
// this.commander.input_el.value = "io import:~/Desktop/test.png anchor=$";
|
||||||
this.commander.input_el.value = "path stroke:$+";
|
// this.commander.input_el.value = "path stroke:$+";
|
||||||
|
this.commander.input_el.value = "magnet lock:";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user