Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/taiseen/learning-react-fabric-js

React - Fabric JS - Canvas Drawing...
https://github.com/taiseen/learning-react-fabric-js

canvas context-api fabric-js local-storage modular-design react-hot-toast react-js tailwind-css

Last synced: 3 days ago
JSON representation

React - Fabric JS - Canvas Drawing...

Awesome Lists containing this project

README

        

> 27 - Sep - 2022

## Fabric Js Learning...

### Tailwind setup

* yarn add -D tailwindcss postcss autoprefixer
* npx tailwindcss init -p
* tailwind.config

### Fabric Js

* yarn add fabric
* yarn add react-hot-toast

## Features:-

* πŸ’Ύ save data at local-storage + ⌨ key operation
* πŸ†— preventing app crash, when save data become undefined...
* πŸ”„ load data from local-storage...
* ❌ single object delete operation + ⌨ key operation
* β›” multiple object delete operation + ⌨ key operation
* πŸ“Έ save as image, whole canvas drawing + ⌨ key operation
* πŸ…° select all object that draw in canvas + ⌨ key operation
* πŸ”Ž canvas zoom functionality
* ⌨ "tab" key press event to navigate inside canvas object for selection...
* ⌨ Check that Caps Lock is on
* πŸ–±οΈ Get the mouse position
* πŸ“ StickyNote demo testing add...


```
Developers describe Fabric.js as "The easiest way to work with HTML5 canvas".
It provides interactive object model on top of canvas element.
Fabric also has SVG-to-canvas (and canvas-to-SVG) parser.
Using Fabric.js, you can create and populate objects on canvas, objects like simple geometrical shapes.
```

```
Things to keep in mind:
When inspecting the canvas, it’s important to note that there are two layers that exist
1) upper canvas &
2) lower canvas

The upper canvas is utilized by the Fabric.js API for handling events, groupings, etc.
while we’re actually working on the lower canvas layer & The lower canvas contains the id we defined
```

* `canvas.clear()` will clear all objects on canvas.
* `canvas.dispose()` will clear all objects on canvas & remove all listeners.

## File & Folder hierarchy

```
src
β”œβ”€β”€ assets
| β”œβ”€β”€ Brush.jsx
| β”œβ”€β”€ Circle.jsx
| β”œβ”€β”€ Eraser.jsx
| β”œβ”€β”€ index.js
| β”œβ”€β”€ Rectangle.jsx
| β”œβ”€β”€ Text.jsx
| └── Triangle.jsx
|
β”œβ”€β”€ components
| β”œβ”€β”€ Canvas.jsx
| β”œβ”€β”€ CanvasLine.jsx
| β”œβ”€β”€ Row1.jsx
| └── Row2.jsx
|
β”œβ”€β”€ context
| └── CanvasContext.js
|
β”œβ”€β”€ drawingTools
| β”œβ”€β”€ draw-i-Text.js
| β”œβ”€β”€ drawCircle.js
| β”œβ”€β”€ drawingBrush.js
| β”œβ”€β”€ drawRectangle.js
| β”œβ”€β”€ drawText.js
| β”œβ”€β”€ drawTextBox.js
| └── drawTriangle.js
|
β”œβ”€β”€ features
| β”œβ”€β”€ copyPasteSelect.js
| β”œβ”€β”€ delete.js
| β”œβ”€β”€ loadSVG.js
| β”œβ”€β”€ mouseHover.js
| β”œβ”€β”€ r&d.js
| β”œβ”€β”€ save.js
| β”œβ”€β”€ search.js
| β”œβ”€β”€ utils.js
| └── zoom.js
|
β”œβ”€β”€ style
| └── index.css
|
β”œβ”€β”€ App.jsx
└── index.js
```