Skip to content

functions for drawing crisp lines on a canvas element

Notifications You must be signed in to change notification settings

sch/crisp-canvas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A module for quickly drawing lines to a canvas element using bresenham's algorithm, for pixel-precision crispness.

Usage

var crisp = require("crisp-canvas");
var canvas = getElementById("canvas-id");
var context = canvas.getContext("2d");

crisp.drawLines(context, [
  {
    start: { x: 5, y: 5 },
    end: { x: 25, y: 25 },
    color: [ 200, 200, 200, 200 ] // rgba
  }
]);

Why?

Html canvas doesn't provide an api for aliasing. All lines and polygons are anti-aliased by default.

Canvas does provide an api for manipulating the image buffer through the ImageData class. This library defines a line drawing command that draws pixels directly to this image buffer.

About

functions for drawing crisp lines on a canvas element

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published