0

What I want to do is

1) I want to draw a length on image and want to add handle to edit it.

2) When I want to zoom the image the drawn length should match the zoom level.

ctx.beginPath();
            ctx.moveTo(linearr[i].x1, linearr[i].y1);
            ctx.lineTo(linearr[i].x2, linearr[i].y2);
            ctx.closePath();
            ctx.stroke();

            ctx.beginPath();
            ctx.arc(linearr[i].x1, linearr[i].y1, 2, 0, Math.PI * 2, true);
            ctx.closePath();
            ctx.fillStyle = 'green';
            ctx.fill();
            ctx.stroke();

            ctx.beginPath();
            ctx.arc(linearr[i].x2, linearr[i].y2, 2, 0, Math.PI * 2, true);
            ctx.closePath();
            ctx.fillStyle = 'green';
            ctx.fill();
            ctx.stroke();

where linearr is an array

Nikhil Ghuse
  • 1,258
  • 14
  • 31

1 Answers1

1

Papaya already supports a ruler tool, if that's what you're looking for.

Otherwise, see the function papaya.viewer.Viewer.prototype.drawRuler() for an example of how to use the screen transform to draw lines, which includes the zoom transform. Another function that might be helpful to you is this.selectedSlice.findProximalRulerHandle().

martinez314
  • 12,162
  • 5
  • 36
  • 63
  • It lets you grab and drag the endpoints, so it's dynamic in that way, but maybe you want to be able to draw and store multiple lines? The functions I mentioned should get you going in the right direction. – martinez314 Jun 08 '18 at 14:25
  • I am succeed to draw different length but the issue is that how can i get handle should i write that function on mouse down..? – Nikhil Ghuse Jun 09 '18 at 12:09
  • But can you tell me how to draw ruler to particular slice..? – Nikhil Ghuse Jun 23 '18 at 11:42