Upload your music and watch it come to life!!
A fork of DaCodeMon's Music Visualizer Version 5.6 by Edge Classfaction2024
xxxxxxxxxx
var shapes={
as:[],
aControl:0,
tdm:{
frame:{
x:[[]],
y:[[]],
w:[[]],
h:[[]],
cts:[[]],
depth:[[]],
a:[]
},
control:0
},
lines:{
x1:[],
y1:[],
x2:[],
y2:[],
control:0,
cts:[],
g:[],
depth:[],
a:[]
},
squares:{
x:[],
y:[],
w:[],
h:[],
squareControl:0,
depth:[0],
a:[]
},
cubes:{
a:[],
libFrom:[[]],
x:[],
y:[],
w:[],
h:[],
colorFrom:[[]],
colorTo:[[]],
cts:[],
cubeControl:0,
depth:[0]
},
spheres:{
a:[],
x:[0],
y:[0],
w:[0],
h:[0],
colorFrom:[[]],
colorTo:[[]],
cts:[],
control:0,
depth:[0]
},
triangles:{
a:[],
x1:[],
y1:[],
x2:[],
y2:[],
x3:[],
y3:[],
colorFrom:[[]],
colorTo:[[]],
cts:[],
control:0,
depth:[]
},
customShapes:{
a:[],
x1:[],
y1:[],
x2:[],
y2:[],
x3:[],
y3:[],
x4:[],
y4:[],
colorFrom:[[]],
colorTo:[[]],
cts:[],
control:0,
depth:[]
},
squareCube:{
a:[],
x:[0],
y:[0],
w:[0],
h:[0],
cts:[0],
depth:[0],
colorFrom:[[]],
colorTo:[[]],
control:0
},
tdtxt:{
a:[],
text:[],
x:[],
y:[],
w:[],
h:[],
cts:[],
depth:[],
control:0
}
};
//Now you can draw a square with a four color transition!!
function error(code){
var e=[];
var num=0;
var c=code.split(" ");
if(c[0]==="t"){
e[0]="txt";
}
if(c[0]==="rs"){
e[0]="redrawShape";
}
if(c[0]==="ngs"){
e[0]="newGradientSquare";
}
if(c[0]==="ns"){
e[0]="newSphere";
}
if(c[0]==="nc"){
e[0]="newCube";
}
if(c[0]==="ncs"){
e[0]="ncs";
}
if(c[1]==="x"){
e[1]="X Param";
}
if(c[1]==="y"){
e[1]="Y Param";
}
if(c[1]==="w"){
e[1]="W Param";
}
if(c[1]==="H"){
e[1]="H Param";
}
if(c[1]==="x1"){
e[1]="X1 Param";
}
if(c[1]==="y1"){
e[1]="Y1 Param";
}
if(c[1]==="x2"){
e[1]="X2 Param";
}
if(c[1]==="x3"){
e[1]="X3 Param";
}
if(c[1]==="y2"){
e[1]="Y2 Param";
}
if(c[1]==="y3"){
e[1]="Y3 Param";
}
if(c[1]==="y4"){
e[1]="Y4 Param";
}
if(c[1]==="y5"){
e[1]="Y5 Param";
}
if(c[1]==="x4"){
e[1]="X4 Param";
}
if(c[1]==="x5"){
e[1]="X5 Param";
}
if(c[1]==="cf"){
e[1]="COLOR FROM ARRAY";
}
if(c[1]==="ct"){
e[1]="COLOR TO ARRAY";
}
if(typeof(c[1])==="undefined"){
e[1]="UNCAUGHT PARAM";
}
if(c[1]==="cts"){
e[1]="COLOR TRANSITION RATE PARAM";
}
if(c[1]==="d"){
e[1]="DEPTH PARAM";
}
if(e[1]==="COLOR TO ARRAY" || e[1]==="COLOR FROM ARRAY"){
println("ERROR: @"+e[0]+" Call Trace Num Of "+num+" One or more elements of the "+e[1]+" are not of type number reading "+c[4]);
}else{
if(e[0]!=="redrawShape"){
println("ERROR: @"+e[0]+" Call Trace Num Of "+c[5]+" "+e[1]+" is not of type "+c[3]+" instead it is type "+c[2]+" reading: "+c[4]);
}else{
println("2ND HAND ERROR: @"+e[0]+" #"+c[6]+" With A Call Num Of "+c[5]+"\n"+e[1]+" is not of type "+c[3]+" instead it is of type "+c[2]+" reading: "+c[4]);
}
}
}
function newGradientSquare(x,y,w,h,colorF,colorT,cts,depth,exists,num){
var cc;
if(exists){
cc=num;
}else{
cc=shapes.cubes.cubeControl;
}
if(typeof(x)==="undefined"||isNaN(x)){
error("ngs x "+typeof(x)+" number "+x+" "+cc);
}
if(typeof(y)==="undefined"||isNaN(y)){
error("ngs y "+typeof(y)+" number "+y+" "+cc);
}
if(typeof(w)==="undefined"||isNaN(w)){
error("ngs w "+typeof(w)+" number "+w+" "+cc);
}
if(typeof(h)==="undefined"||isNaN(h)){
error("ngs h "+typeof(h)+" number "+h+" "+cc);
}
if(typeof(cts)==="undefined"||isNaN(cts)){
error("ngs cts "+typeof(cts)+" number "+cts+" "+cc);
}
if(typeof(colorF[0])==="undefined"||isNaN(colorF[0])||typeof(colorF[1])==="undefined"||isNaN(colorF[1])||typeof(colorF[2])==="undefined"||isNaN(colorF[2])){
error("ngs cf "+typeof(colorF)+" array "+colorF+" "+cc);
}
if(typeof(colorT[0])==="undefined"||isNaN(colorT[0])||typeof(colorT[1])==="undefined"||isNaN(colorT[1])||typeof(colorT[2])==="undefined"||isNaN(colorT[2])){
error("ngs ct "+typeof(colorT)+" array "+colorT+" "+cc);
}
if(typeof(depth)==="undefined"||isNaN(depth)){
error("ngs d "+typeof(depth)+" number "+depth+" "+cc);
}
if(typeof(exists)==="undefined"||exists===false){
cc=shapes.cubes.cubeControl;
shapes.cubes.libFrom[cc]=colorF;
shapes.cubes.x[cc]=x;
shapes.cubes.y[cc]=y;
shapes.cubes.w[cc]=w;
shapes.cubes.h[cc]=h;
shapes.cubes.colorFrom[cc]=colorF;
shapes.cubes.colorTo[cc]=colorT;
shapes.cubes.cts[cc]=cts;
shapes.cubes.depth[cc]=depth;
}
var colorFrom=colorF;
var colorTo=colorT;
var t=cts;
var loopx=0;
while(loopx<depth){
if(colorFrom[0]>colorTo[0]){
colorFrom[0]-=t;
}
if(colorTo[0]>colorFrom[0]){
colorFrom[0]+=t;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=t;
}
if(colorTo[1]>colorFrom[1]){
colorFrom[1]+=t;
}
if(colorFrom[2]>colorTo[2]){
colorFrom[2]-=t;
}
if(colorTo[2]>colorFrom[2]){
colorFrom[2]+=t;
}
//println(shapes.cubes.colorFrom);
//println(colorFrom+"| "+t+"| "+colorTo);
stroke(colorFrom[0],colorFrom[1],colorFrom[2]);
//println(cts+" g");
line(x+loopx,y,x+loopx,y+h);
loopx++;
}
if(exists===false || typeof(exists)==="undefined"){
shapes.cubes.cubeControl++;
}
}
function newSphere(x,y,w,h,colorF,colorT,cts,depth,exists,num){
fill(0,0,0,0);
var c;
if(exists){
c=num;
}else{
c=shapes.spheres.control;
}
if(typeof(x)==="undefined"){
error("ns x "+typeof(x)+" number "+x+" "+c);
}
if(typeof(y)==="undefined"){
error("ns y "+typeof(y)+" number "+y+" "+c);
}
if(typeof(w)==="undefined"){
error("ns w "+typeof(w)+" number "+w+" "+c);
}
if(typeof(h)==="undefined"){
error("ns h "+typeof(h)+" number "+h+" "+c);
}
if(typeof(colorF)==="undefined"){
error("ns cf "+typeof(colorF)+" number "+colorF+" "+c);
}
if(typeof(colorT)==="undefined"){
error("ns ct "+typeof(colorT)+" number "+colorT+" "+c);
}
if(typeof(cts)==="undefined"){
error("ns cts "+typeof(cts)+" number "+cts+" "+c);
}
if(typeof(depth)==="undefined"){
error("ns d "+typeof(depth)+" number "+depth+" "+c);
}
if(exists===false|| typeof(exists)==="undefined"){
shapes.spheres.x[c]=x;
shapes.spheres.y[c]=y;
shapes.spheres.w[c]=w;
shapes.spheres.h[c]=h;
shapes.spheres.colorFrom[c]=colorF;
shapes.spheres.colorTo[c]=colorT;
shapes.spheres.depth[c]=depth;
shapes.spheres.cts[c]=cts;
}
var colorFrom=colorF;
var colorTo=colorT;
var loopw=0;
var l=shapes.spheres.w[c];
while(loopw<depth){
l--;
if(colorFrom[0]>colorTo[0]){
colorFrom[0]-=cts;
}
if(colorFrom[0]<colorTo[0]){
colorFrom[0]+=cts;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=cts;
}
if(colorFrom[1]<colorTo[1]){
colorFrom[1]+=cts;
}
if(colorFrom[2]>colorTo[2]){
colorFrom[2]-=cts;
}
if(colorFrom[2]<colorTo[2]){
colorFrom[2]+=cts;
}
fill(0,0,0,0);
stroke(colorFrom[0],colorFrom[1],colorFrom[2]);
ellipse(x,y,l,h);
loopw++;
}
if(exists===false || typeof(exists)==="undefined"){
shapes.spheres.control++;
}
}
function newPyramid(x1,y1,x2,y2,x3,y3,colorF,colorT,cts,depth,exists,num){
var c;
var clr=colorF;
if(exists){
c=num;
}else{
c=shapes.triangles.control;
}
if(exists===false || typeof(exists)==="undefined"){
shapes.triangles.x1[c]=x1;
shapes.triangles.x2[c]=x2;
shapes.triangles.x3[c]=x3;
shapes.triangles.y1[c]=y1;
shapes.triangles.y2[c]=y2;
shapes.triangles.y3[c]=y3;
shapes.triangles.colorFrom[c]=colorF;
shapes.triangles.colorTo[c]=colorT;
shapes.triangles.cts[c]=cts;
shapes.triangles.depth[c]=depth;
}
if(typeof(shapes.triangles.x1[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF X1 @newPyramid x1 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.x1[c])+" reading: "+shapes.triangles.x1[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF X1 @newPyramid x1 is not of type number\n instead it is of type: "+typeof(shapes.triangles.x1[c])+" reading: "+shapes.triangles.x1[c]);
}
}
if(typeof(shapes.triangles.x2[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF X2 @newPyramid x2 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.x2[c])+" reading: "+shapes.triangles.x2[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF X1 @newPyramid x2 is not of type number\n instead it is of type: "+typeof(shapes.triangles.x2[c])+" reading: "+shapes.triangles.x2[c]);
}
}
if(typeof(shapes.triangles.x3[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF X3 @newPyramid x3 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.x3[c])+" reading: "+shapes.triangles.x3[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF X3 @newPyramid x3 is not of type number\n instead it is of type: "+typeof(shapes.triangles.x3[c])+" reading: "+shapes.triangles.x3[c]);
}
}
if(typeof(shapes.triangles.y1[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF Y1 @newPyramid Y1 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.y1[c])+" reading: "+shapes.triangles.y1[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF Y1 @newPyramid y1 is not of type number\n instead it is of type: "+typeof(shapes.triangles.y1[c])+" reading: "+shapes.triangles.y1[c]);
}
}
if(typeof(shapes.triangles.y2[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF Y2 @newPyramid Y2 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.y2[c])+" reading: "+shapes.triangles.y2[c]+shapes.triangles.y1[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF Y2 @newPyramid y2 is not of type number\n instead it is of type: "+typeof(shapes.triangles.y2[c])+" reading: "+shapes.triangles.y2[c]);
}
}
if(typeof(shapes.triangles.y3[c])!=="number"){
if(exists){
println("INTERNAL ERROR: TYPEOF Y3 @newPyramid Y3 is not of \ntype number instead it is of type: "+typeof(shapes.triangles.y3[c])+" reading: "+shapes.triangles.y3[c]+" calling from | redrawShape > #PYRAMID with num param of "+num);
}else{
println("ERROR: TYPEOF Y3 @newPyramid y3 is not of type number\n instead it is of type: "+typeof(shapes.triangles.y3[c])+" reading: "+shapes.triangles.y3[c]);
}
}
var loop=0;
var colorFrom=colorF;
var colorTo=colorT;
var p=x1;
if(typeof(colorFrom[0])!=="number" && exists===false){
println("NON-FATAL Error: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[0]));
}else if(exists && typeof(colorFrom[0])!=="number"){
println("NON-FATAL INTERNAL ERROR: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number reading: "+colorFrom[0]+" type: "+typeof(colorFrom[0])+" calling from: redrawShape > #PYRAMID with the NUM param of: "+num);
}
if(typeof(colorFrom[1])!=="number" && exists===false){
println("NON-FATAL Error: TYPEOF COLORFROM PARAM 1 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[1]));
}
if(typeof(colorFrom[1])!=="number" && exists){
println("NON-FATAL INTERNAL Error: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[0]));
}
if(typeof(colorFrom[2])!=="number" && exists===false){
println("NON-FATAL Error: TYPEOF COLORFROM PARAM 2 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[2]));
}
if(typeof(colorFrom[2])!=="number" && exists){
println("NON-FATAL INTERNAL Error: TYPEOF COLORFROM PARAM 2 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[2])+" reading: "+colorFrom[2]+" called from: redrawShape > #PYRAMID with the NUM PARAM of "+num);
}
while(loop<depth){
if(colorFrom[0]>colorTo[0]){
try{colorFrom[0]-=cts;}catch(e){println("NON-FATAL Error: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[0]));}
}
if(colorFrom[0]<colorTo[0]){
colorFrom[0]+=cts;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=cts;
}
if(colorFrom[1]<colorTo[1]){
colorFrom[1]+=cts;
}
if(colorFrom[2]>colorTo[2]){
try{colorFrom[2]-=cts;}catch(e){println("NON-FATAL Error: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[0]));}
}
if(colorFrom[2]<colorTo[2]){
try{colorFrom[2]+=cts;}catch(e){println("NON-FATAL Error: TYPEOF COLORFROM PARAM 0 @newPyramid is not of type number instead it is of type: "+typeof(colorFrom[0]));}
}
stroke(colorFrom[0],colorFrom[1],colorFrom[2]);
triangle(x1+loop,y1,x2,y2+loop,x3-loop,y3);
loop++;
}
if(typeof(exists)==="undefined"||exists===false){
shapes.triangles.control++;
}
}
function ncs(x1,y1,x2,y2,x3,y3,x4,y4,colorF,colorT,cts,depth,exists,num){
var c;
if(exists){
c=num;
}else{c=shapes.customShapes.control;
shapes.customShapes.x1[c]=x1;
shapes.customShapes.x2[c]=x2;
shapes.customShapes.x3[c]=x3;
shapes.customShapes.x4[c]=x4;
shapes.customShapes.y1[c]=y1;
shapes.customShapes.y2[c]=y2;
shapes.customShapes.y3[c]=y3;
shapes.customShapes.y4[c]=y4;
shapes.customShapes.cts[c]=cts;
shapes.customShapes.depth[c]=depth;
}
if(typeof(x1)==="undefined" || isNaN(x1)){
error("ncs x "+typeof(x1)+" number "+x1+" "+c);
}
if(typeof(x2)==="undefined" || isNaN(x2)){
error("ncs x2 "+typeof(x2)+" number "+x2+" "+c);
}
if(typeof(x3)==="undefined" || isNaN(x3)){
error("ncs x3 "+typeof(x3)+" number "+x3+" "+c);
}
if(typeof(x4)==="undefined" || isNaN(x4)){
error("ncs x4 "+typeof(x4)+" number "+x4+" "+c);
}
if(typeof(y1)==="undefined" || isNaN(y1)){
error("ncs y "+typeof(y1)+" number "+y1+" "+c);
}
if(typeof(y2)==="undefined" || isNaN(y2)){
error("ncs y2 "+typeof(y2)+" number "+y2+" "+c);
}
if(typeof(y3)==="undefined" || isNaN(y3)){
error("ncs y3 "+typeof(y3)+" number "+y3+" "+c);
}
if(typeof(y4)==="undefined" || isNaN(y4)){
error("ncs y4 "+typeof(y4)+" number "+y4+" "+c);
}
if(typeof(cts)==="undefined" || isNaN(cts)){
error("ncs cts "+typeof(cts)+" number "+cts+" "+c);
}
if(typeof(colorF)==="undefined" || isNaN(colorF[2])|| isNaN(colorF[1])|| isNaN(colorF[0])){
error("ncs cf "+typeof(colorF)+" number "+colorF+" "+c);
}
if(typeof(colorT)==="undefined" || isNaN(colorT[2])|| isNaN(colorT[1])|| isNaN(colorT[0])){
error("ncs ct "+typeof(colorT)+" number "+colorT+" "+c);
}
if(typeof(depth)==="undefined" || isNaN(depth)){
error("ncs d "+typeof(depth)+" number "+depth+" "+c);
}
var loop=0;
var colorFrom=shapes.customShapes.colorFrom;
var colorTo=shapes.customShapes.colorTo;
var p=x1+depth;
var colorFrom=colorF;
var colorTo=colorT;
while(loop<p){
if(colorFrom[0]>colorTo[0]){
colorFrom[0]-=cts;
}
if(colorFrom[0]<colorTo[0]){
colorFrom[0]+=cts;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=cts;
}
if(colorFrom[1]<colorTo[1]){
colorFrom[1]+=cts;
}
if(colorFrom[2]>colorTo[2]){
colorFrom[2]-=cts;
}
if(colorFrom[2]<colorTo[2]){
colorFrom[2]+=cts;
}
stroke(colorFrom[0],colorFrom[1],colorFrom[2]);
fill(0,0,0,0);
beginShape();
vertex(x4,y4);
bezierVertex(x1+loop,y1,x2,y2+loop,x3-loop,y3);
endShape();
loop++;
}
if(typeof(exists)==="undefined"){
shapes.customShapes.control++;
}
}
function newCube(x,y,w,h,colorF,colorT,cts,depth,exists,num){
var c;
if(exists){
c=num;
}else{
c=shapes.squareCube.control;
shapes.squareCube.x[c]=x;
shapes.squareCube.y[c]=y;
shapes.squareCube.w[c]=w;
shapes.squareCube.h[c]=h;
shapes.squareCube.colorFrom[c]=colorF;
shapes.squareCube.colorTo[c]=colorT;
shapes.squareCube.depth[c]=depth;
shapes.squareCube.cts[c]=cts;
shapes.squareCube.control++;
}
if(typeof(x)==="undefined"||isNaN(x)){
error("nc x "+typeof(x)+" number "+x+" "+c);
}
if(typeof(y)==="undefined"||isNaN(y)){
error("nc y "+typeof(y)+" number "+y+" "+c);
}
if(typeof(w)==="undefined"||isNaN(w)){
error("nc w "+typeof(w)+" number "+w+" "+c);
}
if(typeof(h)==="undefined"||isNaN(h)){
error("nc h "+typeof(h)+" number "+h+" "+c);
}
if(typeof(depth)==="undefined"||isNaN(depth)){
error("nc depth "+typeof(depth)+" number "+depth+" "+c);
}
if(typeof(cts)==="undefined"||isNaN(cts)){
error("nc cts "+typeof(cts)+" number "+cts+" "+c);
}
if(typeof(colorF)==="undefined"||isNaN(colorF[0])||isNaN(colorF[1])||isNaN(colorF[2])){
error("nc cf "+typeof(colorF)+" number "+colorF+" "+c);
}
if(typeof(colorT)==="undefined"||isNaN(colorT[0])||isNaN(colorT[1])||isNaN(colorT[2])){
error("nc ct "+typeof(colorT)+" array "+colorT+" "+c);
}
var colorFrom=colorF;
var colorTo=colorT;
var loop=0;
while(loop<depth){
if(colorFrom[0]<colorTo[0]){
colorFrom[0]+=cts;
}
if(colorFrom[0]>colorTo[0]){
colorFrom[0]-=cts;
}
if(colorFrom[1]<colorTo[1]){
colorFrom[1]+=cts;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=cts;
}
if(colorFrom[2]<colorTo[2]){
colorFrom[2]+=cts;
}
if(colorFrom[2]>colorTo[2]){
colorFrom[2]-=cts;
}
stroke(colorFrom[0],colorFrom[1],colorFrom[2]);
var p=loop*0.25;
fill(0,0,0,0);
rect(x-p/2,y+p/2,w,h);
loop++;
}
}
function txt(t,x,y,w,h,colorF,colorT,cts,depth,fnt,exists,num){
var c;
if(exists){
c=num;
}else{
c=shapes.tdtxt.control;
var s=shapes.tdtxt;
s.x[c]=x;
s.y[c]=y;
s.w[c]=w;
s.h[c]=h;
s.text[c]=t;
s.cts[c]=cts;
s.depth[c]=depth;
s.control++;
}
if(typeof(x)!=="undefined" && isNaN(x)){
error("txt x "+typeof(x)+" number "+x+" "+c);
}
if(typeof(y)!=="undefined" && isNaN(y)){
error("txt y "+typeof(y)+" number "+y+" "+c);
}
if(typeof(w)!=="undefined" && isNaN(w)){
error("txt w "+typeof(w)+" number "+w+" "+c);
}
if(typeof(h)!=="undefined" && isNaN(h)){
error("txt h "+typeof(h)+" number "+h+" "+c);
}
if(typeof(cts)!=="undefined" && isNaN(cts)){
error("txt cts "+typeof(cts)+" number "+cts+" "+c);
}
if(typeof(depth)!=="undefined" && isNaN(depth)){
error("txt d "+typeof(depth)+" number "+depth+" "+c);
}
if(typeof(fnt)!=="undefined" && isNaN(fnt)){
error("txt fs "+typeof(fnt)+" number "+fnt+" "+c);
}
if(typeof(colorF)!=="undefined" && isNaN(colorF[0])||isNaN(colorF[1])||isNaN(colorF[2])){
error("txt cf "+typeof(x)+" array "+colorF+" "+c);
}
if(typeof(colorT)!=="undefined" && isNaN(colorT[0])||isNaN(colorT[1])||isNaN(colorT[2])){
error("txt ct "+typeof(colorT)+" array "+colorT+" "+c);
}
var l=0;
var colorFrom=colorF;
var colorTo=colorT;
while(l<depth){
if(colorFrom[0]<colorTo[0]){
colorFrom[0]+=cts;
}
if(colorTo[0]<colorFrom[0]){
colorFrom[0]-=cts;
}
if(colorFrom[1]<colorTo[1]){
colorFrom[1]+=cts;
}
if(colorFrom[1]>colorTo[1]){
colorFrom[1]-=cts;
}
if(colorFrom[2]>colorTo[2]){
colorFrom[2]-=cts;
}
if(colorFrom[2]<colorTo[2]){
colorFrom[2]+=cts;
}
fill(0,0,0,0);
fill(colorFrom[0],colorFrom[1],colorFrom[2]);
//stroke(255,0,0);
textSize(fnt);
var p=l*0.25;
text(t,x+p/2,y-p/2);
l++;
}
}
function newGradientLine(x1,y1,x2,y2,colorF,colorT,cts,g,depth,exists,num){
var c;
if(exists){
c=num;
}else{
var s=shapes.lines;
c=s.control;
s.x1[c]=x1;
s.x2[c]=x2;
s.y1[c]=y1;
s.y2[c]=y2;
s.cts[c]=cts;
s.g[c]=g;
s.depth[c]=depth;
s.control++;
}
var cf=colorF;
var ct=colorT;
var x=0;
var loop=0;
if(g){
loop=x1;
depth+=x1;
}else{
loop=y1;
depth+=y1;
}
while(loop<depth){
if(cf[0]<ct[0]){
cf[0]+=cts;
}
if(cf[0]>ct[0]){
cf[0]-=cts;
}
if(cf[1]<ct[1]){
cf[1]+=cts;
}
if(cf[1]>ct[1]){
cf[1]+=cts;
}
if(cf[2]<ct[2]){
cf[2]+=cts;
}
if(cf[2]>ct[2]){
cf[2]+=cts;
}
stroke(cf[0],cf[1],cf[2]);
if(g){
line(x1+x,y1,x1+x,y2);
}else{
line(x1,y1+x,x2,y2+x);
}
x++;
loop++;
}
}
function newQuadGradientSquare(code,exists,num){
var s=shapes.tdm.frame;
var c;
for(var i=0;i<code.length;i++){
var f=code[i][0].split("_")[1];
f=parseInt(f,0)-1;
if(exists){
c=num;
}else{
c=shapes.tdm.control;
if(f===0){
s.x[c]=[];
s.y[c]=[];
s.w[c]=[];
s.h[c]=[];
// s.depth=[];
s.x[c][f]=code[i][1];
s.y[c][f]=code[i][2];
s.w[c][f]=code[i][3];
s.h[c][f]=code[i][4];
s.depth[c][f]=code[i][5];
s.cts[c][f]=code[i][6];
}else{
//println(c);
s.x[c][f]=code[i][1];
s.y[c][f]=code[i][2];
s.w[c][f]=code[i][3];
s.h[c][f]=code[i][4];
s.cts[c][f]=code[i][5];
s.depth[c][f]=code[i][6];
}
}
var cf=code[i][5];
var ct=code[i][6];
var l=0;
//println(s.depth+"h");
}//for i
shapes.tdm.control++;
}
function drawQuadGradientSquare(num,colorFromW,colorToW,colorFromH,colorToH,frame){
var s=shapes.tdm.frame;
var cfw=colorFromW;
var ctw=colorToW;
var cfh=colorFromH;
var cth=colorToH;
var l=s.w[num][frame];
//println(cf);
println("d3dm="+shapes.tdm.frame.depth[num][frame]);
for(var i=0;i<shapes.tdm.frame.depth[num][frame];i++){
// println(s.x[num][frame]+","+s.y[num][frame]+","+s.x[num][frame]+s.w[num][frame]+","+s.y[num][frame]+s.h[num][frame]+" k");
var v=0;
while(v<s.w[num][frame]){
if(cfw[0]<ctw[0]){
cfw[0]+=s.cts[num][frame];
}
if(cfw[0]>ctw[0]){
cfw[0]-=s.cts[num][frame];
}
if(cfw[1]<ctw[1]){
cfw[1]+=s.cts[num][frame];
}
if(cfw[1]>ctw[1]){
cfw[1]-=s.cts[num][frame];
}
if(cfw[2]<ctw[2]){
cfw[2]+=s.cts[num][frame];
}
if(cfw[2]>ctw[2]){
cfw[2]-=s.cts[num][frame];
}
stroke(cfw[0],cfw[1],cfw[2]);
line(s.x[num][frame],s.y[num][frame],s.x[num][frame]+v,s.y[num][frame]+s.h[num][frame]);
v++;
}
var h=0;
while(h<s.h[num][frame]){
if(cfh[0]<cth[0]){
cfh[0]+=s.cts[num][frame];
}
if(cfh[0]>cth[0]){
cfh[0]-=s.cts[num][frame];
}
if(cfh[1]<cth[1]){
cfh[1]+=s.cts[num][frame];
}
if(cfh[1]>cth[1]){
cfh[1]-=s.cts[num][frame];
}
if(cfh[2]<cth[2]){
cfh[2]+=s.cts[num][frame];
}
if(cfh[2]>cth[2]){
cfh[2]-=s.cts[num][frame];
}
stroke(cfh[0],cfh[1],cfh[2]);
line(s.x[num][frame],s.y[num][frame],s.x[num][frame]+v,s.y[num][frame]+h);
h++;
}
l--;
}
}
function attatchShape(shape,num,to,peg,gn){
shape=shape.toLowerCase();
if(shape==="square"||shape==="gradientsquare"){
if(peg){
shape="square";
shapes.as[gn].push([shape,num]);
}else{
shapes.as[shapes.aControl]=[shape,num,to];
shapes.aControl++;
}
}
if(shape==="sphere"||shape==="ncs"||shape==="pyramid"||shape==="line"||shape==="cube"||shape==="txt"){
if(peg){
shapes.as[gn].push([shape,num]);
}else{
shapes.as[shapes.aControl]=[shape,num,to];
shapes.aControl++;
}
}
}
function drawAttatchedShapeGroup(num,colorFrom,colorTo,options){
var o={
x1:0,
x2:0,
x3:0,
x4:0,
y1:0,
y2:0,
y3:0,
y4:0,
cts:0,
depth:0
};
var s=shapes.as[num];
var ss=shapes.cubes;
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
options[i][0]=options[i][0].toLowerCase();
if(options[i][0]==="x"||options[i][0]==="x1"){
o.x1=options[i][1];
}
if(options[i][0]==="y"||options[i][0]==="y1"){
o.y1=options[i][1];
}
if(options[i][0]==="x2"){
o.x2=options[i][1];
}
if(options[i][0]==="x3"){
o.x3=options[i][1];
}
if(options[i][0]==="y2"){
o.y2=options[i][1];
}
if(options[i][0]==="y3"){
o.y3=options[i][1];
}
if(options[i][0]==="x4"){
o.x4=options[i][1];
}
if(options[i][0]==="y4"){
o.y4=options[i][1];
}
if(options[i][0]==="w"){
o.x2=options[i][1];
}
if(options[i][0]==="h"){
o.y2=options[i][1];
}
}
}
if(s[0]==="square"){
println(s[1]);
newGradientSquare(ss.x[s[1]]+o.x1,ss.y[s[1]]+o.y1,ss.w[s[1]]+o.x2,ss.h[s[1]]+o.y2,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true,s[1]);
}
if(s[0]==="sphere"){
var ss=shapes.spheres;
newSphere(ss.x[s[1]]+o.x1,ss.y[s[1]]+o.y1,ss.w[s[1]]+o.x2,ss.h[s[1]]+o.y2,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true,s[1]);
}
if(s[0]==="line"){
var ss=shapes.lines;
newGradientLine(ss.x[s[1]]+o.x1,ss.y[s[1]]+o.y1,ss.w[s[1]]+o.x2,ss.h[s[1]]+o.y2,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true,s[1]);
}
if(s[0]==="cube"){
var ss=shapes.customShapes;
newCube(ss.x[s[1]]+o.x1,ss.y[s[1]]+o.y1,ss.w[s[1]]+o.x2,ss.h[s[1]]+o.y2,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true);
}
if(s[0]==="txt"){
var ss=shapes.tdtxt;
txt(ss.text[s[1]],ss.x[s[1]]+o.x1,ss.y[s[1]]+o.y1,ss.w[s[1]]+o.x2,ss.h[s[1]]+o.y2,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true);
}
if(s[0]==="pyramid"){
var ss=shapes.triangles;
newPyramid(ss.x1[s[1]]+o.x1,ss.y1[s[1]]+o.y1,ss.x2[s[1]]+o.x2,ss.y2[s[1]]+o.y2,ss.x3[s[1]]+o.x3,ss.y3[s[1]],colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth,true);
}
if(s[0]==="ncs"){
var ss=shapes.customShapes;
ncs(ss.x1[s[1]]+o.x1,ss.y1[s[1]]+o.y1,ss.x2[s[1]]+o.x2,ss.y2[s[1]]+o.y2,ss.x3[s[1]]+o.x3,ss.y3[s[1]]+o.y3,ss.x4[s[1]]+o.x4,ss.y4[s[1]]+o.y4,colorFrom,colorTo,ss.cts[s[1]]+o.cts,ss.depth[s[1]]+o.depth);
}
for(var i=0;i<s.length;i++){
if(s[i][0]==="square"){
newGradientSquare(ss.x[s[i][1]]+o.x1,ss.y[s[i][1]]+o.y1,ss.w[s[i][1]]+o.x2,ss.h[s[i][1]]+o.y2,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="sphere"){
var ss=shapes.spheres;
newSphere(ss.x[s[i][1]]+o.x1,ss.y[s[i][1]]+o.y1,ss.w[s[i][1]]+o.x2,ss.h[s[i][1]]+o.y2,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="cube"){
var ss=shapes.squareCube;
newCube(ss.x[s[i][1]]+o.x1,ss.y[s[i][1]]+o.y1,ss.w[s[i][1]]+o.x2,ss.h[s[i][1]]+o.y2,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="txt"){
var ss=shapes.tdtxt;
txt(ss.text[s[i][1]],ss.x[s[i][1]]+o.x1,ss.y[s[i][1]]+o.y1,ss.w[s[i][1]]+o.x2,ss.h[s[i][1]]+o.y2,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="line"){
var ss=shapes.lines;
newGradientLine(ss.x[s[i][1]]+o.x1,ss.y[s[i][1]]+o.y1,ss.w[s[i][1]]+o.x2,ss.h[s[i][1]]+o.y2,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="ncs"){
var c=shapes.customShapes;
ncs(ss.x1[s[i][1]]+o.x1,ss.y1[s[i][1]]+o.y1,ss.x2[s[i][1]]+o.x2,ss.y2[s[i][1]]+o.y2,ss.x3[s[i][1]]+o.x3,ss.y3[s[i][1]]+o.y3,ss.x4[s[i][1]]+o.x4,ss.y4[s[i][1]]+o.y4,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
if(s[i][0]==="pyramid"){
var c=shapes.triangles;
newPyramid(ss.x1[s[i][1]]+o.x1,ss.y1[s[i][1]]+o.y1,ss.x2[s[i][1]]+o.x2,ss.y2[s[i][1]]+o.y2,ss.x3[s[i][1]]+o.x3,ss.y3[s[i][1]]+o.y3,colorFrom,colorTo,ss.cts[s[i][1]]+o.cts,ss.depth[s[i][1]]+o.depth,true,s[i][1]);
}
}
}
function redrawShape(shape,num,colorFrom,colorTo,a,options){
if(shape.toLowerCase()==="gradientline"||shape.toLowerCase()==="line"){
var s=shapes.lines;
var x1=s.x1[num];
var x2=s.x2[num];
var y1=s.y1[num];
var y2=s.y2[num];
var cts=s.cts[num];
var g=s.g[num];
var d=s.depth[num];
if(typeof(x1)!=="undefined" && isNaN(x1)){
error("rs x1 "+typeof(x1)+" number "+x1+" "+num+" "+shape);
}
if(typeof(x2)!=="undefined" && isNaN(x2)){
error("rs x2 "+typeof(x2)+" number "+x2+" "+num+" "+shape);
}
if(typeof(y1)!=="undefined" && isNaN(y1)){
error("rs y1 "+typeof(y1)+" number "+y1+" "+num+" "+shape);
}
if(typeof(y2)!=="undefined" && isNaN(y2)){
error("rs y2 "+typeof(y2)+" number "+y2+" "+num+" "+shape);
}
if(typeof(cts)!=="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(g)!=="undefined" && isNaN(g)){
error("rs g "+typeof(g)+" number "+g+" "+num+" "+shape);
}
if(typeof(d)!=="undefined" && isNaN(d)){
error("rs d "+typeof(d)+" number "+d+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
options[i][0]=options[i][0].toLowerCase();
if(options[i][0]==="x1"){
x1+=options[i][1];
}
if(options[i][0]==="x2"){
x2+=options[i][1];
}
if(options[i][0]==="y1"){
y1+=options[i][1];
}
if(options[i][0]==="y2"){
y2+=options[i][1];
}
if(options[i][0]==="cts"){
cts+=options[i][1];
}
if(options[i][0]==="d"){
d+=options[i][1];
}
if(options[i][0]==="g"){
g+=options[i][1];
}
}
}
newGradientLine(x1,y1,x2,y2,colorFrom,colorTo,cts,g,d,true,num);
}
if(shape.toLowerCase()==="txt"){
var s=shapes.tdtxt;
var x=s.x[num];
var y=s.y[num];
var w=s.w[num];
var h=s.h[num];
var cts=s.cts[num];
var depth=s.depth[num];
var fs=s.fs[num];
if(typeof(x)==="undefined" && isNaN(x)){
error("rs x "+typeof(x)+" number "+x+" "+num+" "+shape);
}
if(typeof(y)==="undefined" && isNaN(y)){
error("rs y "+typeof(y)+" number "+y+" "+num+" "+shape);
}
if(typeof(w)==="undefined" && isNaN(w)){
error("rs w "+typeof(w)+" number "+w+" "+num+" "+shape);
}
if(typeof(h)==="undefined" && isNaN(h)){
error("rs h "+typeof(h)+" number "+h+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(depth)==="undefined" && isNaN(depth)){
error("rs d "+typeof(depth)+" number "+depth+" "+num+" "+shape);
}
if(typeof(fs)==="undefined" && isNaN(fs)){
error("rs fs "+typeof(fs)+" number "+fs+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){options[i][0]=options[i][0].toLowerCase();
if(options[i][0]==="x"){
x+=options[i][1];
}
if(options[i][0]==="y"){
y+=options[i][1];
}
if(options[i][0]==="w"){
w+=options[i][1];
}
if(options[i][0]==="h"){
h+=options[i][1];
}
if(options[i][0]==="cts"){
cts+=options[i][1];
}
if(options[i][0]==="depth"){
depth+=options[i][1];
}
if(options[i][0]==="fs"){
fs+=options[i][1];
}
}
}
}
if(shape.toLowerCase()==="cube"){
var s=shapes.squareCube;
var x=s.x[num];
var y=s.y[num];
var w=s.w[num];
var h=s.h[num];
var cts=s.cts[num];
var d=s.depth[num];
if(typeof(x)==="undefined" && isNaN(x)){
error("rs x "+typeof(x)+" number "+x+" "+num+" "+shape);
}
if(typeof(y)==="undefined" && isNaN(y)){
error("rs y "+typeof(y)+" number "+y+" "+num+" "+shape);
}
if(typeof(w)==="undefined" && isNaN(w)){
error("rs w "+typeof(w)+" number "+w+" "+num+" "+shape);
}
if(typeof(h)==="undefined" && isNaN(h)){
error("rs h "+typeof(h)+" number "+h+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(d)==="undefined" && isNaN(d)){
error("rs d "+typeof(d)+" number "+d+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
options[i][0]=options[i][0].toLowerCase();
if(options[i][0]==="x"){
x+=options[i][1];
}
if(options[i][0]==="y"){
x+=options[i][1];
}
if(options[i][0]==="w"){
w+=options[i][1];
}
if(options[i][0]==="h"){
h+=options[i][1];
}
}
}
newCube(x,y,w,h,colorFrom,colorTo,cts,d,true,num);
}
if(shape.toLowerCase()==="ncs"){
var s=shapes.customShapes;
var x1=s.x1[num];
var y1=s.y1[num];
var x2=s.x2[num];
var y2=s.y2[num];
var x3=s.x3[num];
var y3=s.y3[num];
var x4=s.x4[num];
var y4=s.y4[num];
var cts=s.cts[num];
var depth=s.depth[num];
if(typeof(x1)==="undefined" && isNaN(x1)){
error("rs x1 "+typeof(x1)+" number "+x1+" "+num+" "+shape);
}
if(typeof(y1)==="undefined" && isNaN(y1)){
error("rs y1 "+typeof(y1)+" number "+y1+" "+num+" "+shape);
}
if(typeof(x2)==="undefined" && isNaN(x2)){
error("rs x2 "+typeof(x2)+" number "+x2+" "+num+" "+shape);
}
if(typeof(y2)==="undefined" && isNaN(y2)){
error("rs y2 "+typeof(y2)+" number "+y2+" "+num+" "+shape);
}
if(typeof(x3)==="undefined" && isNaN(x3)){
error("rs x3 "+typeof(x3)+" number "+x3+" "+num+" "+shape);
}
if(typeof(y3)==="undefined" && isNaN(y3)){
error("rs y3 "+typeof(y3)+" number "+y3+" "+num+" "+shape);
}
if(typeof(x4)==="undefined" && isNaN(x4)){
error("rs x4 "+typeof(x4)+" number "+x4+" "+num+" "+shape);
}
if(typeof(y4)==="undefined" && isNaN(y4)){
error("rs y4 "+typeof(y4)+" number "+y4+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(depth)==="undefined" && isNaN(depth)){
error("rs d "+typeof(depth)+" number "+depth+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
options[i][0]=options[i][0].toLowerCase();
if(options[i][0]==="x"){
x1+=options[i][1];
x2+=options[i][1];
x3+=options[i][1];
x4+=options[i][1];
}
if(options[i][0]==="y"){
y1+=options[i][1];
y2+=options[i][1];
y3+=options[i][1];
y4+=options[i][1];
}
if(options[i][0]==="x1"){
x1+=options[i][1];
}
if(options[i][0]==="x2"){
x2+=options[i][1];
}
if(options[i][0]==="x3"){
x3+=options[i][1];
}
if(options[i][0]==="x4"){
x4+=options[i][1];
}
if(options[i][0]==="y1"){
y1+=options[i][1];
}
if(options[i][0]==="y2"){
y2+=options[i][1];
}
if(options[i][0]==="y3"){
y3+=options[i][1];
}
if(options[i][0]==="y4"){
y4+=options[i][1];
}
}
}
ncs(x1,y1,x2,y2,x3,y3,x4,y4,colorFrom,colorTo,cts,depth,true,num);
}
if(shape.toLowerCase()==="gradientsquare"){
var s=shapes.cubes;
var x=s.x[num];
var y=s.y[num];
var w=s.w[num];
var h=s.h[num];
var cf=s.colorFrom[num];
var ct=s.colorTo[num];
var cts=s.cts[num];
var d=s.depth[num];
if(typeof(x)==="undefined" && isNaN(x)){
error("rs x "+typeof(x)+" number "+x+" "+num+" "+shape);
}
if(typeof(y)==="undefined" && isNaN(y)){
error("rs y "+typeof(y)+" number "+y+" "+num+" "+shape);
}
if(typeof(w)==="undefined" && isNaN(w)){
error("rs x2 "+typeof(w)+" number "+w+" "+num+" "+shape);
}
if(typeof(h)==="undefined" && isNaN(h)){
error("rs w "+typeof(h)+" number "+h+" "+num+" "+shape);
}
if(typeof(d)==="undefined" && isNaN(d)){
error("rs d "+typeof(d)+" number "+d+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
if(options[i][0].toLowerCase()==="x"){
x+=options[i][1];
}
if(options[i][0].toLowerCase()==="y"){
y+=options[i][1];
}
if(options[i][0].toLowerCase()==="w"){
w+=options[i][1];
}
if(options[i][0].toLowerCase()==="h"){
h+=options[i][1];
}
}
}
newGradientSquare(x,y,w,h,colorFrom,colorTo,cts,d,true,num);
}
if(shape.toLowerCase()==="sphere"){
var s=shapes.spheres;
var x=s.x[num];
var y=s.y[num];
var w=s.w[num];
var h=s.h[num];
var cf=s.colorFrom[num];
var ct=s.colorTo[num];
var cts=s.cts[num];
var d=s.depth[num];
if(typeof(x)==="undefined" && isNaN(x)){
error("rs x "+typeof(x)+" number "+x+" "+num+" "+shape);
}
if(typeof(y)==="undefined" && isNaN(y)){
error("rs y "+typeof(y)+" number "+y+" "+num+" "+shape);
}
if(typeof(w)==="undefined" && isNaN(w)){
error("rs w "+typeof(w)+" number "+w+" "+num+" "+shape);
}
if(typeof(h)==="undefined" && isNaN(h)){
error("rs h "+typeof(h)+" number "+h+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(d)==="undefined" && isNaN(d)){
error("rs d "+typeof(d)+" number "+d+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
if(options[i][0].toLowerCase()==="x"){
x+=options[i][1];
}
if(options[i][0].toLowerCase()==="y"){
y+=options[i][1];
}
if(options[i][0].toLowerCase()==="w"){
w+=options[i][1];
}
if(options[i][0].toLowerCase()==="h"){
h+=options[i][1];
}
}
}
newSphere(x,y,w,h,colorFrom,colorTo,cts,d,true,num);
}
if(shape.toLowerCase()==="pyramid"){
var s=shapes.triangles;
var x=s.x1[num];
var y=s.y1[num];
var x2=s.x2[num];
var y2=s.y2[num];
var x3=s.x3[num];
var y3=s.y3[num];
var cf=s.colorFrom[num];
var ct=s.colorTo[num];
var cts=s.cts[num];
var d=s.depth[num];
if(typeof(x)==="undefined" && isNaN(x)){
error("rs x "+typeof(x)+" number "+x+" "+num+" "+shape);
}
if(typeof(y)==="undefined" && isNaN(y)){
error("rs y "+typeof(y)+" number "+y+" "+num+" "+shape);
}
if(typeof(x2)==="undefined" && isNaN(x2)){
error("rs x2 "+typeof(x2)+" number "+x2+" "+num+" "+shape);
}
if(typeof(y2)==="undefined" && isNaN(y2)){
error("rs y2 "+typeof(y2)+" number "+y2+" "+num+" "+shape);
}
if(typeof(x3)==="undefined" && isNaN(x3)){
error("rs x3 "+typeof(x3)+" number "+x3+" "+num+" "+shape);
}
if(typeof(y3)==="undefined" && isNaN(y3)){
error("rs y3 "+typeof(y3)+" number "+y3+" "+num+" "+shape);
}
if(typeof(cts)==="undefined" && isNaN(cts)){
error("rs cts "+typeof(cts)+" number "+cts+" "+num+" "+shape);
}
if(typeof(d)==="undefined" && isNaN(d)){
error("rs d "+typeof(d)+" number "+d+" "+num+" "+shape);
}
if(typeof(options)!=="undefined"){
for(var i=0;i<options.length;i++){
if(options[i][0].toLowerCase()==="x"){
x+=options[i][1];
}
if(options[i][0].toLowerCase()==="y"){
y+=options[i][1];
}
if(options[i][0].toLowerCase()==="x2"){
x2+=options[i][1];
}
if(options[i][0].toLowerCase()==="y2"){
y2+=options[i][1];
}
if(options[i][0].toLowerCase()==="y3"){
y3+=options[i][1];
}
if(options[i][0].toLowerCase()==="x3"){
x3+=options[i][1];
}
}
}
var caught=false;
try{newPyramid(x,y,x2,y2,x3,y3,colorFrom,colorTo,cts,d,true,num);}catch(e){
if(typeof(colorFrom)!=="object"||colorFrom===null){
println("TYPEOF COLORFROM @ redrawShape #PYRAMID must be an \narray of 3 numbers [R,G,B] not type: "+typeof(colorFrom)+". If you have entered an array please check the variable type of each array block.");
caught=true;
}
if(typeof(colorTo)!=="object"||colorTo===null){
println("TYPEOF COLORTO @ redrawShape #PYRAMID must be an \narray of 3 numbers [R,G,B] not type: "+typeof(colorTo)+". If you have entered an array please check the variable type of each array block.");
caught=true;
}
if(typeof(num)!=="number"){
println("ERROR: TYPEOF NUM @redrawShape num is not a number instead it is of type: "+typeof(num)+" reading: "+num);
caught=true;
}
if(caught===false){
println("ERROR: unknown error @redrawShape #PYRAMID");
}
}
}
}