mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 08:46:44 +08:00
manual test for drawHitFromCache with alpha threshold
This commit is contained in:
5
konva.js
5
konva.js
@@ -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
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
<script src="functional/TouchEvents-test.js"></script>
|
||||
<script src="functional/DragAndDropEvents-test.js"></script>
|
||||
|
||||
<!--<!–=============== manual tests ================–>-->
|
||||
<!--<script src="manual/manual-test.js"></script>-->
|
||||
<!--=============== manual tests ================-->
|
||||
<script src="manual/manual-test.js"></script>
|
||||
|
||||
<script>
|
||||
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
|
||||
|
||||
Reference in New Issue
Block a user