Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
bresenham-zingl
Advanced tools
Port of C code by Alois Zingl from this paper
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, ...
setPixel(x, y)
Use that callback to fill the pixel on canvas.
parameter | type | description |
---|---|---|
x | number | |
y | number |
setPixelAlpha(x, y, alpha)
Callback that would also receive the alpha value for the pixel
parameter | type | description |
---|---|---|
x | number | |
y | number | |
alpha | number |
line(x0, y0, x1, y1, setPixel)
Line segment rasterisation
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
setPixel | setPixel |
lineAA(x0, y0, x1, y1, setPixelAA)
Draw a black (0) anti-aliased line on white (255) background
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
setPixelAA | setPixelAlpha |
Returns number
,
lineWidth(x0, y0, x1, y1, wd, setPixel)
Plot an anti-aliased line of width wd
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
wd | number | |
setPixel | setPixel |
quadRationalBezierSegment(x0, y0, x1, y1, x2, y2, w, setPixel)
plot a limited rational Bezier segment, squared weight
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
w | number | |
setPixel | setPixel |
quadRationalBezierSegmentAA(x0, y0, x1, y1, x2, y2, w, setPixelAA)
draw an anti-aliased rational quadratic Bezier segment, squared weight
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
w | number | |
setPixelAA | setPixelAlpha |
rotatedEllipse(x, y, a, b, angle, setPixel)
Plot ellipse rotated by angle (radian)
parameter | type | description |
---|---|---|
x | number | |
y | number | |
a | number | |
b | number | |
angle | number | |
setPixel | setPixel |
rotatedEllipseRect(x0, y0, x1, y1, zd, setPixel)
Rectangle encloMath.sing the ellipse, integer rotation angle
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
zd | number | |
setPixel | setPixel |
ellipseRect(x0, y0, x1, y1, setPixel)
Rectangular parameter encloMath.sing the ellipse
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
setPixel | setPixel |
circle(xm, ym, r, setPixel)
Circle rasterisation
parameter | type | description |
---|---|---|
xm | number | |
ym | number | |
r | number | |
setPixel | setPixel |
circleAA(xm, ym, r, setPixelAA)
Draw a black anti-aliased circle on white background
parameter | type | description |
---|---|---|
xm | number | |
ym | number | |
r | number | |
setPixelAA | setPixelAlpha |
quadBezierSegment(x0, y0, x1, y1, x2, y2, setPixel)
plot a limited quadratic Bezier segment
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
setPixel | setPixel |
quadBezierAA(x0, y0, x1, y1, x2, y2, setPixelAA)
Plot any quadratic Bezier curve with anti-alias
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
setPixelAA | setPixelAlpha |
quadBezierSegmentAA(x0, y0, x1, y1, x2, y2, setPixelAA)
Draw an limited anti-aliased quadratic Bezier segment
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
setPixelAA | setPixelAlpha |
cubicBezier(x0, y0, x1, y1, x2, y2, x3, y3, setPixel)
plot any cubic Bezier curve
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
x3 | number | |
y3 | number | |
setPixel | setPixel |
cubicBezierAA(x0, y0, x1, y1, x2, y2, x3, y3, setPixelAA)
plot any cubic Bezier curve
parameter | type | description |
---|---|---|
x0 | number | |
y0 | number | |
x1 | number | |
y1 | number | |
x2 | number | |
y2 | number | |
x3 | number | |
y3 | number | |
setPixel | setPixelAlpha |
(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.
FAQs
Bresenham rasterisation algorithms by Alois Zingl
The npm package bresenham-zingl receives a total of 66 weekly downloads. As such, bresenham-zingl popularity was classified as not popular.
We found that bresenham-zingl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.