How to use the fabric.fabric.Point function in fabric

To help you get started, we’ve selected a few fabric examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bfortuner / labelml / src / components / Editor.vue View on Github external
let curZoom = this.zoomFactor;
      let cursor, delta;
      if (zoomIn) {
        cursor = 'zoom-in';
        delta = 1.1;
        //this.scalePoints(.95);
      } else {
        cursor = 'zoom-out';
        delta = .95
        //this.scalePoints(1.1);
      }
      this.zoomFactor *= delta;
      console.log(cursor);
      // canvas.defaultCursor = cursor;
      // canvas.hoverCursor = cursor;
      canvas.zoomToPoint(new fabric.Point(
        e.e.offsetX, e.e.offsetY), this.zoomFactor);
      //this.resetCursors();
// let obj = e.target;
      // if (obj !== undefined 
      //     && obj !== null
      //     && this.polygonClicks.length > 0
      //     && obj === this.polygonClicks[0]) {
      //   obj.set({
      //     stroke: 'green',
      //     fill: 'green',
      //   });
      //   canvas.renderAll();
      // }
    },
github bfortuner / labelml / src / components / Editor.vue View on Github external
resetZoom: function() {
      this.zoomFactor = 1 ;
      console.log(canvas.width, canvas.height);
      canvas.setZoom(this.zoomFactor);
      canvas.zoomToPoint(new fabric.Point(
        canvas.width/2, canvas.height/2), this.zoomFactor);
    },
github bfortuner / labelml / src / components / Editor.vue View on Github external
handleGrabMove: function(e) {
      console.log("handling grab move", e.e);
      var delta = new fabric.Point(e.e.movementX, e.e.movementY) ;
      canvas.relativePan(delta);
    },
github SonyCSLParis / NONOTO / drawing_stave.ts View on Github external
canvas.on('mouse:up', function(o){
    var objectFound = false;
    var clickPoint = new fabric.Point(o.e.offsetX, o.e.offsetY);
    canvas.forEachObject(function (obj) {
        if (!objectFound && obj.containsPoint(clickPoint)) {
            objectFound = true;

            if (composition_mode === 'free'){
              note_start = Math.floor(obj.path[0][1] / (time_step * 4)) + 1
              note_end = Math.floor(obj.path[obj.path.length -1][1] / (time_step * 4))
            }
            else{
              note_start = Math.floor(Math.min(obj.x1,obj.x2) / (time_step * 4))
              note_end = Math.floor(Math.max(obj.x1,obj.x2) / (time_step * 4)) + 1
            }
            console.log(note_start)
            console.log(note_end)
            send_notes(note_start, note_end, composition_mode)
            ;}
github SonyCSLParis / NONOTO / drawing_stave.ts View on Github external
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === line)) {
                                          let point_tl = new fabric.Point(obj.x1, 0);
                                          let point_br = new fabric.Point(obj.x2, canvas.height);
                                          if (line.intersectsWithRect(point_tl, point_br) || line.isContainedWithinRect(point_tl, point_br)) {canvas.remove(line).renderAll()}
                                        }

                                      });
                                    });
github SonyCSLParis / NONOTO / drawing_stave.ts View on Github external
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === path)) {
                                                      let point_tl = new fabric.Point(obj.path[0][1], 0);
                                                      let point_br = new fabric.Point(obj.path[obj.path.length -1][1], canvas.height);
                                                      if (path.intersectsWithRect(point_tl, point_br) || path.isContainedWithinRect(point_tl, point_br)) {canvas.remove(path).renderAll();}
                                                    }
                                                  })
                                      }
github SonyCSLParis / NONOTO / drawing_stave.ts View on Github external
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === line)) {
                                          let point_tl = new fabric.Point(obj.x1, 0);
                                          let point_br = new fabric.Point(obj.x2, canvas.height);
                                          if (line.intersectsWithRect(point_tl, point_br) || line.isContainedWithinRect(point_tl, point_br)) {canvas.remove(line).renderAll()}
                                        }

                                      });
                                    });
github SonyCSLParis / NONOTO / drawing_stave.ts View on Github external
canvas.forEachObject((obj) => {if (!(typeof(obj) === 'undefined') && !(obj === path)) {
                                                      let point_tl = new fabric.Point(obj.path[0][1], 0);
                                                      let point_br = new fabric.Point(obj.path[obj.path.length -1][1], canvas.height);
                                                      if (path.intersectsWithRect(point_tl, point_br) || path.isContainedWithinRect(point_tl, point_br)) {canvas.remove(path).renderAll();}
                                                    }
                                                  })
                                      }