Added cursor drag
This commit is contained in:
@@ -83,6 +83,20 @@ function Brush()
|
||||
}
|
||||
}
|
||||
|
||||
this.erase = function(line)
|
||||
{
|
||||
var ctx = ronin.render.context();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.globalCompositeOperation="destination-out";
|
||||
ctx.moveTo(line.from.x * 2,line.from.y * 2);
|
||||
ctx.lineTo(line.to.x * 2,line.to.y * 2);
|
||||
ctx.lineCap="round";
|
||||
ctx.lineWidth = this.thickness(line);
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
this.mod_size = function(mod)
|
||||
{
|
||||
this.settings.size = clamp(this.settings.size+mod,1,100);
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
function Eraser()
|
||||
{
|
||||
Module.call(this,"eraser");
|
||||
|
||||
this.thickness = function(line)
|
||||
{
|
||||
return ronin.brush.thickness(line);
|
||||
}
|
||||
|
||||
this.stroke = function(line)
|
||||
{
|
||||
var ctx = ronin.render.context();
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.globalCompositeOperation="destination-out";
|
||||
ctx.moveTo(line.from.x * 2,line.from.y * 2);
|
||||
ctx.lineTo(line.to.x * 2,line.to.y * 2);
|
||||
ctx.lineCap="round";
|
||||
ctx.lineWidth = this.thickness(line);
|
||||
ctx.stroke();
|
||||
ctx.closePath();
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ function IO()
|
||||
this.render = function()
|
||||
{
|
||||
var fs = require('fs');
|
||||
var data = ronin.render.to_data().replace(/^data:image\/\w+;base64,/, "");
|
||||
var data = ronin.render.to_base64().replace(/^data:image\/\w+;base64,/, "");
|
||||
var buf = new Buffer(data, 'base64');
|
||||
|
||||
dialog.showSaveDialog((fileName) => {
|
||||
|
||||
@@ -2,26 +2,29 @@ function Magnet()
|
||||
{
|
||||
Module.call(this,"magnet","Cursor magnetisation settings.");
|
||||
|
||||
this.settings = {size:15,rate:4};
|
||||
this.settings = {size:0,step:4};
|
||||
|
||||
this.methods.lock = function(q)
|
||||
{
|
||||
var size = parseInt(q);
|
||||
|
||||
if(size < 5){ return; }
|
||||
if(size < 5){ this.unlock(); return; }
|
||||
|
||||
console.log(size)
|
||||
|
||||
ronin.grid.draw(size);
|
||||
ronin.grid.draw(size,ronin.magnet.settings.step);
|
||||
}
|
||||
|
||||
this.methods.unlock = function(q)
|
||||
{
|
||||
console.log(q)
|
||||
ronin.magnet.settings.size = 0;
|
||||
ronin.grid.clear();
|
||||
}
|
||||
|
||||
this.filter = function(pos)
|
||||
{
|
||||
if(this.settings.size < 5){
|
||||
return pos;
|
||||
}
|
||||
|
||||
var s = this.settings.size;
|
||||
return {x:parseInt(pos.x/s)*s,y:parseInt(pos.y/s)*s};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ function Path()
|
||||
{
|
||||
Module.call(this,"path");
|
||||
|
||||
this.settings = {thickness:30,color:"black",cap:"square"};
|
||||
|
||||
this.methods.stroke = function(q)
|
||||
{
|
||||
ronin.preview.clear();
|
||||
@@ -32,9 +34,9 @@ function Path()
|
||||
|
||||
var ctx = ronin.preview.context();
|
||||
ctx.beginPath();
|
||||
ctx.lineCap = "butt";
|
||||
ctx.lineWidth = 30;
|
||||
ctx.strokeStyle = "black";
|
||||
ctx.lineCap = q.settings.cap ? q.settings.cap : ronin.path.settings.cap;
|
||||
ctx.lineWidth = q.settings.thickness ? q.settings.thickness : ronin.path.settings.thickness;
|
||||
ctx.strokeStyle = q.settings.color ? q.settings.color : ronin.path.settings.color;
|
||||
ctx.stroke(new Path2D(path));
|
||||
ctx.closePath();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user