{"id":16140490,"url":"https://github.com/anthonyec/16seg","last_synced_at":"2025-03-18T17:30:29.222Z","repository":{"id":42853500,"uuid":"261110869","full_name":"anthonyec/16seg","owner":"anthonyec","description":"📟 Little thing to simulate 16 segment displays in SVG","archived":false,"fork":false,"pushed_at":"2024-05-02T16:36:26.000Z","size":3864,"stargazers_count":4,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-28T10:58:33.550Z","etag":null,"topics":["animated","javascript","prototype","segment-display","svg"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/anthonyec.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}},"created_at":"2020-05-04T07:46:24.000Z","updated_at":"2024-12-14T20:29:58.000Z","dependencies_parsed_at":"2023-02-07T19:01:30.496Z","dependency_job_id":null,"html_url":"https://github.com/anthonyec/16seg","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/anthonyec%2F16seg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2F16seg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2F16seg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anthonyec%2F16seg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anthonyec","download_url":"https://codeload.github.com/anthonyec/16seg/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243940210,"owners_count":20372050,"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":["animated","javascript","prototype","segment-display","svg"],"created_at":"2024-10-09T23:52:50.922Z","updated_at":"2025-03-18T17:30:28.815Z","avatar_url":"https://github.com/anthonyec.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📟 16seg\n\n![Animated preview showing 16 seg displays showing the alphabet](preview.gif)\n\n_Preview of what this repo does. Inspired by [Da Sul's Dribbble post](https://dribbble.com/shots/6717324-16-segment-display)._\n\n## Setup\nThis repo uses [Parcel](https://github.com/parcel-bundler/parcel/) to bundle all the files and [InvlineSVG](https://github.com/jonnyhaynes/inline-svg#readme) to inline SVG markup in the examples.\n\nRun the following commands and open the localhost URL Parcel provides in the CLI.\n```sh\n$ npm i\n```\n\n```sh\n$ npm start\n```\n\n## How to use\n### Static\n```js\n// Add the `16seg.svg` to your markup\n// and select it.\nconst svg = document.querySelector('svg');\n\n// Create the display passing in the SVG.\nconst display = createSegmentDisplay(svg);\n\n// Show a letter on the display!\ndisplay.show('A');\n```\n### Animated\n```js\nconst svg = document.querySelector('svg');\n\n// Pass in optional options.\nconst display = createSegmentDisplay(svg, {\n  loop: true,\n  delay: 100,\n});\n\n// Ta-da!\ndisplay.showSequence(['A', 'B', 'C']);\n```\n\n## How it works\n### The SVG file\nThe `16seg.svg` file contains all the segments as SVG polygons. Each polygon in the SVG is in a specifc order.\n\n![Diagram showing which segment has what number](numbered.jpg)\n\n### Font\nA `font` is a key value map of characters and an array of numbers that say which segment should be highlighted. The current font is built in.\n\n```js\nconst font = {\n  'A': [0, 1, 2, 3, 4, 5, 9, 13],\n  'B': [2, 3, 4, 5, 6, 7, 11, 13, 15],\n  'C': [0, 1, 2, 3, 6, 7]\n  //...\n}\n```\n\nIt can also contain arbitrary strings that represent certain segment configurations.\n\n\n```js\nconst font = {\n  //...\n  'CURL1': [0, 1, 2, 10, 11],\n  'CURL2': [1, 2, 3, 4, 12, 13],\n  'CURL3': [4, 5, 6, 14, 15],\n  'CURL4': [0, 5, 6, 7, 8, 9],\n  //...\n}\n```\n\nThis is quite a brute force approach, but it works! However, maybe this can be done in a smarter way like using bytes and math. Let me know if so!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyec%2F16seg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanthonyec%2F16seg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanthonyec%2F16seg/lists"}