Moved scaling stuff into a module
This commit is contained in:
parent
c23b96ca3a
commit
bbe469d29b
@ -1,17 +1,18 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="scripts/module.js"></script>
|
||||
<script type="text/javascript" src="scripts/modules/frame.js"></script>
|
||||
<script type="text/javascript" src="scripts/modules/brush.js"></script>
|
||||
<script type="text/javascript" src="scripts/modules/eraser.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/io.js"></script>
|
||||
<script type="text/javascript" src="scripts/query.js"></script>
|
||||
<script type="text/javascript" src="scripts/keyboard.js"></script>
|
||||
<script type="text/javascript" src="scripts/cursor.js"></script>
|
||||
<script type="text/javascript" src="scripts/brush.js"></script>
|
||||
<script type="text/javascript" src="scripts/eraser.js"></script>
|
||||
<script type="text/javascript" src="scripts/hint.js"></script>
|
||||
<script type="text/javascript" src="scripts/render.js"></script>
|
||||
<script type="text/javascript" src="scripts/commander.js"></script>
|
||||
<script type="text/javascript" src="scripts/ronin.js"></script>
|
||||
|
||||
<script type="text/javascript" src="scripts/modules/rescale.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="links/reset.css"/>
|
||||
<link rel="stylesheet" type="text/css" href="links/fonts.css"/>
|
||||
|
@ -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)
|
||||
|
16
sources/scripts/module.js
Normal file
16
sources/scripts/module.js
Normal file
@ -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()+"]";
|
||||
}
|
||||
}
|
@ -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)
|
@ -1,5 +1,7 @@
|
||||
function Eraser()
|
||||
{
|
||||
Module.call(this,"eraser");
|
||||
|
||||
this.thickness = function(line)
|
||||
{
|
||||
return ronin.brush.thickness(line);
|
4
sources/scripts/modules/frame.js
Normal file
4
sources/scripts/modules/frame.js
Normal file
@ -0,0 +1,4 @@
|
||||
function Frame()
|
||||
{
|
||||
Module.call(this,"frame");
|
||||
}
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user