{"id":26556658,"url":"https://github.com/eagletrt/libraster-sw","last_synced_at":"2026-05-02T10:38:03.420Z","repository":{"id":283736125,"uuid":"952536567","full_name":"eagletrt/libraster-sw","owner":"eagletrt","description":"A simple library that provides a way to define and raster a graphic layout","archived":false,"fork":false,"pushed_at":"2025-12-04T20:32:12.000Z","size":190,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-08T01:45:43.382Z","etag":null,"topics":["embedded","graphics","library","platformio","platformio-library","rasterizer","sw"],"latest_commit_sha":null,"homepage":"","language":"C","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/eagletrt.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-21T12:51:48.000Z","updated_at":"2025-06-04T16:21:10.000Z","dependencies_parsed_at":"2025-05-10T17:30:55.086Z","dependency_job_id":"ce1cad7a-5aba-4d45-9cac-387eb9ea21e1","html_url":"https://github.com/eagletrt/libraster-sw","commit_stats":null,"previous_names":["eagletrt/libraster-sw"],"tags_count":1,"template":false,"template_full_name":"eagletrt/libstm32-sw-template","purl":"pkg:github/eagletrt/libraster-sw","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eagletrt%2Flibraster-sw","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eagletrt%2Flibraster-sw/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eagletrt%2Flibraster-sw/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eagletrt%2Flibraster-sw/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eagletrt","download_url":"https://codeload.github.com/eagletrt/libraster-sw/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eagletrt%2Flibraster-sw/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32531742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["embedded","graphics","library","platformio","platformio-library","rasterizer","sw"],"created_at":"2025-03-22T11:24:50.928Z","updated_at":"2026-05-02T10:38:03.414Z","avatar_url":"https://github.com/eagletrt.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LIBRASTER\n\nThis library is made to rasterize an interface defined by the user using only callbacks.\n\n## Why callbacks?\n\nThe idea is to let the user decide how things are done. This helps with performances based on the platform, as using 2 for loops for drawing a square isn't always the best option. This library does not use dynamic allocation to make sure it stays compatible with every platform.\n\n\u003e [!TIP]\n\u003e On an STM32 you may want to use `DMA2D`, while using SDL2 you may want to use the function `SDL_FillRect` or just 2 for loops.\n\n## Usage\n\n### First of all you need to generate the actual font. There are 2 main cases:\n1. **Using PlatformIO package manager**\n    You will need to add a script as such:\n    ```python\n    import os\n    import hashlib\n    import sys\n    from pathlib import Path\n    from SCons.Script import Import\n    import logging\n\n    Import(\"env\")\n\n    json_path = Path(\"tools/fonts.json\")\n    hash_path = Path(\"tools/.fonts.json.sha256\")\n    libgen = next(Path(\".pio\").rglob(\"generator.py\"))\n\n\n    def hash_file(p):\n        return hashlib.sha256(p.read_bytes()).hexdigest()\n\n    logger = logging.getLogger(\"libraster\")\n    logging.basicConfig(encoding='utf-8', level=logging.INFO)\n\n    if not json_path.exists():\n        logger.warning(\"[libraster] fonts.json not found\")\n        exit(1)\n    elif not hash_path.exists() or hash_file(json_path) != hash_path.read_text():\n        logger.info(\"[libraster] generating\")\n        os.system(f\"{sys.executable} {libgen} --json {json_path}\")\n        hash_path.write_text(hash_file(json_path))\n    else:\n        logger.warning(\"[libraster] fonts.json unchanged, skipping\")\n\n    ```\n    This will let you create a folder named `tools` containing the `fonts.json`.\n    Then in your `platformio.ini` just call the script on-build like this:\n    ```\n    extra_scripts = pre:tools/generate_fonts.py\n    ```\n\n2. **Using the library without PlatformIO package manager**\n    You will still need to create the `fonts.json`, but after that everything is on you. You will decide how and when to call the generator. You can pass the path to `fonts.json` using the `--json` argument.\n\n### Actual usage\nAll you have to do is include `raster-api.h` in your program, create labels and boxes, then initialize a handler with the interface, and call the function `raster_api_render` with the handler.\n\n\u003e [!IMPORTANT]\n\u003e If you're using 2 buffers, you still have to swap them yourself.\n\n#### Callback Functions\n\nYou need to implement three callback functions:\n\n```c\n// Draw a horizontal line of pixels\nvoid draw_line_callback(uint16_t x, uint16_t y, uint16_t lenght, struct Color color) {\n    // Your implementation here\n    // This is called for text rendering\n}\n\n// Draw a filled rectangle\nvoid draw_rectangle_callback(uint16_t x, uint16_t y, uint16_t w, uint16_t h, struct Color color) {\n    // Your implementation here\n    // This is called for box backgrounds\n}\n\n// Clear the entire screen (only used when RASTER_PARTIAL is disabled)\nvoid clear_screen_callback(void) {\n    // Your implementation here\n    // Only needed if RASTER_PARTIAL = 0\n}\n```\n\n#### Label Structure \nEach label (`struct RasterLabel`) contains:\n- `data` - Union containing the actual data (string, int, float)\n- `type` - Type of data (see Label Data Types)\n- `format` - Union for format options (e.g., number of decimal places for floats)\n- `pos` - Position of the label inside the box (x, y)\n- `font` - Enum defining the font to use\n- `size` - Font size\n- `align` - Text alignment (left, center, right)\n- `color` - Font color (`Color` structure)\n\n#### Label Data Types\n\nThe library supports the following label data types:\n- `LABEL_DATA_STRING` - Text string (char*)\n- `LABEL_DATA_INT` - Integer value\n- `LABEL_DATA_FLOAT` - Float value\n\n#### Box Structure\n\nEach box (`struct RasterBox`) contains:\n- `updated` - Flag for partial rendering optimization (only if RASTER_PARTIAL is enabled)\n- `id` - Unique identifier for the box\n- `rect` - Rectangle dimensions (x, y, width, height)\n- `color` - Background color (ARGB format)\n- `label` - Pointer to label structure (optional, can be NULL)\n\n\u003e [!TIP]\n\u003e Create a file `raster-config.h` with the following defines to customize behaviour:\n\u003e - `RASTER_PARTIAL` - Enable/disable partial rendering optimization (default = 1). When enabled, only boxes with `updated = true` will be redrawn.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feagletrt%2Flibraster-sw","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feagletrt%2Flibraster-sw","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feagletrt%2Flibraster-sw/lists"}