Skip to content

Instantly share code, notes, and snippets.

View Seventh7th-Son's full-sized avatar

Seventh7th_Son Seventh7th-Son

View GitHub Profile
@theabbie
theabbie / filepicker.js
Created December 24, 2020 16:24
Promise-based File Picker in Javascript
// 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));
@linchpinstudios
linchpinstudios / fabric.arrow.js
Last active December 25, 2023 18:27
Fabric JS Arrow
fabric.Arrow = fabric.util.createClass(fabric.Line, {
type: 'Arrow',
initialize: function(element, options) {
options || (options = {});
this.callSuper('initialize', element, options);
},
toObject: function() {
@farnabaz
farnabaz / arrow.fabric.js
Created May 22, 2015 23:29
fabric.js arrow shape
//
// 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) {
@paulkaplan
paulkaplan / fabricBezierCurve.js
Last active February 2, 2024 08:30
Cubic bezier curves with fabric.js renderer
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() );
@willmcneilly
willmcneilly / gist:3181555
Created July 26, 2012 11:24
Fabric consecutive 't' paths fix
/**
* @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