Progress toward Ronin source files.
This commit is contained in:
@@ -5,10 +5,7 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
this.position_prev = null;
|
||||
this.angle = null;
|
||||
this.distance = 0;
|
||||
|
||||
this.osc_scale = null;
|
||||
this.osc_rate = null;
|
||||
|
||||
|
||||
this.draw = function()
|
||||
{
|
||||
if(!this.position_prev){this.position_prev = this.position(); }
|
||||
@@ -18,12 +15,6 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
|
||||
this.distance += position.distance_to(this.position_prev);
|
||||
|
||||
// Osc experiment
|
||||
if(this.osc_rate && this.osc_scale){
|
||||
// position.x += (Math.sin(this.distance/(25 * this.osc_rate)) * this.osc_scale) - (this.osc_scale/2);
|
||||
position.y += (Math.sin(this.distance/(25 * this.osc_rate)) * this.osc_scale) - (this.osc_scale/2);
|
||||
}
|
||||
|
||||
ronin.canvas.context().beginPath();
|
||||
ronin.canvas.context().moveTo(this.position_prev.x,this.position_prev.y);
|
||||
ronin.canvas.context().lineTo(position.x,position.y);
|
||||
@@ -50,6 +41,8 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
|
||||
this.position = function()
|
||||
{
|
||||
return ronin.cursor.position;
|
||||
|
||||
if(this.angle){
|
||||
var angle_radian = this.angle.degrees * Math.PI / 180;
|
||||
var deltaX = ronin.brush.position.x - this.offset.x;
|
||||
@@ -66,6 +59,10 @@ function Pointer(offset = new Position(), color = new Color('000000'))
|
||||
else if(this.mirror && this.mirror.height > 0){
|
||||
return new Position((ronin.brush.position.x + this.offset.x), (2 * this.mirror.height) - (ronin.brush.position.y + this.offset.y));
|
||||
}
|
||||
|
||||
console.log(ronin.brush.position);
|
||||
console.log(this.offset);
|
||||
return;
|
||||
return new Position(ronin.brush.position.x + this.offset.x, ronin.brush.position.y + this.offset.y);
|
||||
}
|
||||
|
||||
|
@@ -5,8 +5,11 @@ function Help(rune)
|
||||
this.active = function(cmd)
|
||||
{
|
||||
var w = window.open('about:blank','image from canvas');
|
||||
var html = this.view_modules();
|
||||
w.document.write("<title>Help</title><style>body { font-size:11px;background:#555; color:#ccc; padding:50px}</style><pre>"+html+"</pre>");
|
||||
var html = "";
|
||||
html += this.view_modules();
|
||||
html += this.view_cursors();
|
||||
html += "<hr />"
|
||||
w.document.write("<title>Help</title><style>body { font-size:11px;background:#555; color:#ccc; padding:50px} pre { width:300px; float:left} hr { clear:both}</style>"+html+"");
|
||||
}
|
||||
|
||||
//
|
||||
@@ -31,7 +34,30 @@ function Help(rune)
|
||||
html += "\n"
|
||||
});
|
||||
|
||||
return html;
|
||||
return "<pre>"+html+"</pre>";
|
||||
}
|
||||
|
||||
this.view_cursors = function()
|
||||
{
|
||||
html = " Cursors\n\n";
|
||||
// Object.keys(ronin.modules).forEach(function (key) {
|
||||
// html += key+" <b>"+ronin.modules[key].constructor.name+"</b>\n";
|
||||
// html += ""
|
||||
// for (i = 0; i < ronin.modules[key].parameters.length; i++) {
|
||||
// html += " "+pad(ronin.modules[key].parameters[i].name,14);
|
||||
// html += pad(new ronin.modules[key].parameters[i]().example,14)+" \n";
|
||||
// }
|
||||
// for (i = 0; i < ronin.modules[key].variables.length; i++) {
|
||||
// html += " "+pad(ronin.modules[key].variables[i].key,14)+"= ";
|
||||
// for (c = 0; c < ronin.modules[key].variables[i].candidates.length; c++) {
|
||||
// html += ronin.modules[key].variables[i].candidates[c]+" ";
|
||||
// }
|
||||
// html += "\n";
|
||||
// }
|
||||
// html += "\n"
|
||||
// });
|
||||
|
||||
return "<pre>"+html+"</pre>";
|
||||
}
|
||||
|
||||
function pad(s,length)
|
||||
|
22
scripts/modules/history.js
Normal file
22
scripts/modules/history.js
Normal file
@@ -0,0 +1,22 @@
|
||||
function History(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.lines = [];
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
console.log(this.lines);
|
||||
}
|
||||
|
||||
this.add = function(content)
|
||||
{
|
||||
this.lines.push(content);
|
||||
}
|
||||
|
||||
this.widget = function()
|
||||
{
|
||||
if(this.lines.length === 0){ return "";}
|
||||
return "; "+this.lines.length+" ";
|
||||
}
|
||||
}
|
@@ -4,6 +4,30 @@ function Stroke(rune)
|
||||
|
||||
this.parameters = [Any];
|
||||
|
||||
// Create a stroke
|
||||
|
||||
this.positions = null;
|
||||
|
||||
this.new_stroke = function()
|
||||
{
|
||||
this.positions = [];
|
||||
}
|
||||
|
||||
this.append_stroke = function(p)
|
||||
{
|
||||
this.positions.push(p);
|
||||
}
|
||||
|
||||
this.save_stroke = function()
|
||||
{
|
||||
s = "_ ";
|
||||
for (i = 0; i < this.positions.length; i++) {
|
||||
s += this.positions[i].render()+" ";
|
||||
}
|
||||
this.positions = null;
|
||||
ronin.history.add(s);
|
||||
}
|
||||
|
||||
// Module
|
||||
|
||||
this.passive = function(cmd)
|
||||
@@ -12,23 +36,26 @@ function Stroke(rune)
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
// TODO
|
||||
|
||||
var origin = new Position(cmd.content[0]);
|
||||
var destination = new Position(cmd.content[1]);
|
||||
|
||||
var e = {};
|
||||
e.clientX = origin.x;
|
||||
e.clientY = origin.y;
|
||||
|
||||
ronin.brush.is_drawing = true;
|
||||
ronin.brush.draw(e);
|
||||
|
||||
e.clientX = destination.x;
|
||||
e.clientY = destination.y;
|
||||
|
||||
ronin.brush.draw(e);
|
||||
ronin.brush.is_drawing = false;
|
||||
var prev = null
|
||||
for (i = 1; i < cmd.content.length; i++) {
|
||||
var p = new Position(cmd.content[i]);
|
||||
if(prev){
|
||||
this.draw(prev,p);
|
||||
}
|
||||
prev = p;
|
||||
}
|
||||
}
|
||||
|
||||
this.draw = function(pos1,pos2)
|
||||
{
|
||||
ronin.canvas.context().beginPath();
|
||||
ronin.canvas.context().moveTo(pos1.x,pos1.y);
|
||||
ronin.canvas.context().lineTo(pos2.x,pos2.y);
|
||||
ronin.canvas.context().lineCap="round";
|
||||
ronin.canvas.context().lineWidth = 1;
|
||||
ronin.canvas.context().strokeStyle = new Color("#ff0000").rgba();
|
||||
ronin.canvas.context().stroke();
|
||||
ronin.canvas.context().closePath();
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user