Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bresenham-zingl

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bresenham-zingl

Bresenham rasterisation algorithms by Alois Zingl

  • 0.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
70
decreased by-43.55%
Maintainers
1
Weekly downloads
 
Created
Source

Bresenham rasterisation functions by Alois Zingl

Screenshot

Port of C code by Alois Zingl from this paper

ALOIS ZINGL: "A Rasterizing Algorithm for Drawing Curves", 8 November 2012 (2012-11-08), pages 1 - 81

Install

npm i -S bresenham-zingl
import { line, circle, quadBezier } from 'bresenham-zingl';

quadBezier(0,0, 10, 10, 0, 10, (x, y) => console.log(x, y)); // 0,0, ...

Demo

API

User-defined callbacks

setPixel(x, y)

Use that callback to fill the pixel on canvas.

Parameters

parametertypedescription
xnumber
ynumber

setPixelAlpha(x, y, alpha)

Callback that would also receive the alpha value for the pixel

Parameters

parametertypedescription
xnumber
ynumber
alphanumber

line(x0, y0, x1, y1, setPixel)

Line segment rasterisation

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
setPixelsetPixel

lineAA(x0, y0, x1, y1, setPixelAA)

Draw a black (0) anti-aliased line on white (255) background

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
setPixelAAsetPixelAlpha

Returns number,

lineWidth(x0, y0, x1, y1, wd, setPixel)

Plot an anti-aliased line of width wd

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
wdnumber
setPixelsetPixel

quadRationalBezierSegment(x0, y0, x1, y1, x2, y2, w, setPixel)

plot a limited rational Bezier segment, squared weight

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
wnumber
setPixelsetPixel

quadRationalBezierSegmentAA(x0, y0, x1, y1, x2, y2, w, setPixelAA)

draw an anti-aliased rational quadratic Bezier segment, squared weight

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
wnumber
setPixelAAsetPixelAlpha

rotatedEllipse(x, y, a, b, angle, setPixel)

Plot ellipse rotated by angle (radian)

Parameters

parametertypedescription
xnumber
ynumber
anumber
bnumber
anglenumber
setPixelsetPixel

rotatedEllipseRect(x0, y0, x1, y1, zd, setPixel)

Rectangle encloMath.sing the ellipse, integer rotation angle

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
zdnumber
setPixelsetPixel

ellipseRect(x0, y0, x1, y1, setPixel)

Rectangular parameter encloMath.sing the ellipse

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
setPixelsetPixel

circle(xm, ym, r, setPixel)

Circle rasterisation

Parameters

parametertypedescription
xmnumber
ymnumber
rnumber
setPixelsetPixel

circleAA(xm, ym, r, setPixelAA)

Draw a black anti-aliased circle on white background

Parameters

parametertypedescription
xmnumber
ymnumber
rnumber
setPixelAAsetPixelAlpha

quadBezierSegment(x0, y0, x1, y1, x2, y2, setPixel)

plot a limited quadratic Bezier segment

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
setPixelsetPixel

quadBezierAA(x0, y0, x1, y1, x2, y2, setPixelAA)

Plot any quadratic Bezier curve with anti-alias

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
setPixelAAsetPixelAlpha

quadBezierSegmentAA(x0, y0, x1, y1, x2, y2, setPixelAA)

Draw an limited anti-aliased quadratic Bezier segment

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
setPixelAAsetPixelAlpha

cubicBezier(x0, y0, x1, y1, x2, y2, x3, y3, setPixel)

plot any cubic Bezier curve

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
x3number
y3number
setPixelsetPixel

cubicBezierAA(x0, y0, x1, y1, x2, y2, x3, y3, setPixelAA)

plot any cubic Bezier curve

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
x3number
y3number
setPixelsetPixelAlpha

License

(The MIT License)

Copyright (c) 2012 Alois Zingl

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Keywords

FAQs

Package last updated on 22 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc