Is there a way to show just a rotating point in js fabric?

I want to show only the rotating point of the canvas object and hide my controls. I tried the following:

obj.hasControls = false;
obj.hasRotatingPoint = true;

      

but it doesn't work.

+3


source to share


2 answers


try this:

obj.setControlsVisibility({
    mt: false,
    mb: false,
    ml: false,
    mr: false,
    tr: false,
    tl: false,
    br: false,
    bl: false
});
obj.hasRotatingPoint = true;

      



View jsFiddle

+8


source


Or like this:



var canvas = window._canvas = new fabric.Canvas('c');

var circle = new fabric.Circle({
  left: 50,
  top: 50,
  radius: 25,
  fill: 'rgba(0,255,0,0.5)',
});


circle.setControlsVisibility({
  mt: false,
  mb: false,
  ml: false,
  mr: false,
  tr: false,
  tl: false,
  br: false,
  bl: false,
  mtr: true //the rotating point (defaut: true)
});

canvas.add(circle);
      

canvas {
  border: 1px solid #999;
}
      

<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="c" width="400" height="200"></canvas>
      

Run codeHide result


"mtr" is the pivot point.

+3


source







All Articles