Last active
August 29, 2015 14:04
-
-
Save diverted247/80c78a71f05f48273830 to your computer and use it in GitHub Desktop.
SVG Elliptical Arc example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>txt.graphics.decodeSVGPath( path )</title> | |
<script type="text/javascript" src="../src/easeljs-NEXT.min.js"></script> | |
<script type="text/javascript" src="../src/txt/Graphics.js"></script> | |
<script type="text/javascript"> | |
var canvas; | |
var stage; | |
var PIXEL_RATIO = (function () { | |
var ctx = document.createElement("canvas").getContext("2d"), | |
dpr = window.devicePixelRatio || 1, | |
bsr = ctx.webkitBackingStorePixelRatio || | |
ctx.mozBackingStorePixelRatio || | |
ctx.msBackingStorePixelRatio || | |
ctx.oBackingStorePixelRatio || | |
ctx.backingStorePixelRatio || 1; | |
return dpr / bsr; | |
})(); | |
createHiDPICanvas = function(w, h, ratio) { | |
if (!ratio) { ratio = PIXEL_RATIO; } | |
var can = document.createElement("canvas"); | |
can.width = w * ratio; | |
can.height = h * ratio; | |
can.style.width = w + "px"; | |
can.style.height = h + "px"; | |
can.getContext("2d").setTransform(ratio, 0, 0, ratio, 0, 0); | |
return can; | |
} | |
function init() { | |
canvas = createHiDPICanvas( 1800 , 1800 , 1 ); | |
document.body.appendChild( canvas ); | |
stage = new createjs.Stage(canvas); | |
var a = new createjs.Shape(); | |
a.graphics.setStrokeStyle( 4 ); | |
a.graphics.beginStroke("#00F"); | |
a.graphics.beginFill("#F00"); | |
a.graphics.decodeSVGPath( 'M 300 200 h -150 a 150 150 0 1 0 150 -150 z' ); | |
stage.addChild(a); | |
var b = new createjs.Shape(); | |
b.graphics.setStrokeStyle( 4 ); | |
b.graphics.beginStroke("#000"); | |
b.graphics.beginFill("#FF0"); | |
b.graphics.decodeSVGPath( 'M 275 175 v -150 a 150 150 0 0 0 -150 150 z' ); | |
stage.addChild(b); | |
var c = new createjs.Shape(); | |
c.graphics.setStrokeStyle( 4 ); | |
c.graphics.beginStroke("#F00"); | |
c.graphics.decodeSVGPath( 'M 600 400 l 50 -25 a25 25 -30 0 1 50 -25 l 50 -25 a25 50 -30 0 1 50 -25 l 50 -25 a25 75 -30 0 1 50 -25 l 50 -25 a 25 100 -30 0 1 50 -25 l50 -25' ); | |
stage.addChild(c); | |
var d = new createjs.Shape(); | |
d.graphics.setStrokeStyle( 4 ); | |
d.graphics.beginStroke("#F00"); | |
d.graphics.decodeSVGPath( 'M 600,75 a100,50 0 0,0 100,50' ); | |
stage.addChild(d); | |
d = new createjs.Shape(); | |
d.graphics.setStrokeStyle( 4 ); | |
d.graphics.beginStroke("#0F0"); | |
d.graphics.decodeSVGPath( 'M 600,75 a100,50 0 0,1 100,50' ); | |
stage.addChild(d); | |
d = new createjs.Shape(); | |
d.graphics.setStrokeStyle( 4 ); | |
d.graphics.beginStroke("#00F"); | |
d.graphics.decodeSVGPath( 'M 600,75 a100,50 0 1,0 100,50' ); | |
stage.addChild(d); | |
d = new createjs.Shape(); | |
d.graphics.setStrokeStyle( 4 ); | |
d.graphics.beginStroke("#F0F"); | |
d.graphics.decodeSVGPath( 'M 600,75 a100,50 0 1,1 100,50' ); | |
stage.addChild(d); | |
stage.update(); | |
} | |
</script> | |
</head> | |
<body onload="init()"> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment