manual test for drawHitFromCache with alpha threshold

This commit is contained in:
lavrton
2015-04-16 09:23:55 +07:00
parent 28d0a6f112
commit 681b81705c
5 changed files with 66 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
* Konva JavaScript Framework v0.9.5
* http://konvajs.github.io/
* Licensed under the MIT or GPL Version 2 licenses.
* Date: Tue Apr 14 2015
* Date: Thu Apr 16 2015
*
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
@@ -3579,6 +3579,9 @@ var Konva = {};
* });
*/
toImage: function(config) {
if (!config || !config.callback) {
throw "callback required for toImage method config argument";
}
Konva.Util._getImage(this.toDataURL(config), function(img) {
config.callback(img);
});

4
konva.min.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1431,6 +1431,9 @@
* });
*/
toImage: function(config) {
if (!config || !config.callback) {
throw "callback required for toImage method config argument";
}
Konva.Util._getImage(this.toDataURL(config), function(img) {
config.callback(img);
});

View File

@@ -384,4 +384,59 @@ suite('Manual', function() {
showHit(layer);
});
// ======================================================
test('image hit region with alpha threshold, mouseover circle', function(done) {
var stage = addStage();
var layer = new Konva.Layer();
stage.add(layer);
var group = new Konva.Group();
var circle = new Konva.Circle({
x : 50,
y : 50,
fill: 'red',
radius : 40
});
var rect = new Konva.Rect({
width : 100,
height : 100,
fill : 'green',
opacity : 0.5
});
group.add(rect, circle);
group.toImage({
width : 100,
height : 100,
callback :function(img) {
var image = new Konva.Image({
image: img
});
image.cache();
image.drawHitFromCache(200);
layer.add(image);
layer.draw();
var shape = layer.getIntersection({
x : 5,
y : 5
});
assert.equal(!!shape, false, 'shape should not be detected');
image.on('mouseenter', function () {
document.body.style.cursor = 'pointer';
});
image.on('mouseleave', function () {
document.body.style.cursor = 'default';
});
done();
}
});
showHit(layer);
});
});

View File

@@ -175,8 +175,8 @@
<script src="functional/TouchEvents-test.js"></script>
<script src="functional/DragAndDropEvents-test.js"></script>
<!--&lt;!&ndash;=============== manual tests ================&ndash;&gt;-->
<!--<script src="manual/manual-test.js"></script>-->
<!--=============== manual tests ================-->
<script src="manual/manual-test.js"></script>
<script>
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }