This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// opens file dialog waits till user selects file and return dataurl of uploaded file | |
async function pick() { | |
var filepicker = document.createElement("input"); | |
filepicker.setAttribute("type","file"); | |
filepicker.click(); | |
return new Promise((resolve,reject) => { | |
filepicker.addEventListener("change", e => { | |
var reader = new FileReader(); | |
reader.addEventListener('load', file => resolve(file.target.result)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fabric.Arrow = fabric.util.createClass(fabric.Line, { | |
type: 'Arrow', | |
initialize: function(element, options) { | |
options || (options = {}); | |
this.callSuper('initialize', element, options); | |
}, | |
toObject: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Arrow for fabric.js | |
// | |
(function($){ | |
$.Arrow = $.util.createClass($.Line, $.Observable, { | |
initialize: function(e,t) { | |
this.callSuper("initialize", e, t) | |
this.set({type:'arrow'}); | |
}, | |
_render: function(e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CubicBezier = function(canvas, opts){ | |
if(!opts) opts = {}; | |
this.start = opts.start || new Vec2(100,100); | |
this.end = opts.end || new Vec2(400, 400); | |
this.c1 = opts.c1 || new Vec2(100, 300); | |
this.c2 = opts.c2 || new Vec2(300, 100); | |
this.curve = new fabric.Path( this.toSVGPath() ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @private | |
* @method _render | |
*/ | |
_render: function(ctx) { | |
var current, // current instruction | |
previous = null, | |
x = 0, // current x | |
y = 0, // current y | |
controlX = 0, // current control point x |