mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
fixed pixel ratio issue with buffer canvas usage
This commit is contained in:
36
test/manual/manual-test.js
Normal file
36
test/manual/manual-test.js
Normal file
@@ -0,0 +1,36 @@
|
||||
suite('Manual', function() {
|
||||
// ======================================================
|
||||
test('tween node', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
var rect = new Kinetic.Rect({
|
||||
x: 100,
|
||||
y: 100,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'green',
|
||||
stroke: 'black',
|
||||
strokeWidth: 2,
|
||||
opacity: 0.2
|
||||
});
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
var tween = new Kinetic.Tween({
|
||||
node: rect,
|
||||
duration: 1,
|
||||
x: 400,
|
||||
y: 30,
|
||||
rotation: Math.PI * 2,
|
||||
opacity: 1,
|
||||
strokeWidth: 6,
|
||||
scaleX: 1.5
|
||||
});
|
||||
|
||||
|
||||
tween.play();
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
@@ -90,6 +90,9 @@
|
||||
<script src="functional/KineticEvents-test.js"></script>
|
||||
<script src="functional/DragAndDropEvents-test.js"></script>
|
||||
|
||||
<!--=============== manual tests ================-->
|
||||
<script src="manual/manual-test.js"></script>
|
||||
|
||||
<script>
|
||||
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
|
||||
else { mocha.run(); }
|
||||
|
||||
@@ -14,6 +14,30 @@ suite('Stage', function() {
|
||||
});
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('test stage buffer canvas and hit buffer canvas', function() {
|
||||
var container = document.createElement('div');
|
||||
container.id = 'container';
|
||||
|
||||
kineticContainer.appendChild(container);
|
||||
|
||||
// simulate pixelRatio = 2
|
||||
Kinetic.pixelRatio = 2;
|
||||
|
||||
var stage = new Kinetic.Stage({
|
||||
container: 'container',
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
|
||||
|
||||
assert.equal(stage.bufferCanvas.getPixelRatio(), 1);
|
||||
assert.equal(stage.bufferHitCanvas.getPixelRatio(), 2);
|
||||
|
||||
// reset
|
||||
Kinetic.pixelRatio = 1;
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('instantiate stage with dom element', function() {
|
||||
var container = document.createElement('div');
|
||||
|
||||
Reference in New Issue
Block a user