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.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
200
increased by4.17%
Maintainers
1
Weekly downloads
 
Created
Source

Bresenham rasterisation function by Alois Zingl

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

Demo

API

These are two callbacks you will have to provide in order to make use of the output:

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

ellipse(xm, ym, a, b, setPixel)

Draws ellipse

Parameters

parametertypedescription
xmnumber
ymnumber
anumber
bnumber
setPixelsetPixel

circle(xm, ym, r, setPixel)

Circel rasterisation

Parameters

parametertypedescription
xmnumber
ymnumber
rnumber
setPixelsetPixel

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

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

Plot any quadratic Bezier curve

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
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

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

plot any quadratic rational Bezier curve

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
wnumber
setPixelsetPixel

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 enclosing the ellipse, integer rotation angle

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
zdnumber
setPixelsetPixel

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

Rectangular parameter enclosing the ellipse

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
setPixelsetPixel

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

Plot limited cubic Bezier segment

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
x2number
y2number
x3number
y3number
setPixelsetPixel

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

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,

circleAA(xm, ym, r, setPixelAA)

Draw a black anti-aliased circle on white background

Parameters

parametertypedescription
xmnumber
ymnumber
rnumber
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

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

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

Plot an anti-aliased line of width wd

Parameters

parametertypedescription
x0number
y0number
x1number
y1number
wdnumber
setPixelsetPixel

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 10 Jan 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