mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
rewrote shadow logic. fill and strokes are now both taken into account. shape and shadow opacities now work well together
This commit is contained in:
@@ -147,17 +147,17 @@ suite('Line', function() {
|
||||
shadowColor: 'black',
|
||||
shadowBlur: 20,
|
||||
shadowOffset: 10,
|
||||
shadowOpacity: 0.3
|
||||
shadowOpacity: 0.5,
|
||||
draggable: true
|
||||
});
|
||||
|
||||
layer.add(line);
|
||||
stage.add(layer);
|
||||
|
||||
|
||||
|
||||
var trace = layer.getContext().getTrace();
|
||||
//console.log(trace);
|
||||
assert.equal(trace, 'clearRect(0,0,578,200);save();lineJoin=round;transform(1,0,0,1,0,0);beginPath();moveTo(73,160);lineTo(340,23);lineCap=round;save();globalAlpha=0.3;shadowColor=black;shadowBlur=20;shadowOffsetX=10;shadowOffsetY=10;lineWidth=20;strokeStyle=blue;stroke();restore();lineCap=round;lineWidth=20;strokeStyle=blue;stroke();restore();');
|
||||
var relaxedTrace = layer.getContext().getTrace(true);
|
||||
//console.log(relaxedTrace);
|
||||
assert.equal(relaxedTrace, 'clearRect();save();save();globalAlpha;shadowColor;shadowBlur;shadowOffsetX;shadowOffsetY;drawImage();restore();drawImage();restore();');
|
||||
|
||||
});
|
||||
});
|
@@ -31,7 +31,7 @@ suite('Rect', function(){
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('add rect with shadow, rotation, corner radius, and opacity', function(){
|
||||
test('add rect with shadow, corner radius, and opacity', function(){
|
||||
var stage = addStage();
|
||||
|
||||
var layer = new Kinetic.Layer();
|
||||
@@ -63,8 +63,8 @@ suite('Rect', function(){
|
||||
assert.equal(rect.getCornerRadius(), 5);
|
||||
|
||||
var trace = layer.getContext().getTrace();
|
||||
//console.log(layer.getContext().traceArr);
|
||||
assert.equal(trace, 'clearRect(0,0,578,200);save();globalAlpha=0.4;transform(1,0,0,1,100,50);beginPath();moveTo(5,0);lineTo(95,0);arc(95,5,5,4.712,0,false);lineTo(100,45);arc(95,45,5,0,1.571,false);lineTo(5,50);arc(5,45,5,1.571,3.142,false);lineTo(0,5);arc(5,5,5,3.142,4.712,false);closePath();save();globalAlpha=0.2;shadowColor=red;shadowBlur=10;shadowOffsetX=5;shadowOffsetY=5;fillStyle=green;fill();restore();fillStyle=green;fill();lineWidth=2;strokeStyle=blue;stroke();restore();');
|
||||
//console.log(trace);
|
||||
assert.equal(trace, 'clearRect(0,0,578,200);save();save();globalAlpha=0.2;shadowColor=red;shadowBlur=10;shadowOffsetX=5;shadowOffsetY=5;drawImage([object HTMLCanvasElement],0,0);restore();globalAlpha=0.4;drawImage([object HTMLCanvasElement],0,0);restore();');
|
||||
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user