mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
label offsets, serialization, and deserialization now work. fixes #406
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user