I have selectionrectangle
on mousemove
(working fine). Can anybody suggest me, how to select shapes within that rectangles range on mouseup
event? My code is like(only main functions):
function onMouseDown() {
if (!isMouseDown) {
return
}
isMouseDown = true;
if (selectionrectangle) {
selectionrectangle.remove();
}
pointerPosition = stage.getPointerPosition();
x = Math.floor(pointerPosition.x)
y = Math.floor(pointerPosition.y )
originX = [];
originY = [];
originX.push(x);
originY.push(y);
selectionrectangle = new Kinetic.Rect({
x: originX[0],
y: originY[0],
width: 0,
height: 0,
stroke: 'pink',
strokeWidth: 3,
name: 'SelectionRectangle'
});
refRect = selectionrectangle;
refRect1 = selectionrectangle;
selectionrectangle.setListening(true);
mainLayer.add(selectionrectangle);
}
function onMouseMove() {
if (!isMouseDown) {
return;
};
isMouseDown = true;
pointerPosition = stage.getPointerPosition();
x = Math.floor(pointerPosition.x )
y = Math.floor(pointerPosition.y)
refRect.setWidth(x - refRect.getX());
refRect.setHeight(y - refRect.getY());
mainLayer.drawScene();
}
function onMouseUp() {
isMouseDown = false;
stage.add(mainLayer);
}