diff --git a/docs/index/index.chart.js b/docs/index/index.chart.js index 87879ca..de3515a 100644 --- a/docs/index/index.chart.js +++ b/docs/index/index.chart.js @@ -24,8 +24,10 @@ new TestContainer("chart", `g2().view({cartesian:true}) .chart({x:40,y:40,b:190,h:90,fs:'black', funcs:[ - {data:[-2,4,2,-1,3,3,4,2],style:{ls:'violet',lw:3,sh:[5,5,5,'rgba(255,0,255,0.7)']}}, - {fn:Math.sin,dx:Math.PI/20,style:{ls:'green',lw:3,sh:[5,5,5,'rgba(0,255,0,0.5)']}} + {data:[-2,4,2,-1,3,3,4,2],style:{ls:'violet', + lw:3,sh:[5,5,5,'rgba(255,0,255,0.7)']}}, + {fn:Math.sin,dx:Math.PI/20,style:{ls:'green', + lw:3,sh:[5,5,5,'rgba(0,255,0,0.5)']}} ], title:{text:"chart"}, xaxis:{title:"x-axis",origin:true}, diff --git a/docs/index/index.core.js b/docs/index/index.core.js index 690ba2b..703eb60 100644 --- a/docs/index/index.core.js +++ b/docs/index/index.core.js @@ -34,40 +34,54 @@ new TestContainer( .ell({x:210,y:50,rx:10,ry:30,w:1,dw:5,ls:'blue'})`), new Test('arc', - `g2().arc({x:90,y:50,r:35,w:1/3*pi,dw:4/3*pi,ls:'blue',lw:5,fs:'#ddd'}) - .arc({x:120,y:50,r:35,w:1/3*pi,dw:-2/3*pi,ls:'blue',lw:5,fs:'#ddd'})`), + `g2().arc({x:90,y:50,r:35,w:1/3*pi,dw:4/3*pi, + ls:'blue',lw:5,fs:'#ddd'}) + .arc({x:120,y:50,r:35,w:1/3*pi,dw:-2/3*pi, + ls:'blue',lw:5,fs:'#ddd'})`), new Test('arc-2', - `g2().arc({x:90,y:50,r:35,w:1/3*pi,dw:4/3*pi,ls:'green',lw:5,fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']}) - .arc({x:120,y:50,r:35,w:1/3*pi,dw:-2/3*pi,ls:'green',lw:5,fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']})`), + `g2().arc({x:90,y:50,r:35,w:1/3*pi,dw:4/3*pi, + ls:'green',lw:5,fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']}) + .arc({x:120,y:50,r:35,w:1/3*pi,dw:-2/3*pi, + ls:'green',lw:5,fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']})`), new Test('rec', `g2().rec({x:60,y:20,b:80,h:40,ls:'red',lw:3,fs:'#ddd'}) - .rec({x:120,y:70,b:80,h:40,ls:'blue',lw:3,fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']})`), + .rec({x:120,y:70,b:80,h:40,ls:'blue',lw:3, + fs:'#ddd',sh:[5,5,5,'rgba(0,0,0,0.5)']})`), new Test('lin', `g2().lin({x1:20,y1:30,x2:180,y2:80,ls:'green',lw:3}) - .lin({x1:30,y1:100,x2:200,y2:120,ls:'orange',lw:3,sh:[5,5,5,'rgba(0,0,0,0.5)']})`), + .lin({x1:30,y1:100,x2:200,y2:120,ls:'orange', + lw:3,sh:[5,5,5,'rgba(0,0,0,0.5)']})`), new Test('ply', - `g2().ply({pts:[20,10,60,80,120,30,180,90],ls:'red',lw:3,fs:'#ddd'})`), + `g2().ply({pts:[20,10,60,80,120,30,180,90], + ls:'red',lw:3,fs:'#ddd'})`), new Test('ply-2', - `g2().ply({pts:[[20,10],[60,80],[120,30],[180,90]],ls:'red',lw:3,fs:'#ddd',w:0.3})`), + `g2().ply({pts:[[20,10],[60,80],[120,30],[180,90]], + ls:'red',lw:3,fs:'#ddd',w:0.3})`), new Test('ply-3', - `g2().ply({y:30,pts:[{x:20,y:10},{x:60,y:80},{x:120,y:30},{x:180,y:90}],ls:'red',lw:3,fs:'#ddd',w:-0.3})`), + `g2().ply({y:30, + pts:[{x:20,y:10},{x:60,y:80},{x:120,y:30},{x:180,y:90}], + ls:'red',lw:3,fs:'#ddd',w:-0.3})`), new Test('ply-4', `g2().ply({pts:[20,10,60,80,120,30,180,90],ls:'red',lw:3}) - .ply({pts:[20,50,60,110,120,60,180,120],ls:'red',lw:3,sh:[5,5,5,'rgba(0,0,0,0.5)']})`), + .ply({pts:[20,50,60,110,120,60,180,120], + ls:'red',lw:3,sh:[5,5,5,'rgba(0,0,0,0.5)']})`), new Test('ply-5', - `g2().ply({pts:[20,10,60,80,120,30,180,90],closed:true,ls:'red',lw:3,fs:'#ddd'})`), + `g2().ply({pts:[20,10,60,80,120,30,180,90],closed:true, + ls:'red',lw:3,fs:'#ddd'})`), new Test('txt', - `g2().txt({str:'Hello',x:30,y:30,w:0,fs:'red',font:'normal 30px serif'}) - .txt({str:'World!',x:120,y:30,w:0,fs:'blue',font:'normal 30px serif',sh:[5,5,5,'rgba(0,0,0,0.5)']})`), + `g2().txt({str:'Hello',x:30,y:30,w:0, + fs:'red',font:'normal 30px serif'}) + .txt({str:'World!',x:120,y:30,w:0,fs:'blue',font:'normal 30px serif', + sh:[5,5,5,'rgba(0,0,0,0.5)']})`), new Test('txt-2', `g2().txt({str:'Hello',x:100,y:50,w:0}) @@ -131,44 +145,46 @@ g2().img({uri:'unknown.png',x:1,y:1,b:30,h:30})`), `g2().img({uri:'img/imageTst.png', x: 10, y: 10, b: 100, h: 50})`), new Test('img-6', - `g2().img({uri:'img/imageTst.png', x: 10, y: 10 , b: 100, h: 50, w: 0.5}) - .rec({x: 10, y: 10, b: 100, h: 50})`), + `g2().img({uri:'img/imageTst.png',x:10,y:10,b:100,h:50,w:0.5}) + .rec({x:10,y:10,b:100,h:50})`), new Test('img-7', - `g2().img({uri:'img/imageTst.png', y: 60 , xoff:-10, yoff:-50, b: 100, h: 50})`), + `g2().img({uri:'img/imageTst.png',y:60,xoff:-10,yoff:-50,b:100,h:50})`), new Test('img-8', - `g2().img({uri:'img/imageTst.png', y: 60 , x:10, yoff:-50, b: 100, h: 50, w: 0.5}) - .rec({x: 10, y: 10, b: 100, h: 50})`), + `g2().img({uri:'img/imageTst.png',y:60,x:10,yoff:-50,b:100,h:50,w:0.5}) + .rec({x:10,y:10,b:100,h:50})`), new Test('img-9', - `g2().img({uri:'img/imageTst.png', y: 10, x: 10, scl: 0.5})`), + `g2().img({uri:'img/imageTst.png',y:10,x:10,scl:0.5})`), new Test('img-10', - `g2().img({uri:'img/imageTst.png', x: 10, y: 10, b:200, h: 100, sx:10, sy:10}) + `g2().img({uri:'img/imageTst.png',x:10,y:10,b:200,h:100,sx:10,sy:10}) .rec({x: 10, y: 10, b: 200, h: 100})`), new Test('img-11', - `g2().img({uri:'img/imageTst.png', x: 10, y: 10, b: 200, h: 100, sx: 10, sy: 10, w: 0.5}) + `g2().img({uri:'img/imageTst.png',x:10,y:10,b:200,h:100, + sx:10,sy:10,w:0.5}) .beg({x: 10, y: 10, w: 0.5}) .rec({b: 200, h: 100}) .end()`), new Test('img-12', - `g2().img({uri:'img/imageTst.png', x: 50, y: 50, b:140, h:65, xoff:10, yoff:10}) + `g2().img({uri:'img/imageTst.png',x:50,y:50,b:140,h:65,xoff:10,yoff:10}) .rec({x: 50, y: 50, b: 150, h: 75})`), new Test('img-13', - `g2().img({uri:'img/imageTst.png', x: 50, y: 50, b:140, h:65, xoff: 10, yoff: 10, w:0.5}) + `g2().img({uri:'img/imageTst.png',x:50,y:50,b:140,h:65, + xoff:10,yoff:10,w:0.5}) .beg({x:50, y:50, w:0.5}) .rec({b: 150, h: 75}) .end()`), new Test('img-14', - `g2().img({uri:'img/imageTst.png', x: 10, y: 10, sb: 100, sh: 100, h: 60})`), + `g2().img({uri:'img/imageTst.png',x:10,y:10,sb:100,sh:100,h:60})`), new Test('img-15', - `g2().img({uri:'img/imageTst.png', x: 10, y: 10, sb: 100, sh: 100, h: 60, w: 0.5})`), + `g2().img({uri:'img/imageTst.png',x:10,y:10,sb:100,sh:100,h:60,w:0.5})`), new Test('img-16', `g2().view({cartesian:true}) @@ -180,22 +196,25 @@ g2().img({uri:'unknown.png',x:1,y:1,b:30,h:30})`), new Test('img-18', `g2().view({cartesian:true}) - .img({uri:'img/imageTst.png', x: 10, y: 10, scl:.4}) - .img({uri:'img/imageTst.png', x: 80, y: 50, scl:.4}) - .img({uri:'img/imageTst.png', x: 160, y: 100, scl:.4})`), + .img({uri:'img/imageTst.png',x:10,y:10,scl:.4}) + .img({uri:'img/imageTst.png',x:80,y:50,scl:.4}) + .img({uri:'img/imageTst.png',x:160,y:100,scl:.4})`), new Test('img-19', - `g2().view({cartesian:true}) .img({uri:'img/imageTst.png', x: 10, y: 10, sy:50, scl:.4}) + `g2().view({cartesian:true}) + .img({uri:'img/imageTst.png',x:10,y:10,sy:50,scl:.4}) .cir({x:10,y:10,r:5})`), new Test('beg', - `g2().beg({w:0.2,scl:2,ls:'#666',fs:'orange',lw:3,lc:'round',lj:'round'}) + `g2().beg({w:0.2,scl:2,ls:'#666',fs:'orange', + lw:3,lc:'round',lj:'round'}) .rec({x:30,y:10,b:30,h:20}) .cir({x:130,y:20,r:20,fs:'green'}) .end()`), new Test('end', - `g2().beg({w:0.2,scl:2,ls:'#666',fs:'orange',lw:3,lc:'round',lj:'round'}) + `g2().beg({w:0.2,scl:2,ls:'#666',fs:'orange', + lw:3,lc:'round',lj:'round'}) .rec({x:30,y:10,b:30,h:20}) .end() .cir({x:130,y:20,r:20,fs:'green'})`), @@ -231,7 +250,8 @@ g2().img({uri:'unknown.png',x:1,y:1,b:30,h:30})`), `g2().drw({d:'M100,10L123.5,82.4L61,37.6'+'L138,37.6L76.5,82.4Z'})`), new Test('drw-3', - `g2().drw({lw:4,ls:'#080',fs:'#0f0',d:'M100,10L123.5,82.4L61,37.6'+'L138,37.6L76.5,82.4Z'})`), + `g2().drw({lw:4,ls:'#080',fs:'#0f0', + d:'M100,10L123.5,82.4L61,37.6'+'L138,37.6L76.5,82.4Z'})`), new Test('del', `g2().rec({x:60,y:30,b:80,h:40}).del().cir({x:100,y:50,r:35})`), diff --git a/docs/index/index.ext.js b/docs/index/index.ext.js index 6f22161..fb6896c 100644 --- a/docs/index/index.ext.js +++ b/docs/index/index.ext.js @@ -8,7 +8,8 @@ new TestContainer("ext", `g2().spline({pts:[50,20,50,80,150,20],closed:false,lw:4,ls:'#080'})`), new Test('spline-3', - `g2().spline({pts:[50,30,150,20,150,80,50,70],closed:true,lw:4,ls:'#080',fs:'orange'})`), + `g2().spline({pts:[50,30,150,20,150,80,50,70],closed:true, + lw:4,ls:'#080',fs:'orange'})`), new Test('label', `g2().view({cartesian:true}) diff --git a/docs/index/index.mec.js b/docs/index/index.mec.js index f3ef79b..cc70729 100644 --- a/docs/index/index.mec.js +++ b/docs/index/index.mec.js @@ -78,15 +78,18 @@ g2().view({cartesian:true}) new Test('rope', `let A = {x:50,y:30}, B = {x:200,y:75}; g2().view({cartesian:true}) - .pulley({...A,r:20}).pulley2({...B,r:40}).rope({p1:A,r1:20,p2:B,r2:40})`), + .pulley({...A,r:20}).pulley2({...B,r:40}) + .rope({p1:A,r1:20,p2:B,r2:40})`), new Test('ground', - `g2().ground({pts:[25,25,25,75,75,75,75,25,125,25],pos:'left'})`), + `g2().ground({pts:[25,25,25,75,75,75,75,25,125,25], + pos:'left'})`), new Test('load', `g2().view({cartesian:true}) .bar({x1:20,y1:50,x2:220,y2:50}) - .load({pts:[20,50,30,140,250,90,220,50],lw:1,w:-Math.PI/3,ls:"blue"})`), + .load({pts:[20,50,30,140,250,90,220,50], + lw:1,w:-Math.PI/3,ls:"blue"})`), new Test('load-2', `g2().view({cartesian:true}) @@ -113,12 +116,12 @@ g2().view({cartesian:true}) .nod({...C,scl:1.5}) .nod({...D,scl:1.5}) .nodflt({...E,w:-Math.PI/2,scl:1.5}) - .ground({pts:[{x:E.x-23,y:E.y+20},{x:A.x-23,y:A.y-18},{x:D.x,y:A.y-18}]}) + .ground({pts:[{x:E.x-23,y:E.y+20}, + {x:A.x-23,y:A.y-18},{x:D.x,y:A.y-18}]}) .vec({x1:D.x,y1:D.y,x2:D.x+50,y2:D.y,ls:'darkred',lw:2}) .vec({x1:B.x,y1:B.y,x2:B.x,y2:B.y-20,ls:'darkred',lw:0.5}) .dim({x1:E.x,y1:E.y+15,x2:D.x,y2:E.y+15}).label({str:'b',loc:'s'}) .dim({x1:D.x,y1:E.y+15,x2:B.x,y2:E.y+15}).label({str:'b',loc:'s'}) .dim({x1:B.x+15,y1:E.y,x2:B.x+15,y2:D.y}).label({str:'b',loc:'w'}) .dim({x1:B.x+15,y1:D.y,x2:B.x+15,y2:B.y}).label({str:'b',loc:'w'})`) - ]); diff --git a/docs/tests.html b/docs/tests.html index c642b99..c30194d 100644 --- a/docs/tests.html +++ b/docs/tests.html @@ -23,7 +23,7 @@ - +

g2 Tests

g2.js, g2.ext.js, g2.mec.js are referenced. canvas and image should look alike.