Loading...
Parmalink
-
Download as svg
-
Output pixel based svg
-
enable debug
⇔
/* # Online programmatic 2D CAD ## How to use. Edit this box or drag drop file to image view. If you use visicut, please use pixel based svg. ## Function reference NOTE: details means number of segment. - Generate nodes - General - empty() - svgtext({x: 0, y:0, str:"string to draw") // Experimental. - Line based - line({x1:0, y1:0, x2:1, y2:1}) - square({width:10, height:10}) - roundedSquare({width:10, height:10, round:1}) - arc({end: 90, details: 20}) - bezier({x1:0, y1:0, x2:1, y2:0, x3:1, y3:0, x4:1, y4:1, details: 20}) - polyline([[0,0], [1,1]]) - text({str: "string to draw"}) - Polygon based - psquare({width: 10, height: 10}) - polygon([[0,0], [1,0], [1,1], [0, 1]]) - Aggrigate nodes - union([]) - cut({from: obj, x1:0, y1:0, x2:1, y2:1}) - noOverwrapUnion([], {margin: 10}) - repeat({obj: obj, times: 1, stepX: 0, stepY: 0}) - Methods - node.translate({x: 0, y: 0}) - node.rotate(0) - node.scale(1) || node.scale({x: 1, y: 1}) - node.mirrorX() - node.mirrorY() - Misc - sin(dig), cos(dig), tan(dig) - getNodeArea(obj) = [x1, x2, y1, y2] - getNodeSize(obj) = [width, height] - log(msg) - warn(msg) - assert(cond, msg) */ function lines() { var rv = []; for(var i=0;i<50;i++) { rv.push(line({x1:i*2,y1:0,x2:0,y2:100-i*2})); } return union(rv); } function box() { return union([ square({width: 100, height: 100}), lines(), lines().rotate(180).translate({x: 100,y:100}), ]); } function eye(){ return union([ box(), box() .mirrorX() .translate({y:100}) .scale(0.5) .translate({x: 25, y:25}), ]) .rotate(45) .translate({x: Math.sqrt(2)*100/2}) .translate({x: 10, y: 10}); } function main() { log("This is log."); warn("This is warning."); assert(1==1, "This is not shown"); assert(1==2, "This will be shown"); return cut({ from: union([ eye(), arc().scale(70).translate({x:82, y:82}), polyline([[10,10],[10,20],[20,20],[20,30],[30,30]]), roundedSquare({width:150,height:150,round:10}).translate({x:5,y:5}), svgtext({x: 70, y: 85, str:"hello world"}), text({str:"本日は晴天なり"}), polygon([[60,60], [90,60],[90,90],[60,90]]), ]), x1: 80, y1: 20, x2: 100, y2: 40, }); }