Added icons

This commit is contained in:
Devine Lu Linvega
2017-01-12 15:37:22 -07:00
parent 2499f805ba
commit a2fed4c21e
65 changed files with 1 additions and 0 deletions

View File

View 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+"'";
}
}

View File

@@ -0,0 +1,12 @@
function Any(str)
{
Unit.call(this);
this.example = "";
this.string = str;
this.render = function()
{
return this.string;
}
}

View File

@@ -0,0 +1,11 @@
function Bang()
{
Unit.call(this);
this.example = "";
this.render = function()
{
return "BANG";
}
}

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

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

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

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

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

View File

@@ -0,0 +1,9 @@
function Unit()
{
this.example = "unknown";
this.render = function()
{
return "[MISSING]";
}
}

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

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