Skip to content

Commit

Permalink
0.8.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted Patrick committed Nov 20, 2014
1 parent fe5006f commit dff50ff
Show file tree
Hide file tree
Showing 8 changed files with 597 additions and 16 deletions.
4 changes: 2 additions & 2 deletions dist/txt.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ var txt;
}
continue;
}
else if (hPosition + currentWord.measuredWidth > this.width && i > 0) {
else if (hPosition + currentWord.measuredWidth > this.width && i > 0 && currentLine.children.length > 0) {
if (this.lineHeight != null) {
lastHeight = currentLine.y + this.lineHeight;
}
Expand Down Expand Up @@ -345,7 +345,7 @@ var txt;
var len = this.lines.length;
for (var i = 0; i < len; i++) {
line = this.lines[i];
if (line.lastWord().lastCharacter()) {
if (line.lastWord() != undefined && line.lastWord().lastCharacter()) {
line.measuredWidth -= line.lastWord().lastCharacter().trackingOffset();
}
measuredHeight += line.measuredHeight;
Expand Down
179 changes: 179 additions & 0 deletions examples/CharacterText/single_word_oneline.html
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>
188 changes: 188 additions & 0 deletions examples/CharacterText/wordwrap_natural_newline.html
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>
2 changes: 1 addition & 1 deletion examples/Text/single_word_oneline.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>txt: Text + MultiLine Alignment Example</title>
<title>txt: Text + Single Word Example</title>

<script type="text/javascript" src="../../dist/easeljs-NEXT.min.js"></script>
<script type="text/javascript" src="../../dist/txt.js"></script>
Expand Down
Loading

0 comments on commit dff50ff

Please sign in to comment.