-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ted Patrick
committed
Nov 20, 2014
1 parent
fe5006f
commit dff50ff
Showing
8 changed files
with
597 additions
and
16 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>txt: CharacterText + Single Word Example</title> | ||
|
||
<script type="text/javascript" src="../../dist/easeljs-NEXT.min.js"></script> | ||
<script type="text/javascript" src="../../dist/txt.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( 1000 , 1000 , 2 ); | ||
document.body.appendChild( canvas ); | ||
|
||
stage = new createjs.Stage(canvas); | ||
|
||
var text; | ||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.TOP_LEFT, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:0, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.TOP_CENTER, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:410, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.TOP_RIGHT, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:820, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.MIDDLE_LEFT, | ||
width:115.2541, | ||
height:73, | ||
size:52, | ||
x:0, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.MIDDLE_CENTER, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:410, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.MIDDLE_RIGHT, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:820, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.BOTTOM_LEFT, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:0, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.BOTTOM_CENTER, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:410, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'Save', | ||
font:'lato', | ||
align:txt.Align.BOTTOM_RIGHT, | ||
width:115, | ||
height:73, | ||
size:52, | ||
x:820, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
stage.update(); | ||
|
||
} | ||
|
||
</script> | ||
|
||
</head> | ||
<body onload="init()"> | ||
</body> | ||
</html> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>txt: CharacterText + Wordwrap Nature and Newline Example</title> | ||
|
||
<script type="text/javascript" src="../../dist/easeljs-NEXT.min.js"></script> | ||
<script type="text/javascript" src="../../dist/txt.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( 1000 , 1000 , 2 ); | ||
document.body.appendChild( canvas ); | ||
|
||
stage = new createjs.Stage(canvas); | ||
|
||
var text; | ||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.TOP_LEFT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:0, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.TOP_CENTER, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:410, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.TOP_RIGHT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:820, | ||
y:0, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.MIDDLE_LEFT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:0, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.MIDDLE_CENTER, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:410, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.MIDDLE_RIGHT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:820, | ||
y:410, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.BOTTOM_LEFT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:0, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.BOTTOM_CENTER, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:410, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
text = new txt.CharacterText( { | ||
text:'TTT YYY\nWW', | ||
font:'opensans', | ||
align:txt.Align.BOTTOM_RIGHT, | ||
width:400, | ||
height:400, | ||
size:150, | ||
tracking: 0, | ||
x:820, | ||
y:820, | ||
debug:true | ||
} ); | ||
|
||
stage.addChild( text ); | ||
|
||
stage.update(); | ||
|
||
} | ||
|
||
</script> | ||
|
||
</head> | ||
<body onload="init()"> | ||
</body> | ||
</html> |
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
Oops, something went wrong.