{"_id":"@emeraldproductions/fwb","_rev":"3-249e0fc40c326a4068d9601d9f782426","name":"@emeraldproductions/fwb","dist-tags":{"latest":"0.1.3"},"versions":{"0.1.0":{"name":"@emeraldproductions/fwb","version":"0.1.0","_id":"@emeraldproductions/fwb@0.1.0","maintainers":[{"name":"unclej","email":"em@emeraldjean.tv"}],"dist":{"shasum":"15706d63f798ecf88b4c77f0bceeaeed9345dd83","tarball":"https://registry.npmjs.org/@emeraldproductions/fwb/-/fwb-0.1.0.tgz","fileCount":5,"integrity":"sha512-5SJcU8hdRrcPeczawldijGxYsFj7Q6cA29h3vC8qe2PDFmpLEfafwyaB68e1HK+Ag3HD2XZaChs4dGwfKnKtlA==","signatures":[{"sig":"MEUCIEivZMdSmMm+VtMFD+vj2wxO8PNV8to8g78BpotZcmMQAiEA5rkuuD6YFo3chSvVo7V6UnYeveYbU4oMfiumEJnVVek=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":59029},"main":"fwb.js","types":"fwb.d.ts","_npmUser":{"name":"unclej","email":"em@emeraldjean.tv"},"_npmVersion":"10.9.0","description":"Emerald FWB is a WebAssembly-based library for efficiently encoding and decoding messages, vectors, and pixel data for collaborative whiteboarding applications. This protocol is designed to facilitate high-performance communication for drawing tools and v","directories":{},"_nodeVersion":"20.11.1","collaborators":["Emerald Productions <em@emeraldjean.tv>"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/fwb_0.1.0_1732788710622_0.9233125841856777","host":"s3://npm-registry-packages"}},"0.1.1":{"name":"@emeraldproductions/fwb","version":"0.1.1","_id":"@emeraldproductions/fwb@0.1.1","maintainers":[{"name":"unclej","email":"em@emeraldjean.tv"}],"dist":{"shasum":"c203d24225fcdd676c2a3fbb599c5535b45f7b00","tarball":"https://registry.npmjs.org/@emeraldproductions/fwb/-/fwb-0.1.1.tgz","fileCount":5,"integrity":"sha512-m733nk/VWZtTaPwWmAMA6x6CvHom5XfvaMYvKLlhCf2HEdxS0VcQXkhit5CGBxe8hS9XlTSOx/MpReNnIwuE5Q==","signatures":[{"sig":"MEQCIGJJqTjuWgmNogvEG/D5yCXbYgSEGyN6raJTiSNHfYwtAiBQZ+CJ6OM8IJ5LztYVDZUvWHWjtCN7+seN5MvNCoEzIA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":64222},"main":"fwb.js","types":"fwb.d.ts","_npmUser":{"name":"unclej","email":"em@emeraldjean.tv"},"_npmVersion":"10.9.0","description":"Emerald FWB is a WebAssembly-based library for efficiently encoding and decoding messages, vectors, and pixel data for collaborative whiteboarding applications. This protocol is designed to facilitate high-performance communication for drawing tools and v","directories":{},"_nodeVersion":"20.11.1","collaborators":["Emerald Productions <em@emeraldjean.tv>"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/fwb_0.1.1_1732794752080_0.5570309032163627","host":"s3://npm-registry-packages"}},"0.1.2":{"name":"@emeraldproductions/fwb","version":"0.1.2","_id":"@emeraldproductions/fwb@0.1.2","maintainers":[{"name":"unclej","email":"em@emeraldjean.tv"}],"dist":{"shasum":"6fa8c5cb4b0683fd5e013d8192e9b1b4acdac121","tarball":"https://registry.npmjs.org/@emeraldproductions/fwb/-/fwb-0.1.2.tgz","fileCount":7,"integrity":"sha512-nUqjTHxNmLGQxgTkTtrJJLAR+mec2Svv4HMCqyOB+zTcm8+N2HGOzEBBzzXDdu7HXoBIuxUUCiwUgn3hOi5sDA==","signatures":[{"sig":"MEYCIQC1iNpn1PxW2JVghrVjR1sgAqTIHbNPeQ8K8MFqyrJRAQIhAPwEk5KgvwlGkSEi6Xk7va1CHLAiRXeMHTcK1cK9rxrh","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":51245},"main":"fwb.js","type":"module","types":"fwb.d.ts","_npmUser":{"name":"unclej","email":"em@emeraldjean.tv"},"_npmVersion":"10.9.0","directories":{},"sideEffects":["./fwb.js","./snippets/*"],"_nodeVersion":"20.11.1","collaborators":["Emerald Productions <em@emeraldjean.tv>"],"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/fwb_0.1.2_1733410507651_0.41448940782792243","host":"s3://npm-registry-packages"}},"0.1.3":{"name":"@emeraldproductions/fwb","type":"module","collaborators":["Emerald Productions <em@emeraldjean.tv>"],"version":"0.1.3","main":"fwb.js","types":"fwb.d.ts","sideEffects":["./fwb.js","./snippets/*"],"_id":"@emeraldproductions/fwb@0.1.3","description":"The **Emerald Whiteboard Protocol** library is a WebAssembly-powered toolkit designed for high-performance manipulation of pixel grids, drawing primitives, and managing a color shader. Ideal for collaborative whiteboard applications or pixel-based graphic","_nodeVersion":"20.11.1","_npmVersion":"10.9.0","dist":{"integrity":"sha512-GsZjpNvxxZldqAQnzg4JkT/2gT7eNwk0KOww1FrkRk4bTWkf5MGUfHeVwJ4EuMIajU3hNcc+l5dNGSzk/SbKug==","shasum":"0ed5058363393d37d66c1284cab9005164e8c82a","tarball":"https://registry.npmjs.org/@emeraldproductions/fwb/-/fwb-0.1.3.tgz","fileCount":7,"unpackedSize":55897,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIC0qXk6184GEPH2f87jHZBy2jotO/jB6uSVJejba6gstAiEAzpH9Ch0qo6ypMTmzDn6W7jA4OaYUvqxG9dspJpPnzME="}]},"_npmUser":{"name":"unclej","email":"em@emeraldjean.tv"},"directories":{},"maintainers":[{"name":"unclej","email":"em@emeraldjean.tv"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fwb_0.1.3_1733410620015_0.057592966819986824"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-28T10:11:50.459Z","modified":"2024-12-05T14:57:00.405Z","0.1.0":"2024-11-28T10:11:50.984Z","0.1.1":"2024-11-28T11:52:32.422Z","0.1.2":"2024-12-05T14:55:07.822Z","0.1.3":"2024-12-05T14:57:00.197Z"},"maintainers":[{"name":"unclej","email":"em@emeraldjean.tv"}],"readme":"# @emeraldproductions/fwb\n\nThe **Emerald Whiteboard Protocol** library is a WebAssembly-powered toolkit designed for high-performance manipulation of pixel grids, drawing primitives, and managing a color shader. Ideal for collaborative whiteboard applications or pixel-based graphics rendering.\n\n---\n\n## Features\n\n- **PixelBox**: Manage 2D grids of pixels with flexible operations.\n- **Color Shader**: Up to 16 colors, customizable for any use case.\n- **Drawing Functions**: Draw dots, lines, and apply transformations.\n- **Efficient Encoding**: Convert PixelBox to/from raw buffers.\n- **WebAssembly**: Cross-platform performance with easy JavaScript integration.\n\n---\n\n## Installation\n\nInstall via NPM:\n\n```bash\nnpm install @emeraldproductions/fwb\n```\n\n---\n\n## Usage\n\n### Import the Library\n\n```javascript\nimport { PixelBox, RGBA, ProtocolMessage } from \"@emeraldproductions/fwb\";\n```\n\n---\n\n## API Documentation\n\n### **PixelBox**\n\nThe core structure for managing 2D pixel grids.\n\n#### Constructor\n\n```javascript\nconst pixelBox = new PixelBox(width: number, height: number);\n```\n\n- `width`: Width of the pixel grid (32-bit integer).\n- `height`: Height of the pixel grid (32-bit integer).\n\n---\n\n#### Methods\n\n- **`fromRGBA(rgba: Uint8Array): void`**\n  - Converts an RGBA buffer to a `PixelBox`.\n  - Example:\n    ```javascript\n    pixelBox.fromRGBA(new Uint8Array([255, 0, 0, 255, ...])); // Red pixels\n    ```\n\n- **`toRGBA(): Uint8Array`**\n  - Converts the `PixelBox` back to an RGBA buffer.\n\n- **`setPixel(x: number, y: number, color: number): void`**\n  - Sets a single pixel at `(x, y)` to a color from the shader palette.\n\n- **`getPixel(x: number, y: number): number`**\n  - Retrieves the color index of the pixel at `(x, y)`.\n\n- **`setShader(shader: Uint8Array): boolean`**\n  - Updates the color shader palette. Must be exactly 48 bytes (16 colors × 3 RGB bytes each).\n\n  Example:\n  ```javascript\n  const shader = new Uint8Array([\n      0, 0, 0,        // Black\n      255, 255, 255,  // White\n      ...             // Other colors\n  ]);\n  pixelBox.setShader(shader);\n  ```\n\n- **`clear(): void`**\n  - Clears the entire pixel grid.\n\n- **`drawDot(x: number, y: number, radius: number, color: number): void`**\n  - Draws a filled circle (dot) at `(x, y)` with a given `radius` and `color`.\n\n  Example:\n  ```javascript\n  pixelBox.drawDot(50, 50, 5, 3); // A dot at (50, 50) with radius 5, color index 3\n  ```\n\n- **`drawLine(x1: number, y1: number, x2: number, y2: number, radius: number, color: number): void`**\n  - Draws a line from `(x1, y1)` to `(x2, y2)` with optional thickness (`radius`).\n\n- **`apply(pb: PixelBox, x: number, y: number): void`**\n  - Overlays another `PixelBox` onto the current one starting at `(x, y)`.\n\n---\n\n### **ProtocolMessage**\n\nManages protocol-based communication.\n\n#### Constructor\n\n```javascript\nconst message = new ProtocolMessage(instruction: number, payload_type: number);\n```\n\n- `instruction`: An 8-bit instruction for the message.\n- `payload_type`: Defines the payload type (`0` for raw, `1` for vectors, `2` for PixelBox).\n\n---\n\n#### Methods\n\n- **`addBuffer(payload: Uint8Array): void`**\n  - Appends raw data to the message payload.\n\n- **`buffer (getter)`**\n  - Retrieves the message as a byte array.\n\n- **`fromBuffer(bytes: Uint8Array): ProtocolMessage`**\n  - Parses a message from a byte array.\n\n---\n\n### **RGBA**\n\nA utility class for working with RGBA colors.\n\n#### Constructor\n\n```javascript\nconst rgba = new RGBA(r: number, g: number, b: number, a: number);\n```\n\n- `r`, `g`, `b`, `a`: Red, Green, Blue, and Alpha values (`0–255`).\n\n---\n\n#### Methods\n\n- **`to_rgb(): RGB`**\n  - Converts the RGBA value to an RGB object (ignoring alpha).\n\n---\n\n### **Vector**\n\nRepresents a vector-based drawing primitive.\n\n#### Constructor\n\n```javascript\nconst vector = new Vector(layer, tool, color, modifier, start_x, start_y, end_x, end_y);\n```\n\n- `layer`: The drawing layer.\n- `tool`: The drawing tool identifier.\n- `color`: Color index from the shader palette.\n- `modifier`: Tool-specific modifier.\n- `start_x`, `start_y`: Starting coordinates.\n- `end_x`, `end_y`: Ending coordinates.\n\n---\n\n## Examples\n\n### Drawing a Circle\n\n```javascript\nconst pixelBox = new PixelBox(100, 100);\npixelBox.drawDot(50, 50, 10, 2); // Draw a circle at (50, 50) with radius 10, color 2\n```\n\n### Setting a Custom Shader\n\n```javascript\nconst shader = new Uint8Array([\n    0, 0, 0,        // Black\n    255, 255, 255,  // White\n    128, 128, 128,  // Gray\n    ...             // 13 more colors\n]);\npixelBox.setShader(shader);\n```\n\n---\n\n## License\n\nThis project is licensed under the MIT License.\n\n---\n\nLet me know if you need further adjustments!","readmeFilename":"README.md","description":"The **Emerald Whiteboard Protocol** library is a WebAssembly-powered toolkit designed for high-performance manipulation of pixel grids, drawing primitives, and managing a color shader. Ideal for collaborative whiteboard applications or pixel-based graphic"}