Giter Club home page Giter Club logo

fabric-guideline-plugin's Introduction

fabric-guideline-plugin

๐Ÿคฉ Help you easily append guidelines and auto-snap to your fabric.js canvas.

Features

  • ๐Ÿ˜ Easily append guidelines to your fabric.js canvas
  • ๐ŸŽจ Automatically snap to nearby elements
  • ๐Ÿค– Automatically adjust the auto-snap threshold when the window is zoomed
  • ๐Ÿ› ๏ธ Customize guidelines' style and other options
  • ๐Ÿ“ฆ Zero dependencies

Example

See ๐Ÿ‘‰ CodeSandbox.

Quick Start

npm install fabric-guideline-plugin --save

After install, you can use it in your project.

import { AlignGuidelines } from "fabric-guideline-plugin";

Usage

import { fabric } from "fabric";
import { AlignGuidelines } from "fabric-guideline-plugin";

const fabricCanvas = new fabric.Canvas("myCanvas");

const guideline = new AlignGuidelines({
  canvas: fabricCanvas,
});

guideline.init();

You can also set some options to customize the guideline.

const guideline = new AlignGuidelines({
  canvas: fabricCanvas,
  pickObjTypes: [{ key: "myType", value: "box" }],
  aligningOptions: {
    lineColor: "#32D10A",
    lineWidth: 2,
    lineMargin: 2,
  },
});

Development

If you want to develop this plugin, you can easily start with the following steps:

$ git clone https://github.com/caijinyc/guideline.git
$ cd guideline
$ pnpm install
$ pnpm dev

fabric-guideline-plugin's People

Contributors

caijinyc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fabric-guideline-plugin's Issues

multi selection object guide line problem

i create a two object and select both object and move it , im only create two object only if i move both there is not other object for snapping. the guide line appear and snap only in canvas top left area only .

Request related to clearGuideline method logic

Thank you for providing us with a good library.
I left an issue because there was something uncomfortable while using it.

When the canvas.isDrawingMode is enabled, running the clearGuideline method causes the brush path to be drawn in real time to be clear as it runs. Can it be modified?

// canvas brush start
canvas.isDrawingMode = true;
// fabric-guideline-plugin / index.js
clearGuideline() {
  this.canvas.clearContext(this.ctx);
}

I think it would be good if it was modified so that not all objects were cleared, but only the guideline disappeared.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.