added new getTextSize(), getTextWidth(), and getTextHeight() methods

This commit is contained in:
Eric Rowell
2012-03-31 15:40:27 -07:00
parent 8398670a47
commit 8f104a6fad
4 changed files with 87 additions and 8 deletions

View File

@@ -905,7 +905,7 @@ Test.prototype.tests = {
layer.add(rect);
stage.add(layer);
},
'SHAPES - add text': function(containerId) {
'Text - add text': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
@@ -971,6 +971,35 @@ Test.prototype.tests = {
test(text.getTextStroke() === 'red', 'text stroke should be red');
test(text.getTextStrokeWidth() === 10, 'test stroke width should be 10');
},
'Text - get metrics': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var text = new Kinetic.Text({
x: stage.width / 2,
y: stage.height / 2,
text: 'Hello World!',
fontSize: 60,
fontFamily: 'Calibri',
fontStyle: 'normal',
textFill: 'green',
fontStyle: 'italic',
align: 'center',
verticalAlign: 'middle'
});
layer.add(text);
stage.add(layer);
test(text.getTextSize().width === 407, 'text width should be 407px');
test(text.getTextSize().height === 60, 'text height should be 60px');
test(text.getTextWidth() === 407, 'text width should be 407px');
test(text.getTextHeight() === 60, 'text height should be 60px');
},
'SHAPES - get shape name': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,