Created
August 12, 2014 17:58
-
-
Save diverted247/01dd381bfabdb4b7a636 to your computer and use it in GitHub Desktop.
Character Case Example - Manipulating character case at the Text control... txt.Case.Normal,txt.Case.UPPER, txt.Case.LOWER, txt.Case.SMALL_CAPS
This file contains hidden or 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: Case Example</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" src="../src/txt/Text.js"></script> | |
<script type="text/javascript" src="../src/txt/Character.js"></script> | |
<script type="text/javascript" src="../src/txt/Glyph.js"></script> | |
<script type="text/javascript" src="../src/txt/Align.js"></script> | |
<script type="text/javascript" src="../src/txt/Case.js"></script> | |
<script type="text/javascript" src="../src/txt/Font.js"></script> | |
<script type="text/javascript" src="../src/txt/Word.js"></script> | |
<script type="text/javascript" src="../src/txt/Line.js"></script> | |
<script type="text/javascript" src="../src/txt/FontLoader.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( 2000 , 1500 , 2 ); | |
document.body.appendChild( canvas ); | |
stage = new createjs.Stage(canvas); | |
stage.addChild( new txt.Text( { | |
text:'Hello World', | |
font:'belinda', | |
characterCase:txt.Case.NORMAL, | |
lineHeight:100, | |
width:2000, | |
height:1000, | |
size:100, | |
x:10, | |
y:10 | |
} ) ); | |
stage.addChild( new txt.Text( { | |
text:'Hello World', | |
font:'belinda', | |
characterCase:txt.Case.UPPER, | |
lineHeight:100, | |
width:2000, | |
height:1000, | |
size:100, | |
x:10, | |
y:110 | |
} ) ); | |
stage.addChild( new txt.Text( { | |
text:'Hello World', | |
font:'belinda', | |
characterCase:txt.Case.LOWER, | |
lineHeight:100, | |
width:2000, | |
height:1000, | |
size:100, | |
x:10, | |
y:210 | |
} ) ); | |
stage.addChild( new txt.Text( { | |
text:'Hello World', | |
font:'belinda', | |
characterCase:txt.Case.SMALL_CAPS, | |
lineHeight:100, | |
width:2000, | |
height:1000, | |
size:100, | |
x:10, | |
y:310 | |
} ) ); | |
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