{"id":13604325,"url":"https://github.com/w8r/bresenham-zingl","last_synced_at":"2025-05-09T00:05:52.463Z","repository":{"id":66124682,"uuid":"116962137","full_name":"w8r/bresenham-zingl","owner":"w8r","description":"Set of efficient Bresenham rasterisers ported from Alois Zingl' code","archived":false,"fork":false,"pushed_at":"2024-12-31T19:27:38.000Z","size":201,"stargazers_count":27,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-09T00:05:46.743Z","etag":null,"topics":["anti-aliasing","bezier","bresenham","curve","rasterizer"],"latest_commit_sha":null,"homepage":"https://w8r.github.io/bresenham-zingl/demo/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/w8r.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2018-01-10T13:35:38.000Z","updated_at":"2024-12-31T19:26:47.000Z","dependencies_parsed_at":"2023-03-10T03:01:03.081Z","dependency_job_id":null,"html_url":"https://github.com/w8r/bresenham-zingl","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"054d4c483bf265af4cae8335628069e306a0e2d2"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fbresenham-zingl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fbresenham-zingl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fbresenham-zingl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/w8r%2Fbresenham-zingl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/w8r","download_url":"https://codeload.github.com/w8r/bresenham-zingl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253166518,"owners_count":21864476,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["anti-aliasing","bezier","bresenham","curve","rasterizer"],"created_at":"2024-08-01T19:00:43.618Z","updated_at":"2025-05-09T00:05:52.443Z","avatar_url":"https://github.com/w8r.png","language":"TypeScript","funding_links":[],"categories":["Basic Raster Graphics Algorithms for Drawing 2D Primitives"],"sub_categories":["Line Drawing"],"readme":"# Bresenham rasterisation functions by Alois Zingl\n\n![Screenshot](https://w8r.github.io/bresenham-zingl/src/bresenham-zingl.png)\n\nPort of [C code](https://gist.github.com/w8r/2f57de439a736b0a079b70ed24c9a246) by Alois Zingl from this paper\n\n[ALOIS ZINGL: \"A Rasterizing Algorithm for Drawing Curves\", 8 November 2012 (2012-11-08), pages 1 - 81](https://github.com/Traumflug/Teacup_Firmware/raw/master/research/A_Rasterizing_Algorithm_for_Drawing_Curves_-_Alois_Zingl_2012.pdf)\n\n## Install\n\n```\nnpm i -S bresenham-zingl\n```\n\n```js\nimport { line, circle, quadBezier } from \"bresenham-zingl\";\n\nquadBezier(0, 0, 10, 10, 0, 10, (x, y) =\u003e console.log(x, y)); // 0,0, ...\n```\n\n## [Demo](https://w8r.github.io/bresenham-zingl/demo/)\n\n## API\n\n### User-defined callbacks\n\n### `setPixel(x, y)`\n\nUse that callback to fill the pixel on canvas.\n\n### Parameters\n\n| parameter | type   | description |\n| --------- | ------ | ----------- |\n| `x`       | number |             |\n| `y`       | number |             |\n\n### `setPixelAlpha(x, y, alpha)`\n\nCallback that would also receive the alpha value for the pixel\n\n### Parameters\n\n| parameter | type   | description |\n| --------- | ------ | ----------- |\n| `x`       | number |             |\n| `y`       | number |             |\n| `alpha`   | number |             |\n\n### `line(x0, y0, x1, y1, setPixel)`\n\nLine segment rasterisation\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `lineAA(x0, y0, x1, y1, setPixelAA)`\n\nDraw a black (0) anti-aliased line on white (255) background\n\n### Parameters\n\n| parameter    | type          | description |\n| ------------ | ------------- | ----------- |\n| `x0`         | number        |             |\n| `y0`         | number        |             |\n| `x1`         | number        |             |\n| `y1`         | number        |             |\n| `setPixelAA` | setPixelAlpha |             |\n\n**Returns** `number`,\n\n### `lineWidth(x0, y0, x1, y1, wd, setPixel)`\n\nPlot an anti-aliased line of width wd\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `wd`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `quadRationalBezierSegment(x0, y0, x1, y1, x2, y2, w, setPixel)`\n\nplot a limited rational Bezier segment, squared weight\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `x2`       | number   |             |\n| `y2`       | number   |             |\n| `w`        | number   |             |\n| `setPixel` | setPixel |             |\n\n### `quadRationalBezierSegmentAA(x0, y0, x1, y1, x2, y2, w, setPixelAA)`\n\ndraw an anti-aliased rational quadratic Bezier segment, squared weight\n\n### Parameters\n\n| parameter    | type          | description |\n| ------------ | ------------- | ----------- |\n| `x0`         | number        |             |\n| `y0`         | number        |             |\n| `x1`         | number        |             |\n| `y1`         | number        |             |\n| `x2`         | number        |             |\n| `y2`         | number        |             |\n| `w`          | number        |             |\n| `setPixelAA` | setPixelAlpha |             |\n\n### `rotatedEllipse(x, y, a, b, angle, setPixel)`\n\nPlot ellipse rotated by angle (radian)\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x`        | number   |             |\n| `y`        | number   |             |\n| `a`        | number   |             |\n| `b`        | number   |             |\n| `angle`    | number   |             |\n| `setPixel` | setPixel |             |\n\n### `rotatedEllipseRect(x0, y0, x1, y1, zd, setPixel)`\n\nRectangle encloMath.sing the ellipse, integer rotation angle\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `zd`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `ellipseRect(x0, y0, x1, y1, setPixel)`\n\nRectangular parameter encloMath.sing the ellipse\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `circle(xm, ym, r, setPixel)`\n\nCircle rasterisation\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `xm`       | number   |             |\n| `ym`       | number   |             |\n| `r`        | number   |             |\n| `setPixel` | setPixel |             |\n\n### `circleAA(xm, ym, r, setPixelAA)`\n\nDraw a black anti-aliased circle on white background\n\n### Parameters\n\n| parameter    | type          | description |\n| ------------ | ------------- | ----------- |\n| `xm`         | number        |             |\n| `ym`         | number        |             |\n| `r`          | number        |             |\n| `setPixelAA` | setPixelAlpha |             |\n\n### `quadBezierSegment(x0, y0, x1, y1, x2, y2, setPixel)`\n\nplot a limited quadratic Bezier segment\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `x2`       | number   |             |\n| `y2`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `quadBezierAA(x0, y0, x1, y1, x2, y2, setPixelAA)`\n\nPlot any quadratic Bezier curve with anti-alias\n\n### Parameters\n\n| parameter    | type          | description |\n| ------------ | ------------- | ----------- |\n| `x0`         | number        |             |\n| `y0`         | number        |             |\n| `x1`         | number        |             |\n| `y1`         | number        |             |\n| `x2`         | number        |             |\n| `y2`         | number        |             |\n| `setPixelAA` | setPixelAlpha |             |\n\n### `quadBezierSegmentAA(x0, y0, x1, y1, x2, y2, setPixelAA)`\n\nDraw an limited anti-aliased quadratic Bezier segment\n\n### Parameters\n\n| parameter    | type          | description |\n| ------------ | ------------- | ----------- |\n| `x0`         | number        |             |\n| `y0`         | number        |             |\n| `x1`         | number        |             |\n| `y1`         | number        |             |\n| `x2`         | number        |             |\n| `y2`         | number        |             |\n| `setPixelAA` | setPixelAlpha |             |\n\n### `cubicBezier(x0, y0, x1, y1, x2, y2, x3, y3, setPixel)`\n\nplot any cubic Bezier curve\n\n### Parameters\n\n| parameter  | type     | description |\n| ---------- | -------- | ----------- |\n| `x0`       | number   |             |\n| `y0`       | number   |             |\n| `x1`       | number   |             |\n| `y1`       | number   |             |\n| `x2`       | number   |             |\n| `y2`       | number   |             |\n| `x3`       | number   |             |\n| `y3`       | number   |             |\n| `setPixel` | setPixel |             |\n\n### `cubicBezierAA(x0, y0, x1, y1, x2, y2, x3, y3, setPixelAA)`\n\nplot any cubic Bezier curve\n\n### Parameters\n\n| parameter  | type          | description |\n| ---------- | ------------- | ----------- |\n| `x0`       | number        |             |\n| `y0`       | number        |             |\n| `x1`       | number        |             |\n| `y1`       | number        |             |\n| `x2`       | number        |             |\n| `y2`       | number        |             |\n| `x3`       | number        |             |\n| `y3`       | number        |             |\n| `setPixel` | setPixelAlpha |             |\n\n## License\n\n(The MIT License)\n\nCopyright (c) 2012 Alois Zingl\n\nPermission 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:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fbresenham-zingl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fw8r%2Fbresenham-zingl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fw8r%2Fbresenham-zingl/lists"}