Akba Hakbar
Akba Hakbar

Reputation: 33

Is there a way to show only the rotating point on fabric js?

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

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

but it's not working.

Upvotes: 3

Views: 2585

Answers (2)

cmnt
cmnt

Reputation: 61

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>

"mtr" is the rotating point.

Upvotes: 6

Nistor Cristian
Nistor Cristian

Reputation: 1266

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

Upvotes: 11

Related Questions