Added icons
This commit is contained in:
0
sources/scripts/units/Icon
Normal file
0
sources/scripts/units/Icon
Normal file
13
sources/scripts/units/angle.js
Normal file
13
sources/scripts/units/angle.js
Normal file
@@ -0,0 +1,13 @@
|
||||
function Angle(angle_str = "0'")
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "45'";
|
||||
|
||||
this.degrees = parseFloat(angle_str.replace('\'',''));
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.degrees+"'";
|
||||
}
|
||||
}
|
||||
12
sources/scripts/units/any.js
Normal file
12
sources/scripts/units/any.js
Normal file
@@ -0,0 +1,12 @@
|
||||
function Any(str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "";
|
||||
this.string = str;
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.string;
|
||||
}
|
||||
}
|
||||
11
sources/scripts/units/bang.js
Normal file
11
sources/scripts/units/bang.js
Normal file
@@ -0,0 +1,11 @@
|
||||
function Bang()
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "";
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return "BANG";
|
||||
}
|
||||
}
|
||||
32
sources/scripts/units/color.js
Normal file
32
sources/scripts/units/color.js
Normal file
@@ -0,0 +1,32 @@
|
||||
function Color(hex = '#000000')
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "#ff0000";
|
||||
this.hex = hex;
|
||||
|
||||
this.rgb = function()
|
||||
{
|
||||
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(this.hex);
|
||||
return result ? {
|
||||
r: parseInt(result[1], 16),
|
||||
g: parseInt(result[2], 16),
|
||||
b: parseInt(result[3], 16)
|
||||
} : null;
|
||||
}
|
||||
|
||||
this.rgba = function()
|
||||
{
|
||||
return "rgba("+this.rgb().r+","+this.rgb().g+","+this.rgb().b+",1)";
|
||||
}
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.hex;
|
||||
}
|
||||
|
||||
this.rgb_to_hex = function(rgb)
|
||||
{
|
||||
return "#"+("0" + parseInt(rgb[0],10).toString(16)).slice(-2)+("0" + parseInt(rgb[1],10).toString(16)).slice(-2)+("0" + parseInt(rgb[2],10).toString(16)).slice(-2);
|
||||
}
|
||||
}
|
||||
12
sources/scripts/units/filepath.js
Normal file
12
sources/scripts/units/filepath.js
Normal file
@@ -0,0 +1,12 @@
|
||||
function Filepath(path_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "assets/demo.png";
|
||||
this.path = path_str;
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.path;
|
||||
}
|
||||
}
|
||||
42
sources/scripts/units/position.js
Normal file
42
sources/scripts/units/position.js
Normal file
@@ -0,0 +1,42 @@
|
||||
function Position(position_str = "0,0",y = null)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "100,150";
|
||||
this.position_str = position_str;
|
||||
|
||||
this.x = y != null ? position_str : parseFloat(this.position_str.split(",")[0]);
|
||||
this.y = y != null ? y : parseFloat(this.position_str.split(",")[1]);
|
||||
|
||||
this.add = function(position)
|
||||
{
|
||||
return new Position(this.x + position.x, this.y + position.y);
|
||||
}
|
||||
|
||||
this.is_equal = function(target)
|
||||
{
|
||||
if(target.x == this.x && target.y == this.y){ return true; }
|
||||
return null;
|
||||
}
|
||||
|
||||
this.distance_to = function(target)
|
||||
{
|
||||
if(!target){ return 0; }
|
||||
return Math.sqrt( (this.x-target.x)*(this.x-target.x) + (this.y-target.y)*(this.y-target.y) );
|
||||
}
|
||||
|
||||
this.normalize = function(rect)
|
||||
{
|
||||
if(this.x < 0){
|
||||
this.x = ronin.canvas.element.width - rect.width - Math.abs(this.x);
|
||||
}
|
||||
if(this.y < 0){
|
||||
this.y = ronin.canvas.element.height - rect.height - Math.abs(this.y);
|
||||
}
|
||||
}
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return (isNaN(this.x) ? 0 : this.x)+","+(isNaN(this.y) ? 0 : this.y);
|
||||
}
|
||||
}
|
||||
15
sources/scripts/units/range.js
Normal file
15
sources/scripts/units/range.js
Normal file
@@ -0,0 +1,15 @@
|
||||
function Range(range_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "10..50";
|
||||
this.range_str = range_str;
|
||||
|
||||
this.from = parseFloat(this.range_str.split("..")[0]);
|
||||
this.to = parseFloat(this.range_str.split("..")[1]);
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.from+".."+this.to;
|
||||
}
|
||||
}
|
||||
15
sources/scripts/units/rect.js
Normal file
15
sources/scripts/units/rect.js
Normal file
@@ -0,0 +1,15 @@
|
||||
function Rect(rect_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "200x300";
|
||||
this.rect_str = rect_str;
|
||||
|
||||
this.width = rect_str ? parseFloat(this.rect_str.split("x")[0]) : 0;
|
||||
this.height = rect_str ? parseFloat(this.rect_str.split("x")[1]) : 0;
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return (isNaN(this.width) ? 0 : this.width)+"x"+(isNaN(this.height) ? 0 : this.height);
|
||||
}
|
||||
}
|
||||
9
sources/scripts/units/unit.js
Normal file
9
sources/scripts/units/unit.js
Normal file
@@ -0,0 +1,9 @@
|
||||
function Unit()
|
||||
{
|
||||
this.example = "unknown";
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return "[MISSING]";
|
||||
}
|
||||
}
|
||||
14
sources/scripts/units/value.js
Normal file
14
sources/scripts/units/value.js
Normal file
@@ -0,0 +1,14 @@
|
||||
function Value(value_str)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.example = "20";
|
||||
this.value = value_str;
|
||||
this.float = parseFloat(this.value);
|
||||
this.int = parseInt(this.value);
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
16
sources/scripts/units/variable.js
Normal file
16
sources/scripts/units/variable.js
Normal file
@@ -0,0 +1,16 @@
|
||||
function Variable(key,value)
|
||||
{
|
||||
Unit.call(this);
|
||||
|
||||
this.candidates = [];
|
||||
this.key = key;
|
||||
|
||||
if(value == "true"){ this.value = true; }
|
||||
else if(value == "false"){ this.value = false; }
|
||||
else{ this.value = value; }
|
||||
|
||||
this.render = function()
|
||||
{
|
||||
return this.key+"="+this.value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user