diff --git a/sources/index.html b/sources/index.html index b415981..0b1dad2 100644 --- a/sources/index.html +++ b/sources/index.html @@ -1,17 +1,18 @@ + + + + + - - - - diff --git a/sources/scripts/hint.js b/sources/scripts/hint.js index e1e543f..98ee06c 100644 --- a/sources/scripts/hint.js +++ b/sources/scripts/hint.js @@ -11,7 +11,13 @@ function Hint() this.update = function(e = null) { - this.el.innerHTML = this.pad(ronin.commander.input_el.value)+"brush:"+ronin.brush.settings.size+"&"+ronin.brush.settings.color+""; + var html = "" + + for(module_id in ronin.modules){ + var module = ronin.modules[module_id]; + html += module.hint()+" "; + } + this.el.innerHTML = this.pad(ronin.commander.input_el.value)+html; } this.pad = function(input) diff --git a/sources/scripts/module.js b/sources/scripts/module.js new file mode 100644 index 0000000..40fa335 --- /dev/null +++ b/sources/scripts/module.js @@ -0,0 +1,16 @@ +function Module(name) +{ + this.name = name; + + this.hint = function() + { + var html = ""; + + for(setting_id in this.settings){ + var setting_value = this.settings[setting_id]; + html += setting_id+"="+setting_value+" "; + } + + return this.name+"["+html.trim()+"]"; + } +} \ No newline at end of file diff --git a/sources/scripts/brush.js b/sources/scripts/modules/brush.js similarity index 81% rename from sources/scripts/brush.js rename to sources/scripts/modules/brush.js index b9d6caf..89fb14c 100644 --- a/sources/scripts/brush.js +++ b/sources/scripts/modules/brush.js @@ -1,5 +1,7 @@ function Brush() { + Module.call(this,"brush"); + this.settings = {size:10,color:"#f00"}; this.thickness = function(line) @@ -26,7 +28,12 @@ function Brush() this.mod_size = function(mod) { - this.settings.size += mod; + this.settings.size = clamp(this.settings.size+mod,1,100); + } + + function clamp(v, min, max) + { + return v < min ? min : v > max ? max : v; } function distance_between(a,b) diff --git a/sources/scripts/eraser.js b/sources/scripts/modules/eraser.js similarity index 93% rename from sources/scripts/eraser.js rename to sources/scripts/modules/eraser.js index 32beb91..d78e176 100644 --- a/sources/scripts/eraser.js +++ b/sources/scripts/modules/eraser.js @@ -1,5 +1,7 @@ function Eraser() { + Module.call(this,"eraser"); + this.thickness = function(line) { return ronin.brush.thickness(line); diff --git a/sources/scripts/modules/frame.js b/sources/scripts/modules/frame.js new file mode 100644 index 0000000..5e1ca3d --- /dev/null +++ b/sources/scripts/modules/frame.js @@ -0,0 +1,4 @@ +function Frame() +{ + Module.call(this,"frame"); +} \ No newline at end of file diff --git a/sources/scripts/ronin.js b/sources/scripts/ronin.js index 81bb4aa..672f67f 100644 --- a/sources/scripts/ronin.js +++ b/sources/scripts/ronin.js @@ -8,13 +8,16 @@ function Ronin() this.commander = new Commander(); this.cursor = new Cursor(); this.render = new Render(); - this.brush = new Brush(); - this.eraser = new Eraser(); this.hint = new Hint(); + this.brush = new Brush(); + this.eraser = new Eraser(); + this.frame = new Frame(); + this.modules = { - rescale : new Rescale(), brush : this.brush, + eraser : this.eraser, + frame : this.frame, }; this.install = function()