How to use the fabric.fabric 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 wearespindle / dotd / app.js View on Github external
server.listen(settings.port, function() {
    moment.locale(settings.language)
    app.engine('handlebars', exphbs({defaultLayout: 'main'}))
    app.set('view engine', 'handlebars')
    app.dayOftheWeek = parseInt(moment().format('e'), 10)
    app.fabric = require('fabric').fabric
    GLOBAL.fabric = app.fabric

    common.init(app)

    app.db = new loki('db.json', {
        autosave: true,
        autosaveInterval: 3000,
        autoload: true,
        autoloadCallback: function() {
            // if database did not exist it will be empty so I will intitialize here
            var collection = app.db.getCollection('paths')
            if (!collection) {
                collection = app.db.addCollection('paths', {indices: ['uuid']})
                collection.ensureUniqueIndex('uuid')
            }
github 0123cf / together-draw / src / index.js View on Github external
// TODO 工具栏激活状态
if (process.env.NODE_ENV !== 'production') {
    require('./index.html')
}
const fabric = require('fabric').fabric
const { SaveImage } = require('./saveImage')
const { Config } = require('./config.js')
let canvas

// const socket = io.connect(`http://${Config.ws.host}:${Config.ws.port}`)

// // 监听绘画新状态
// socket.on('drawListen', (msg) => {
// 	// console.log('收到监听, drawListen')
// 	// console.log(msg)
// 	canvas.loadFromJSON(msg)
// })

// push已修改的状态
let HandleCanvasUpdate = (canvas) => {
    // // TODO 发送到服务端的话需要做序列号, 需要优化算法(不然这样服务器吃不消啊)
github anvaka / ngraph.fabric / example / node.js / innode.js View on Github external
function renderToCanvas(graph, layout) {
  var graphRect = layout.getGraphRect();
  var size = Math.max(graphRect.x2 - graphRect.x1, graphRect.y2 - graphRect.y1) + 200;

  var createFabricGraphics = require('../../');
  var fabricGraphics = createFabricGraphics(graph, { width: size, height: size, layout: layout });
  var fabric = require('fabric').fabric;

  // This line customize appearance of each node and link. The best part of it -
  // it is the same code which renders graph in `customUI` example
  require('../shared/uiSettings')(fabricGraphics, fabric);

  var scale = 1;
  fabricGraphics.setTransform(size/2, size/2, scale);
  fabricGraphics.renderOneFrame(); // One frame is enough

  return fabricGraphics.canvas;
}
github shyiko / canvas-text-opentypejs-shim / demo / demo-runkit-fabric.js View on Github external
// https://github.com/shyiko/canvas-text-opentypejs-shim
//
// To execute locally (Node.js >= 6):
// npm init -f && npm i canvas@1.6.2 opentype.js@0.6.6 node-fetch@1.6.3 fabric@1.7.2
// node demo-runkit-fabric.js

const fabric = require('fabric').fabric
const opentype = require('opentype.js')
const fetch = require('node-fetch')
const fs = require('fs')
const useOpenTypeJsForText =
  (() => { try { return require('../canvas-text-opentypejs-shim') } catch (e) {} })() ||
  require('canvas-text-opentypejs-shim')

// this way fabric tends to yield more consistent results when compared to
// CanvasRenderingContext2D.drawText
fabric.Text.prototype._fontSizeMult = 1.25

/**
 * @param fontFamily e.g. "'Open Sans', sans-serif"
 * @return e.g. ["Open Sans", "sans-serif"]
 */
function splitFontFamily (fontFamily) {
github anvaka / ngraph.generators / doc / index.js View on Github external
function renderToCanvas(graph, layout) {
  var graphRect = layout.getGraphRect();
  var size = Math.max(graphRect.x2 - graphRect.x1, graphRect.y2 - graphRect.y1) + 200;

  var fabricGraphics = createFabricGraphics(graph, { width: size, height: size, layout: layout });
  var fabric = require('fabric').fabric;

  var scale = 1;
  fabricGraphics.setTransform(size/2, size/2, scale);
  fabricGraphics.renderOneFrame(); // One frame is enough

  return fabricGraphics.canvas;
}
github tbolis / react-sketch / src / pan.js View on Github external
/*eslint no-unused-vars: 0*/

import FabricCanvasTool from './fabrictool'

const fabric = require('fabric').fabric;

class Pan extends FabricCanvasTool {

  configureCanvas(props) {
    let canvas = this._canvas;
    canvas.isDrawingMode = canvas.selection = false;
    canvas.forEachObject((o) => o.selectable = o.evented = false);
    //Change the cursor to the move grabber
    canvas.defaultCursor = 'move';
  }

  doMouseDown(o) {
    let canvas = this._canvas;
    this.isDown = true;
    let pointer = canvas.getPointer(o.e);
    this.startX = pointer.x;
github WISE-Community / WISE / src / main / webapp / wise5 / vle / src / polyfills.ts View on Github external
/***************************************************************************************************
 * APPLICATION IMPORTS
 */
import * as jQuery from 'jquery';
import * as fabric from 'fabric';
import * as StompJS from '@stomp/stompjs';
import * as SockJS from 'sockjs-client';
import * as Highcharts from '../../lib/highcharts/highcharts.src';
import * as hopscotch from 'hopscotch';
import * as EventEmitter2 from 'eventemitter2';
import * as draggablePoints from '../../lib/draggable-points/draggable-points';
import * as HighchartsExporting from '../../lib/highcharts-exporting@4.2.1';

window['$'] = jQuery;
window['jQuery'] = jQuery;
window['fabric'] = fabric.fabric;
window['SockJS'] = SockJS;
window['Stomp'] = StompJS.Stomp;
window['hopscotch'] = hopscotch;
window['Highcharts'] = Highcharts;
window['EventEmitter2'] = EventEmitter2;
import * as summernote from 'summernote';
window['summernote'] = summernote;
window['draggablePoints'] = draggablePoints;
window['HighchartsExporting'] = HighchartsExporting;
github WISE-Community / WISE / src / main / webapp / wise5 / classroomMonitor / src / polyfills.ts View on Github external
/***************************************************************************************************
 * APPLICATION IMPORTS
 */
import * as jQuery from 'jquery';
import * as fabric from 'fabric';
import * as StompJS from '@stomp/stompjs';
import * as SockJS from 'sockjs-client';
import * as Highcharts from '../../lib/highcharts/highcharts.src';
import * as hopscotch from 'hopscotch';
import * as EventEmitter2 from 'eventemitter2';

window['$'] = jQuery;
window['jQuery'] = jQuery;
window['fabric'] = fabric.fabric;
window['SockJS'] = SockJS;
window['Stomp'] = StompJS.Stomp;
window['hopscotch'] = hopscotch;
window['Highcharts'] = Highcharts;
window['EventEmitter2'] = EventEmitter2;
github anvaka / ngraph.fabric / lib / fabric.js View on Github external
module.exports = (typeof window === 'undefined') ? require('fabric').fabric : window.fabric;