{"id":21525268,"url":"https://github.com/superraytin/slices","last_synced_at":"2025-04-09T23:21:41.890Z","repository":{"id":57363048,"uuid":"47921762","full_name":"superRaytin/slices","owner":"superRaytin","description":"Node.js module for slicing given area into blocks with the given reference lines. :fork_and_knife: :cake:","archived":false,"fork":false,"pushed_at":"2016-08-15T03:57:00.000Z","size":138,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T14:39:18.629Z","etag":null,"topics":[],"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/superRaytin.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":"2015-12-13T14:11:56.000Z","updated_at":"2023-03-08T10:33:13.000Z","dependencies_parsed_at":"2022-09-26T16:32:23.031Z","dependency_job_id":null,"html_url":"https://github.com/superRaytin/slices","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fslices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fslices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fslices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/superRaytin%2Fslices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/superRaytin","download_url":"https://codeload.github.com/superRaytin/slices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248126403,"owners_count":21051916,"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":[],"created_at":"2024-11-24T01:34:09.793Z","updated_at":"2025-04-09T23:21:41.868Z","avatar_url":"https://github.com/superRaytin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp style=\"text-align: center\"\u003e\n    \u003cimg src=\"docs/demonstrate.png\" width=\"887\" alt=\"slices\"\u003e\n\u003c/p\u003e\n\nYeah, no kidding, you give me a range (width \u0026 height) and reference lines, and I'll give you blocks, the same as cutting the cake! :fork_and_knife: :cake:\n\n# slices\n\n\u003e Node.js module for slicing given area into blocks with the given reference lines\n\n[![Build Status](https://travis-ci.org/superRaytin/slices.svg?branch=master)](https://travis-ci.org/superRaytin/slices)\n[![NPM version][npm-image]][npm-url]\n[![Downloads][downloads-image]][npm-url]\n\n[![slices](https://nodei.co/npm/slices.png)](https://npmjs.org/package/slices)\n\n[npm-url]: https://npmjs.org/package/slices\n[downloads-image]: http://img.shields.io/npm/dm/slices.svg\n[npm-image]: http://img.shields.io/npm/v/slices.svg\n\n```js\nvar Slices = require('slices');\nvar blocks = Slices(500, 500, [100], [100]);\n```\n\nGet blocks:\n\n```js\n[\n    { width: 100, height: 100, x: 0, y: 0 },\n    { width: 400, height: 100, x: 100, y: 0 },\n    { width: 100, height: 400, x: 0, y: 100 },\n    { width: 400, height: 400, x: 100, y: 100 }\n]\n```\n\n# Installation\n\n```\nnpm install slices\n```\n\n# API\n\n### Slices(width, height, lineXArray, lineYArray [, options])\n\n- **width:** Number of pixels wide\n- **height:** Number of pixels high\n- **lineXArray:** reference lines of the X axis\n- **lineYArray:** reference lines of the Y axis\n- **options:** slice with some optional parameters, see [options](#options) for detail.\n\n## Options\n\n### middleBoundaryMode\n\nEither true or false, default is false.\n\nIf set to true, this will put spaces between each two lines of X axis as parent-block,\nthe areas between the first line of Y axis and the last will be children of the parent-block, and it will generate boundary data.\n\n\u003cp style=\"text-align: center\"\u003e\n    \u003cimg src=\"docs/demonstrate2.png\" width=\"870\" alt=\"slices\"\u003e\n\u003c/p\u003e\n\nBelow is an example:\n\n```js\nSlices(500, 500, [100, 300], [100, 200, 300], {middleBoundaryMode: true});\n```\n\nGet blocks like below:\n\n```js\n[\n    {\n        \"width\": 500,\n        \"height\": 100,\n        \"x\": 0,\n        \"y\": 0,\n        \"children\": [\n            {\n                \"width\": 100,\n                \"height\": 100,\n                \"x\": 100,\n                \"y\": 0,\n                \"left\": 0,\n                \"top\": 0,\n                \"parentBlockIndex\": 0,\n                \"index\": 0\n            },\n            {\n                \"width\": 100,\n                \"height\": 100,\n                \"x\": 200,\n                \"y\": 0,\n                \"left\": 100,\n                \"top\": 0,\n                \"parentBlockIndex\": 0,\n                \"index\": 1\n            }\n        ],\n        \"boundary\": {\n            \"leftTop\": {\n                \"x\": 100,\n                \"y\": 0\n            },\n            \"rightBottom\": {\n                \"x\": 300,\n                \"y\": 100\n            }\n        }\n    },\n    ...\n]\n```\n\n## Where is this library used?\n\nIf you are using this library in one of your projects, add it in this list :)\n\n- [image-to-slices](https://github.com/superRaytin/image-to-slices)\n- [Puzzler](https://github.com/superRaytin/puzzler)\n\n# Testing\n\n```\nnpm test\n```\n\n# License\n\nMIT, see the [LICENSE](/LICENSE) file for detail.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperraytin%2Fslices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuperraytin%2Fslices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuperraytin%2Fslices/lists"}