mirror of
https://github.com/konvajs/konva.git
synced 2026-01-23 13:26:07 +08:00
clipping regions now work correctly when device pixel ratio != 1
This commit is contained in:
32
tests/js/unit/canvasTests.js
Normal file
32
tests/js/unit/canvasTests.js
Normal file
@@ -0,0 +1,32 @@
|
||||
Test.Modules.CANVAS = {
|
||||
'pixel ratio': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var circle = new Kinetic.Circle({
|
||||
x: 578/2,
|
||||
y: 100,
|
||||
radius: 70,
|
||||
fill: 'green',
|
||||
stroke: 'blue',
|
||||
strokeWidth: 4
|
||||
});
|
||||
|
||||
layer.add(circle);
|
||||
stage.add(layer);
|
||||
|
||||
|
||||
stage.setWidth(578/2);
|
||||
stage.setHeight(100);
|
||||
|
||||
stage.draw();
|
||||
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
Test.Modules.CONTAINER = {
|
||||
'use clipping function': function(containerId) {
|
||||
'clip': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
container: containerId,
|
||||
width: 578,
|
||||
@@ -7,10 +7,7 @@ Test.Modules.CONTAINER = {
|
||||
draggable: true
|
||||
});
|
||||
var layer = new Kinetic.Layer({
|
||||
clipFunc: function(canvas) {
|
||||
var context = canvas.getContext();
|
||||
context.rect(0, 0, 400, 100);
|
||||
}
|
||||
clip: [0, 0, stage.getWidth() / 2, 100]
|
||||
});
|
||||
var group = new Kinetic.Group();
|
||||
var circle = new Kinetic.Circle({
|
||||
|
||||
Reference in New Issue
Block a user