Massive update, incl. dynamic documentation.

This commit is contained in:
Devine Lu Linvega
2016-12-09 05:22:55 -07:00
parent c32c009256
commit 78b2d13de8
27 changed files with 222 additions and 188 deletions

View File

@@ -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())];

View File

@@ -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)
{

View File

@@ -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'/>");
}
}
}

View 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)
{
}
}

View File

@@ -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
View 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;
}
}

View File

@@ -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");

View File

@@ -1,6 +1,6 @@
function Stroke(element)
function Stroke(rune)
{
Module.call(this);
Module.call(this,rune);
this.parameters = [Any];

View File

@@ -1,6 +1,6 @@
function Vector()
function Vector(rune)
{
Module.call(this);
Module.call(this,rune);
this.parameters = [Any,Position];