konvajs

selecting by drawing a box around objects in konva

寵の児 提交于 2019-12-04 14:13:01
Is there an example or way of drawing a box around multiple objects on the konva canvas and by doing so selecting the objects which are inside this box with some kind of indicator around them? Here's a working snippet. Uses simple rect-overlap collision detection and corrects drag rect co-ordinates if user chooses to drag north or east. Should get you going. // Set up the canvas and shapes var s1 = new Konva.Stage({container: 'container1', width: 300, height: 200}); var layer1 = new Konva.Layer({draggable: false}); s1.add(layer1); // draw a background rect to catch events. var r1 = new Konva

How to make selection box in Canvas to select any object it touches not only objects it embraces?

放肆的年华 提交于 2019-12-04 13:36:25
There is a great tutorial Selecting Multiple Objects with KineticJS that teaches you how to create a selection box in HTML Canvas in order to select multiple objects, but the author Michelle Higgins wrote his code to select object that embraced by the selection box. The following JavaScript code expresses the algorithm: var pos = rectSel.getAbsolutePosition(); //get the extents of the selection box var selRecXStart = parseInt(pos.x); var selRecXEnd = parseInt(pos.x) + parseInt(rectSel.attrs.width); var selRecYStart = parseInt(pos.y); var selRecYEnd = parseInt(pos.y) + parseInt(rectSel.attrs

KonvaJS: How to connect two shapes with an arrow?

佐手、 提交于 2019-11-30 03:56:39
问题 I would like to use Konvajs to do below tasks: draw two rectangle groups on canvas. Each group contains a rectangle, text, and a circle When I use the mouse to drag from the circle, it draws an arrow while dragging. When I drop the arrow into another group, it stops drawing and connects the two groups edge to edge Something like this: Are there any native methods that support connections between shapes? Could anyone show me some examples please? 回答1: I have connected Konva.Circles. But the

Animate drawing of path on HTML5 canvas

假如想象 提交于 2019-11-29 16:51:01
My problem is how to animate the drawing of a path between two points. Consider a curved line or path between two points, A & B. I can draw this easily on the canvas using the line drawing functions in Konvajs. However, what I actually want is to animate the revealing of the line so that it starts from point A and progressively draws to point B. The reveal should be animated so I can apply pleasing easings. As a comparable example, see the brief video on this site https://coggle.it/ where the video shows the creation of a new box and the line draws to connect it to the old. Here is a potential

Vue.js Konva library to display a simple image, what am I missing?

让人想犯罪 __ 提交于 2019-11-29 11:59:54
So I went through the sample code listed on the vue-konva page. Although it samples creating shapes I understood it enough to try to display a simple image to start. Here is the base code. My question lies in how do I attach the actual image file to the "image" property. Or if I am missing something else. <template> <div id="app"> <h1>Display Image via Konva</h1> <div> <v-stage ref="stage" :config="configKonva"> <v-layer ref="layer"> <v-image :config="configImg"></v-image> </v-layer> </v-stage> </div> </div> </template> <script> import Vue from 'vue'; import VueKonva from 'vue-konva' Vue.use

Animate drawing of path on HTML5 canvas

最后都变了- 提交于 2019-11-28 11:30:09
问题 My problem is how to animate the drawing of a path between two points. Consider a curved line or path between two points, A & B. I can draw this easily on the canvas using the line drawing functions in Konvajs. However, what I actually want is to animate the revealing of the line so that it starts from point A and progressively draws to point B. The reveal should be animated so I can apply pleasing easings. As a comparable example, see the brief video on this site https://coggle.it/ where the