UNPKG

dojox

Version:

Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.

55 lines (47 loc) 1.46 kB
<html> <head> <title>Testing add/remove shape</title> <style type="text/css"> @import "../../../../dojo/resources/dojo.css"; @import "../../../../dijit/tests/css/dijitTests.css"; @import "../../../../dijit/themes/tundra/tundra.css"; </style> <!-- SVGWEB { --> <meta name="svg.render.forceflash" content="true"/> <script src="svgweb/src/svg.js" data-path="svgweb/src"></script> <script src="../../../../dojo/dojo.js" data-dojo-config="isDebug:true,forceGfxRenderer:'svg'" type="text/javascript"></script> <!-- } --> <script type="text/javascript"> dojo.require("dojox.gfx"); dojo.require("dijit.form.CheckBox"); dojo.require("dojo.parser"); var surface = null, shape = null; createSurface = function(){ surface = dojox.gfx.createSurface("test", 300, 300); }; flip = function(){ if(dojo.byId("cb").checked){ if(!shape){ //shape = surface.createRect({x: 100, y: 100, width: 100, height: 100}) shape = surface.createCircle({cx: 150, cy : 150, r: 50}) .setFill("yellow").setStroke({color: "red", width: 3}); }else{ surface.add(shape); } }else{ surface.remove(shape); } } dojo.addOnLoad(createSurface); </script> </head> <body class="tundra"> <h1>Testing add/remove shape</h1> <p> <input type="checkbox" dojoType="dijit.form.CheckBox" id="cb" name="cb" onClick="flip()"> <label for="cb">Add shape to the surface</label> </p> <div id="test" style="width: 300px; height: 300px;"></div> <p>That's all Folks!</p> </body> </html>