{"id":17949546,"url":"https://github.com/mrtenz/binary-pixel-map","last_synced_at":"2025-03-24T22:35:55.120Z","repository":{"id":44218766,"uuid":"154698471","full_name":"Mrtenz/binary-pixel-map","owner":"Mrtenz","description":"A library for creating and editing a binary 2D pixel map","archived":false,"fork":false,"pushed_at":"2022-12-04T00:21:12.000Z","size":114,"stargazers_count":2,"open_issues_count":9,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T19:51:52.572Z","etag":null,"topics":["arduino","nodejs","oled-display","raspberry-pi","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mrtenz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-25T15:54:46.000Z","updated_at":"2020-10-25T18:46:18.000Z","dependencies_parsed_at":"2023-01-23T23:03:52.450Z","dependency_job_id":null,"html_url":"https://github.com/Mrtenz/binary-pixel-map","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mrtenz%2Fbinary-pixel-map","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mrtenz%2Fbinary-pixel-map/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mrtenz%2Fbinary-pixel-map/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mrtenz%2Fbinary-pixel-map/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mrtenz","download_url":"https://codeload.github.com/Mrtenz/binary-pixel-map/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366205,"owners_count":20603438,"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":["arduino","nodejs","oled-display","raspberry-pi","typescript"],"created_at":"2024-10-29T09:26:45.613Z","updated_at":"2025-03-24T22:35:50.096Z","avatar_url":"https://github.com/Mrtenz.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# binary-pixel-map\n\nA library written in TypeScript for creating and editing a binary 2D pixel map, made for usage with small monochrome displays, for example on a Raspberry Pi or Arduino.\n\nThis library is based on [`oled-js`](https://github.com/noopkat/oled-js) and [`oled-font-5x7`](https://github.com/noopkat/oled-font-5x7) by noopkat.\n\n## Installation\n\n```\nyarn add binary-pixel-map\n```\n\n## Usage\n\n```typescript\nimport { PixelMap, Pixel } from 'binary-pixel-map';\n\n// Create a new pixel map with a width of 54, height of 18.\nconst map = new PixelMap(54, 18);\n\n// Draw \"Hello, world!\" on the map.\nmap.text(1, 1, 'Hello,');\nmap.text(1, 10, 'world!');\n\n// Enable the top left and bottom right pixel.\nmap.set(0, 0, Pixel.ON);\nmap.set(53, 17, Pixel.ON);\n\nconsole.log(map.toString());\n```\n\nThe example above will output the following:\n\n```\nPixelMap { x - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n           - x - - - x - - - - - - - - - - - - x x - - - - - - x x - - - - - - - - - - - - - - - - - - - - - - - - - -\n           - x - - - x - - - - - - - - - - - - - x - - - - - - - x - - - - - - - - - - - - - - - - - - - - - - - - - -\n           - x - - - x - - - - x x x - - - - - - x - - - - - - - x - - - - - - x x x - - - - - - - - - - - - - - - - -\n           - x x x x x - - - x - - - x - - - - - x - - - - - - - x - - - - - x - - - x - - - - - - - - - - - - - - - -\n           - x - - - x - - - x x x x x - - - - - x - - - - - - - x - - - - - x - - - x - - - - x x - - - - - - - - - -\n           - x - - - x - - - x - - - - - - - - - x - - - - - - - x - - - - - x - - - x - - - - - x - - - - - - - - - -\n           - x - - - x - - - - x x x - - - - - x x x - - - - - x x x - - - - - x x x - - - - - x - - - - - - - - - - -\n           - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n           - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n           - - - - - - - - - - - - - - - - - - - - - - - - - - x x - - - - - - - - - x - - - - - x - - - - - - - - - -\n           - - - - - - - - - - - - - - - - - - - - - - - - - - - x - - - - - - - - - x - - - - - x - - - - - - - - - -\n           - x - - - x - - - - x x x - - - - x - x x - - - - - - x - - - - - - x x - x - - - - - x - - - - - - - - - -\n           - x - - - x - - - x - - - x - - - x x - - x - - - - - x - - - - - x - - x x - - - - - x - - - - - - - - - -\n           - x - x - x - - - x - - - x - - - x - - - - - - - - - x - - - - - x - - - x - - - - - x - - - - - - - - - -\n           - x - x - x - - - x - - - x - - - x - - - - - - - - - x - - - - - x - - - x - - - - - - - - - - - - - - - -\n           - - x - x - - - - - x x x - - - - x - - - - - - - - x x x - - - - - x x x x - - - - - x - - - - - - - - - -\n           - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - x }\n```\n\n## API\n\n### PixelMap\n\n```typescript\nnew PixelMap(width: number, height: number);\n```\n\n#### get\n\n```typescript\nget(x: number, y: number): PixelStatus;\n```\n\nGet the value of the pixel at [x, y].\n\n#### getAll\n\n```typescript\ngetAll(): PixelStatus[][];\n```\n\nGet all pixels.\n\n#### set\n\n```typescript\nset(x: number, y: number, status: PixelStatus): void;\n```\n\nSet the value of the pixel at [x, y];\n\n#### clear\n\n```typescript\nclear(): void;\n```\n\nClear the whole map.\n\n#### fill\n\n```typescript\nfill(status: PixelStatus): void;\n```\n\nFill the map with enabled (ON) or disabled (OFF) pixels.\n\n#### line\n\n```typescript\nline(x0: number, y0: number, x1: number, y1: number, status: PixelStatus = Pixel.ON): void;\n```\n\nDraw a line from [x0, y0] to [x1, y1] using Bresenham's line algorithm.\n\n#### rectangle\n\n```typescript\nrectangle(x: number, y: number, width: number, height: number, outline: boolean = false, status: PixelStatus = Pixel.ON): void;\n```\n\nDraw a rectangle at [x, y] with the size [width, height]. If `outline` is set to true, only an outline will be drawn. Otherwise the rectangle will be filled.\n\n#### text\n\n```typescript\ntext(x: number, y: number, content: string, size: number = 1, spacing: number = 2, wrap: boolean = true): void;\n```\n\nDraw text at [x, y] with size `size`. The standard size (`size = 1`) for letters is 5 x 7.\n\n#### copy\n\n```typescript\ncopy(from: PixelMap, x: number = 0, y: number = 0): void;\n```\n\nCopy another pixel map onto the current pixel map at [x, y].\n\n#### image\n\n```typescript\nasync image(path: string | Buffer, x: number = 0, y: number = 0, maxWidth?: number, maxHeight?: number): Promise\u003cvoid\u003e;\n```\n\nCopy an image onto the pixel map. `path` can be a file path or image buffer. Supported file types are: PNG, JPEG, WebP, GIF, SVG and TIFF.\n\n#### toArray\n\n```typescript\ntoArray(): PixelStatus[];\n```\n\nGet the map as sequence of all rows. Can be useful for displaying the map on a display.\n\n#### toString\n\n```typescript\ntoString(): string;\n```\n\nGet the map as string. Can be useful for debugging.\n\n### Pixel\n\n```typescript\nimport { Pixel } from 'binary-pixel-map';\n```\n\n#### PixelStatus\n\n```typescript\ntype PixelStatus = boolean;\n```\n\nUsed as alternative to booleans. You can still use regular booleans if you prefer.\n\n#### Pixel.ON\n\nAlternative way of writing `true`.\n\n#### Pixel.OFF\n\nAlternative way of writing `false`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtenz%2Fbinary-pixel-map","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrtenz%2Fbinary-pixel-map","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrtenz%2Fbinary-pixel-map/lists"}