Massive update, incl. dynamic documentation.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
function Brush()
|
||||
function Brush(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Position,Rect,Angle,Color,Value,Bang];
|
||||
this.pointers = [new Pointer(new Position())];
|
||||
|
@@ -1,9 +1,8 @@
|
||||
function Canvas(element)
|
||||
function Canvas(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Rect,Position,Color,Bang];
|
||||
this.element = element;
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
|
@@ -1,9 +1,8 @@
|
||||
function File()
|
||||
function FileLoad(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Filepath,Position,Rect,Bang];
|
||||
this.storage = [];
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
@@ -16,7 +15,7 @@ function File()
|
||||
var position = cmd.position() ? cmd.position() : new Position();
|
||||
|
||||
base_image = new Image();
|
||||
base_image.src = cmd.value() && this.storage[cmd.value().int] ? this.storage[cmd.value().int] : cmd.filepath().path;
|
||||
base_image.src = cmd.filepath().path;
|
||||
base_image.src += '?' + new Date().getTime();
|
||||
base_image.crossOrigin = "Anonymous";
|
||||
|
||||
@@ -49,16 +48,4 @@ function File()
|
||||
ronin.overlay.draw(position);
|
||||
}
|
||||
}
|
||||
|
||||
this.save = function(cmd)
|
||||
{
|
||||
if(cmd.value() && cmd.value().int > 0){
|
||||
this.storage[cmd.value().int] = ronin.canvas.element.toDataURL("image/png");
|
||||
}
|
||||
else{
|
||||
var d = ronin.canvas.element.toDataURL("image/png");
|
||||
var w = window.open('about:blank','image from canvas');
|
||||
w.document.write("<title>"+(cmd.content[0] ? cmd.content[0] : "Untitled")+"</title><img src='"+d+"' alt='from canvas'/>");
|
||||
}
|
||||
}
|
||||
}
|
19
scripts/modules/file.save.js
Normal file
19
scripts/modules/file.save.js
Normal file
@@ -0,0 +1,19 @@
|
||||
function FileSave(rune)
|
||||
{
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Any];
|
||||
|
||||
this.active = function(cmd)
|
||||
{
|
||||
var n = cmd.any().string[1];
|
||||
var f = cmd.variable("format");
|
||||
var d = ronin.canvas.element.toDataURL("image/png");
|
||||
var w = window.open('about:blank','image from canvas');
|
||||
w.document.write("<title>"+(n ? n : "Untitled")+"</title><img src='"+d+"'/>");
|
||||
}
|
||||
|
||||
this.passive = function(cmd)
|
||||
{
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
function Filter(element)
|
||||
function Filter(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Any];
|
||||
|
||||
|
47
scripts/modules/help.js
Normal file
47
scripts/modules/help.js
Normal file
@@ -0,0 +1,47 @@
|
||||
function Help(rune)
|
||||
{
|
||||
Module.call(this,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>");
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
this.view_modules = function()
|
||||
{
|
||||
html = " Modules\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 html;
|
||||
}
|
||||
|
||||
function pad(s,length)
|
||||
{
|
||||
if(!s){ return s; }
|
||||
|
||||
var new_string = s;
|
||||
while(new_string.length < length){
|
||||
new_string += " ";
|
||||
}
|
||||
return new_string;
|
||||
}
|
||||
}
|
@@ -1,9 +1,8 @@
|
||||
function Overlay(element)
|
||||
function Overlay(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Position,Rect];
|
||||
this.element = element;
|
||||
|
||||
// Module
|
||||
|
||||
@@ -102,6 +101,33 @@ function Overlay(element)
|
||||
this.context().closePath();
|
||||
}
|
||||
|
||||
// Live Draw(Ctrl)
|
||||
|
||||
this.live_draw_from = null;
|
||||
|
||||
this.live_draw_start = function(e)
|
||||
{
|
||||
this.clear();
|
||||
|
||||
this.draw_pointer(ronin.position_in_canvas(e));
|
||||
this.live_draw_from = ronin.position_in_canvas(e);
|
||||
commander.show();
|
||||
commander.element_input.focus();
|
||||
commander.element_input.value = "| "+this.live_draw_from.render();
|
||||
}
|
||||
|
||||
this.live_draw = function(e)
|
||||
{
|
||||
this.clear();
|
||||
|
||||
var rect = new Rect();
|
||||
rect.width = ronin.position_in_canvas(e).x - this.live_draw_from.x;
|
||||
rect.height = ronin.position_in_canvas(e).y - this.live_draw_from.y;
|
||||
|
||||
this.draw_rect(this.live_draw_from,rect);
|
||||
commander.element_input.value = "| "+this.live_draw_from.render()+" "+rect.render();
|
||||
}
|
||||
|
||||
this.resize = function(rect)
|
||||
{
|
||||
this.element.setAttribute('width',rect.width+"px");
|
||||
|
@@ -1,6 +1,6 @@
|
||||
function Stroke(element)
|
||||
function Stroke(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Any];
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
function Vector()
|
||||
function Vector(rune)
|
||||
{
|
||||
Module.call(this);
|
||||
Module.call(this,rune);
|
||||
|
||||
this.parameters = [Any,Position];
|
||||
|
||||
|
Reference in New Issue
Block a user