Progress on layers

This commit is contained in:
Devine Lu Linvega
2018-02-07 07:42:34 +13:00
parent 8bf586c283
commit 2cf8005706
2 changed files with 58 additions and 22 deletions

View File

@@ -40,6 +40,20 @@ function Tool()
this.verteces.push(pos);
}
this.vertex_at = function(pos)
{
for(segment_id in this.layer()){
var segment = this.layer()[segment_id];
for(vertex_id in segment.verteces){
var vertex = segment.verteces[vertex_id];
if(vertex.x == Math.abs(pos.x) && vertex.y == Math.abs(pos.y)){
return vertex;
}
}
}
return null;
}
this.cast = function(type)
{
if(!this.layer()){ this.layers[this.index] = []; }
@@ -78,6 +92,11 @@ function Tool()
return html
}
this.paths = function()
{
return [this.path(this.layers[0]),this.path(this.layers[1]),this.path(this.layers[2])]
}
this.render = function(segment)
{
var type = segment.type;
@@ -110,20 +129,6 @@ function Tool()
return html
}
this.vertex_at = function(pos)
{
for(segment_id in this.layer()){
var segment = this.layer()[segment_id];
for(vertex_id in segment.verteces){
var vertex = segment.verteces[vertex_id];
if(vertex.x == Math.abs(pos.x) && vertex.y == Math.abs(pos.y)){
return vertex;
}
}
}
return null;
}
this.translate = function(a,b)
{
for(segment_id in this.layer()){
@@ -170,4 +175,20 @@ function Tool()
this.clear();
dotgrid.draw();
}
this.layer_up = function()
{
this.index -= this.index > 0 ? 1 : 0;
this.clear();
dotgrid.draw();
console.log(`layer:${this.index}`)
}
this.layer_down = function()
{
this.index += this.index < 2 ? 1 : 0;
this.clear();
dotgrid.draw();
console.log(`layer:${this.index}`)
}
}