{"id":16125592,"url":"https://github.com/semibran/image-extract","last_synced_at":"2025-06-23T10:34:40.157Z","repository":{"id":130492048,"uuid":"79757070","full_name":"semibran/image-extract","owner":"semibran","description":"extracts sprites from a spritesheet image","archived":false,"fork":false,"pushed_at":"2017-02-28T02:16:33.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T13:12:49.534Z","etag":null,"topics":["extract","sprite","spritesheet"],"latest_commit_sha":null,"homepage":null,"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/semibran.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}},"created_at":"2017-01-23T00:47:47.000Z","updated_at":"2017-02-28T02:08:27.000Z","dependencies_parsed_at":"2024-03-15T04:09:34.288Z","dependency_job_id":null,"html_url":"https://github.com/semibran/image-extract","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/semibran/image-extract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimage-extract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimage-extract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimage-extract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimage-extract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/semibran","download_url":"https://codeload.github.com/semibran/image-extract/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fimage-extract/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261462427,"owners_count":23161958,"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":["extract","sprite","spritesheet"],"created_at":"2024-10-09T21:30:03.696Z","updated_at":"2025-06-23T10:34:35.143Z","avatar_url":"https://github.com/semibran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# image-extract\n\u003e Extracts sprites from a spritesheet image\n\n## Installation\n```sh\nnpm install --save semibran/sprite\n```\n\n## Usage\n```javascript\nvar Sprite = require('sprite')\nvar sprite = Sprite(image)(width, height)(x, y)\n```\n\nThe main `Sprite` function is curried into three separate phases for reusability. Depending on how it is used, the final function may return either one or multiple `HTMLCanvasElement` objects.\n\n### `use`\n```javascript\nvar createSprite = Sprite(image)\n```\n\nSpecifies the image from which the resulting sprite will be extracted. This can be either an `Image`, an `HTMLCanvasElement`, or anything that can be drawn onto a `CanvasRenderingContext2D`.\n\n### `config`\n```javascript\nvar createTile = Sprite(image)(width, height)\n```\n\nConfigures the dimensions of the resulting sprite(s).\n\n### `extract`\n```javascript\nvar sprite = Sprite(image)(width, height)(x, y)\n```\n\nThe last function does the actual sprite extraction. Note that `x` and `y` are indices referring to the location of the desired sprite rather than raw positions.\n\nIf `y` is not provided, `x` will be treated as an index, wrapping around the spritesheet until it reaches the desired sprite.\n\n**If `x` is not provided, the library will extract all the sprites possible with the given dimensions in a grid shape, then return them all as an array.** I personally recommend this method since it abstracts away most (if not all) of the loop logic that you'd have to delve into in order to retrieve each individual sprite.\n\n```javascript\n// ES6 users can use the \"new\" destructuring and object assignment syntax.\nvar [idle, run0, run1, run2, skid, jump, ouch] = Sprite(mario)(16)()\nhero.sprites = { idle, run0, run1, run2, skid, jump, ouch }\n```\n\n## License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fimage-extract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemibran%2Fimage-extract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fimage-extract/lists"}