mirror of
https://github.com/konvajs/konva.git
synced 2026-01-23 13:26:07 +08:00
Unit tests added for issue #249. Fixed rendering of TextPath along vertical lines. Added unit tests for SVG-as-images.
This commit is contained in:
@@ -36,6 +36,98 @@ Test.Modules['TEXT PATH'] = {
|
||||
|
||||
test(textpath.getClassName() === 'TextPath', 'getClassName should be TextPath');
|
||||
},
|
||||
'Find Next Segment when Arc is in Path': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 1024,
|
||||
height: 480,
|
||||
throttle: 80,
|
||||
scale: 1,
|
||||
x: 50,
|
||||
y: 10
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var c = "M 50 50 a 150 50 0 0 1 250 50 l 50 0";
|
||||
var path = new Kinetic.Path({
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(path);
|
||||
|
||||
var textpath = new Kinetic.TextPath({
|
||||
fill: 'black',
|
||||
fontSize: '10',
|
||||
text: 'All the world\'s a stage, and all the men and women merely players. They have their exits and their entrances; And one man in his time plays many parts.',
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(textpath);
|
||||
stage.add(layer);
|
||||
},
|
||||
'Render Text Along Vertical Line': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 1024,
|
||||
height: 480,
|
||||
throttle: 80,
|
||||
scale: 1,
|
||||
x: 50,
|
||||
y: 10
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
// Top Down
|
||||
var c = "M 50,10 50,150";
|
||||
|
||||
var path = new Kinetic.Path({
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(path);
|
||||
|
||||
var textpath = new Kinetic.TextPath({
|
||||
stroke: 'black',
|
||||
strokeWidth: 1,
|
||||
fill: 'orange',
|
||||
fontSize: '18',
|
||||
fontFamily: 'Arial',
|
||||
text: 'The quick brown fox jumped over the lazy dog\'s back',
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(textpath);
|
||||
|
||||
|
||||
// Bottom up
|
||||
c = "M 150,150 150,10";
|
||||
|
||||
path = new Kinetic.Path({
|
||||
stroke: 'red',
|
||||
strokeWidth: 1,
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(path);
|
||||
|
||||
textpath = new Kinetic.TextPath({
|
||||
stroke: 'black',
|
||||
strokeWidth: 1,
|
||||
fill: 'orange',
|
||||
fontSize: '18',
|
||||
fontFamily: 'Arial',
|
||||
text: 'The quick brown fox jumped over the lazy dog\'s back',
|
||||
data: c
|
||||
});
|
||||
|
||||
layer.add(textpath);
|
||||
stage.add(layer);
|
||||
|
||||
},
|
||||
'Render Text Along two connected Bezier': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
|
||||
@@ -205,9 +205,9 @@ Test.Modules.IMAGE = {
|
||||
image: imageObj,
|
||||
draggable: true,
|
||||
shadowColor: 'black',
|
||||
shadowBlur: 10,
|
||||
shadowOffset: [20, 20],
|
||||
shadowOpacity: 0.2
|
||||
shadowBlur: 10,
|
||||
shadowOffset: [20, 20],
|
||||
shadowOpacity: 0.2
|
||||
});
|
||||
|
||||
// override color key with black
|
||||
@@ -226,5 +226,72 @@ Test.Modules.IMAGE = {
|
||||
imageObj.src = '../assets/lion.png';
|
||||
|
||||
showHit(layer);
|
||||
},
|
||||
'image with svg source': function(containerId) {
|
||||
var imageObj = new Image();
|
||||
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
imageObj.onload = function() {
|
||||
|
||||
var tiger = new Kinetic.Image({
|
||||
x: 0,
|
||||
y: 0,
|
||||
image: imageObj,
|
||||
draggable: true,
|
||||
scale: 0.25
|
||||
});
|
||||
|
||||
layer.add(tiger);
|
||||
stage.add(layer);
|
||||
};
|
||||
imageObj.src = '../assets/Ghostscript_Tiger.svg';
|
||||
},
|
||||
'opacity test for image with svg source': function(containerId) {
|
||||
var imageObj = new Image();
|
||||
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
layer.add(new Kinetic.Line({
|
||||
points: [0,0,578,200],
|
||||
stroke: 'black',
|
||||
strokeWidth: 5
|
||||
}));
|
||||
|
||||
imageObj.onload = function() {
|
||||
|
||||
var tiger = new Kinetic.Image({
|
||||
x: 0,
|
||||
y: 0,
|
||||
image: imageObj,
|
||||
draggable: true,
|
||||
scale: 0.25,
|
||||
opacity: 0.5
|
||||
});
|
||||
|
||||
layer.add(tiger);
|
||||
|
||||
layer.add(new Kinetic.Line({
|
||||
points: [578,0,0,200],
|
||||
stroke: 'blue',
|
||||
strokeWidth: 5
|
||||
}));
|
||||
|
||||
stage.add(layer);
|
||||
|
||||
};
|
||||
imageObj.style.opacity = 0.5;
|
||||
imageObj.src = '../assets/Ghostscript_Tiger.svg';
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user