Progress on cleanup
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
function Tool()
|
||||
{
|
||||
this.layer = 0;
|
||||
this.index = 0;
|
||||
this.layers = [];
|
||||
this.verteces = [];
|
||||
|
||||
this.layer = function()
|
||||
{
|
||||
console.log(this.layers)
|
||||
if(!this.layers[this.index]){
|
||||
this.layers[this.index] = [];
|
||||
}
|
||||
return this.layers[this.index];
|
||||
}
|
||||
|
||||
this.remove_segment = function()
|
||||
{
|
||||
this.layers[this.layer].pop();
|
||||
this.layer().pop();
|
||||
this.clear();
|
||||
dotgrid.draw();
|
||||
}
|
||||
@@ -19,21 +28,21 @@ function Tool()
|
||||
|
||||
this.cast = function(type)
|
||||
{
|
||||
if(!this.layers[this.layer]){ this.layers[this.layer] = []; }
|
||||
if(!this.layer()){ this.layers[this.index] = []; }
|
||||
|
||||
this.layers[this.layer].push({type:type,verteces:this.verteces.slice()})
|
||||
this.layer().push({type:type,verteces:this.verteces.slice()})
|
||||
this.clear();
|
||||
dotgrid.draw();
|
||||
|
||||
console.log(`Casted ${type}+${this.layers[this.layer].length}`);
|
||||
console.log(`Casted ${type}+${this.layer().length}`);
|
||||
}
|
||||
|
||||
this.path = function()
|
||||
{
|
||||
var html = "";
|
||||
|
||||
for(id in this.layers[this.layer]){
|
||||
var segment = this.layers[this.layer][id];
|
||||
for(id in this.layer()){
|
||||
var segment = this.layer()[id];
|
||||
html += this.render(segment);
|
||||
}
|
||||
return html
|
||||
@@ -56,8 +65,8 @@ function Tool()
|
||||
|
||||
this.vertex_at = function(pos)
|
||||
{
|
||||
for(segment_id in this.layers[this.layer]){
|
||||
var segment = this.layers[this.layer][segment_id];
|
||||
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)){
|
||||
@@ -70,8 +79,8 @@ function Tool()
|
||||
|
||||
this.translate = function(a,b)
|
||||
{
|
||||
for(segment_id in this.layers[this.layer]){
|
||||
var segment = this.layers[this.layer][segment_id];
|
||||
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(a.x) && vertex.y == Math.abs(a.y)){
|
||||
|
||||
Reference in New Issue
Block a user