| 1 | <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" > |
| 2 | <head> |
| 3 | <title>Drawing Paths Test</title> |
| 4 | <style> |
| 5 | @import url("../../../dijit/themes/dijit.css"); |
| 6 | @import url("../../../dojox/drawing/resources/drawing.css"); |
| 7 | @import url("../../../dojox/drawing/resources/toolbar.css"); |
| 8 | @import url("../../../dojox/drawing/resources/GreekPalette.css"); |
| 9 | href, body{ |
| 10 | overflow:hidden; |
| 11 | } |
| 12 | .drawing{ |
| 13 | width:800px; |
| 14 | height:400px; |
| 15 | border:1px solid #ccc; |
| 16 | cursor:crosshair; |
| 17 | } |
| 18 | #data{ |
| 19 | display:block; |
| 20 | height:100px; |
| 21 | width:855px; |
| 22 | margin-top:5px; |
| 23 | } |
| 24 | button{ |
| 25 | border:2px solid #ccc; |
| 26 | border-color:#D9E1F9 #B5BCD0 #878E9D #C6CEE4; |
| 27 | background-color:#CDDCF3; |
| 28 | cursor:pointer; |
| 29 | } |
| 30 | .gfxToolbar{ |
| 31 | width:800px; |
| 32 | height:50px; |
| 33 | margin-bottom:10px; |
| 34 | border:1px solid #ccc; |
| 35 | } |
| 36 | </style> |
| 37 | |
| 38 | <script> |
| 39 | djConfig = { |
| 40 | isDebug:false, |
| 41 | parseOnLoad:true |
| 42 | }; |
| 43 | </script> |
| 44 | <script src="../../../dojo/dojo.js"></script> |
| 45 | <script> |
| 46 | dojo.require("dojo.parser"); |
| 47 | dojo.require("dojox.drawing"); |
| 48 | |
| 49 | |
| 50 | // custom Tools and Plugins need to be required |
| 51 | dojo.require("dojox.drawing.tools.TextBlock"); |
| 52 | dojo.require("dojox.drawing.tools.Rect"); |
| 53 | dojo.require("dojox.drawing.tools.Ellipse"); |
| 54 | dojo.require("dojox.drawing.tools.Line"); |
| 55 | dojo.require("dojox.drawing.tools.Path"); |
| 56 | dojo.require("dojox.drawing.tools.Pencil"); |
| 57 | |
| 58 | dojo.require("dojox.drawing.plugins.drawing.GreekPalette"); |
| 59 | dojo.require("dojox.drawing.plugins.drawing.Grid"); |
| 60 | |
| 61 | dojo.require("dojox.drawing.ui.Toolbar"); |
| 62 | dojo.require("dojox.drawing.ui.Button"); |
| 63 | |
| 64 | |
| 65 | dojo.addOnLoad(function(){ |
| 66 | dojo.connect(myDrawing, "onSurfaceReady", function(){ |
| 67 | |
| 68 | var path = function(pts, dontClosePath){ |
| 69 | var closePath = !dontClosePath; |
| 70 | myDrawing.addStencil("path", {points:pts, closePath:closePath}); |
| 71 | |
| 72 | } |
| 73 | |
| 74 | // Test Q curve |
| 75 | path([{x:210, y:210},{t:"Q", x:300, y:400},{x:400,y:210} ]) |
| 76 | |
| 77 | // Test closing path on a Q curve (have to use a double-point) |
| 78 | path([{t:"Q", x:300, y:390},{x:500, y:390},{t:"Q", x:400,y:300}, {x:300,y:390} ]) |
| 79 | |
| 80 | // test double donut |
| 81 | path([ |
| 82 | {x:10, y:390},{x:10, y:200},{x:100,y:200},{x:100,y:390}, {t:"Z"}, |
| 83 | {t:"M", x:20, y:210}, {x:90,y:210}, {x:90, y:290}, {x:20, y:290}, {t:"Z"}, |
| 84 | {t:"M", x:20, y:310}, {x:90,y:310}, {x:90, y:380}, {x:20, y:380} , {t:"Z"} |
| 85 | ]); |
| 86 | |
| 87 | // test unclosed paths |
| 88 | path([{x:300, y:10},{x:400, y:50}, {x:320, y:100}], true); |
| 89 | path([{x:400, y:10},{x:500, y:50}, {x:420, y:100}], true); |
| 90 | |
| 91 | // approximate a circle |
| 92 | path([ |
| 93 | {x:600, y:150},{t:"Q", x:600, y:100},{x:650,y:100}, {x:700, y:100}, |
| 94 | {x:700,y:150},{x:700,y:200},{x:650,y:200},{x:600,y:200},{x:600,y:150} |
| 95 | ]); |
| 96 | |
| 97 | // pencil icon |
| 98 | path([ { x:68, y:20 }, { x:80, y:32 }, { x:32, y:74 }, { x:20, y:80 }, { x:62, y:74 }, { x:80, y:80 }, { x:20, y:80 }, { x:26, y:68 }, { t:'Z' }, { t:'M', x:26, y:74 }, { x:26, y:68 }, { x:62, y:32 }, { x:68, y:38 }, { x:62, y:38 }, { x:32, y:68 } ]) |
| 99 | }); |
| 100 | }) |
| 101 | </script> |
| 102 | |
| 103 | </head> |
| 104 | <body class="tundra"> |
| 105 | <h2>Drawing Paths Test</h2> |
| 106 | <div id="conEdit" contenteditable="true"></div> |
| 107 | <div id="wrapper"> |
| 108 | |
| 109 | |
| 110 | <div dojoType="dojox.drawing.ui.Toolbar" id="gfxToolbarNode" drawingId="drawingNode" class="gfxToolbar" orient="H" tools="all" plugs="all" selected="pencil"></div> |
| 111 | |
| 112 | <div dojoType="dojox.drawing.Drawing" id="drawingNode" data-dojo-id="myDrawing" class="drawing" |
| 113 | plugins="[{'name':'dojox.drawing.plugins.drawing.Grid', 'options':{minor:20, major:100}}]"> |
| 114 | </div> |
| 115 | </div> |
| 116 | |
| 117 | <div dojoType="dojox.drawing.plugins.drawing.GreekPalette" id="greekPalette"></div> |
| 118 | </body> |
| 119 | </html> |