Fabric.js Brush Configuration and Usage
Overview
Fabric.js provides drawing capabilities when the canvas is set to drawing mode. This guide covers the fundamental brush configuration options.
Note: This guide uses Fabric.js version 5.2.1
Initial Setup
Enable drawing mode on the canvas to activate brush funcsionality:
<canvas id="canvas" width="600" height=&qu ...
Posted on Wed, 28 Oct 2026 16:04:20 +0000 by jonsjava
Implementing a Wolf and Sheep Pathfinding Game
When developing canvas games for mobile devices, visual blurring often occurs due to the difference between CSS dimensions and physical screen pixels. The devicePixelRatio property addresses this scaling requirement. Consider this implementation:
function setupCanvasResolution(canvasElement) {
const pixelRatio = window.devicePixelRatio || 1 ...
Posted on Tue, 13 Oct 2026 16:01:56 +0000 by leszczu
Drawing Circles in p5.js Using the circle() Function
The circle() function in p5.js provides a straightforward way to render circular shapes. It requires three arguments: the horizontal coordinate of the center, the vertical coordinate of the center, and the diameter of the circle.
Coordinate System
In p5.js, the origin (0,0) lies at the top-left corner of the canvas. Increasing the x-value moves ...
Posted on Fri, 09 Oct 2026 16:25:53 +0000 by seaten
Adding and Controlling Overline, Strikethrough, and Underline Text Decorations in Fabric.js
Text decoration properties are straightforward to assign during IText initialization via the nested styles object. The top-level keys in styles represent zero-indexed line numbers, while each nested object uses zero-indexed character positions as keys, holding individual decoration boolean flags: overline, linethrough, and underline.
The t ...
Posted on Tue, 06 Oct 2026 16:47:24 +0000 by laeelin
Generating Matrix-Rain Avatars with Canvas and gif.js
Upload a static profile picture and walk away with an animated Matrix-style avatar that drips green glyphs. A live demo is here.
Quick start
Pick a square photo—round crops look better.
If the falling characters look off, tweak the tint until they match the vibe.
Happy with the preview? Right-click → "Save image as…" or hit the downl ...
Posted on Sat, 03 Oct 2026 16:29:59 +0000 by gunslinger008
Pencil Brush in Fabric.js
Regular Configuration
Enable Drawing Mode
To use the pencil tool, first enable drawing mode by setting isDrawingMode to true when initializing the canvas. Here’s the base code:
<canvas id="fabricCanvas" width="500" height="400" style="border: 1px solid #ccc;"></canvas>
<script>
const ...
Posted on Sat, 03 Oct 2026 16:16:50 +0000 by twopeak
Applying Visual Overlays to Mask Canvas Content in Fabric.js
When using Fabric.js, the overlayColor property provides a straightforward way to mask everything on a canvas by drawing a layer above all visual content.
Configuring the Overlay Layer
During instantiation, pass overlayColor along with other canvas options:
<canvas id="surface"></canvas>
<script>
const surface = n ...
Posted on Fri, 11 Sep 2026 16:14:13 +0000 by crusty_php
Creating Floating Heart Animations with Canvas and Bezier Curves
Implementing a floating heart animation for a "like" feature requires moving a heart image along a Bezier curve trajectory while gradually fading it out. The core challenge lies in calculating a series of points along the Bezier curve.
Calculating Bezier Curve Points
The mathematical formula for an n-order Bezier curve allows us to co ...
Posted on Sun, 06 Sep 2026 16:55:44 +0000 by AmiraSan
Implementing Advanced Web Animations with CSS3 Transforms and HTML5 Canvas
CSS3 2D Transformations
CSS3 introduced the transform property, enabling developers to manipulate the coordinate space of elements. This allows for effects such as rotation, scaling, skewing, and translation without relying on JavaScript for the visual rendering engine, resulting in smoother performance.
Underlying specific transformation funct ...
Posted on Sat, 29 Aug 2026 16:33:15 +0000 by Hiro
Customizing Fabric.js Selection Controls and Visual States
When working with Fabric.js canvas applications, customizing how selected objects appear is essential for creating polished user experiences. This guide covers the properties and methods available for modifying selection handles, borders, and object states.
Canvas Setup
<canvas id="c" style="border: 1px solid #ccc;">&l ...
Posted on Mon, 24 Aug 2026 16:17:13 +0000 by JessePHP