label offsets, serialization, and deserialization now work. fixes #406

This commit is contained in:
Eric Rowell
2013-05-20 09:42:16 -07:00
parent 35b1f61bda
commit ae326a9c89
2 changed files with 66 additions and 33 deletions

View File

@@ -54,5 +54,25 @@ Test.Modules.LABEL = {
test(label.getType() === 'Group', 'label should be a group');
test(label.getClassName() === 'Label', 'label class name should be Label');
var json = label.toJSON();
console.log(json);
},
'create label from json': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var json = '{"attrs":{"x":100,"y":100,"draggable":true,"text":{"width":"auto","height":"auto","text":"Hello big world","fontSize":50,"lineHeight":1.2,"fill":"green"},"tag":{"fill":"#bbb","stroke":"#333","shadowColor":"black","shadowBlur":10,"shadowOffsetX":10,"shadowOffsetY":10,"shadowOpacity":0.2,"lineJoin":"round","pointerDirection":"up","pointerWidth":20,"pointerHeight":20,"cornerRadius":5}},"className":"Label","nodeType":"Group"}';
var layer = new Kinetic.Layer();
var label = Kinetic.Node.create(json);
layer.add(label);
stage.add(layer);
}
};