123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- {
- "manifest": {
- "name": "bitmap-sdf",
- "version": "1.0.3",
- "description": "Calculate SDF for image/bw-data/array",
- "main": "index.js",
- "dependencies": {
- "clamp": "^1.0.1"
- },
- "devDependencies": {
- "enable-mobile": "^1.0.7",
- "bubleify": "^0.7.0"
- },
- "scripts": {
- "test": "budo test",
- "build": "browserify test.js -g bubleify | indexhtmlify | metadataify | github-cornerify > index.html"
- },
- "repository": {
- "type": "git",
- "url": "git+https://github.com/dfcreative/bitmap-sdf.git"
- },
- "keywords": [
- "sdf",
- "signed-distance",
- "image-sdf",
- "bitmap",
- "bwdist",
- "tiny-sdf"
- ],
- "author": {
- "name": "Dima Yv",
- "email": "dfcreative@gmail.com"
- },
- "license": "MIT",
- "bugs": {
- "url": "https://github.com/dfcreative/bitmap-sdf/issues"
- },
- "homepage": "https://github.com/dfcreative/bitmap-sdf#readme",
- "_registry": "npm",
- "_loc": "/home/jovyan/.cache/yarn/v6/npm-bitmap-sdf-1.0.3-c99913e5729357a6fd350de34158180c013880b2-integrity/node_modules/bitmap-sdf/package.json",
- "readmeFilename": "readme.md",
- "readme": "# bitmap-sdf [![unstable](https://img.shields.io/badge/stability-unstable-green.svg)](http://github.com/badges/stability-badges)\n\nCalculate signed distance field for an image / bw-data. Fork of [tiny-sdf](https://github.com/mapbox/tiny-sdf) with reduced API.\n\n![bitmap-sdf](https://raw.githubusercontent.com/dfcreative/bitmap-sdf/master/preview.png)\n\n[Demo](https://dfcreative.github.io/bitmap-sdf/)\n\n## Usage\n\n[![npm install bitmap-sdf](https://nodei.co/npm/bitmap-sdf.png?mini=true)](https://npmjs.org/package/bitmap-sdf/)\n\n```js\nlet calcSdf = requrie('bitmap-sdf')\n\n//draw image\nlet canvas = document.body.appendChild(document.createElement('canvas'))\nlet w = canvas.width = 200, h = canvas.height = 200\nlet ctx = canvas.getContext('2d')\nctx.fillStyle = 'white'\nctx.font = 'bold 30px sans-serif'\nctx.fillText('X', 20, 20)\n\n//calculate distances\nlet distances = calcSdf(canvas)\n\n//show distances\nlet imgArr = new Uint8ClampedArray(w*h*4)\nfor (let i = 0; i < w; i++) {\n\tfor (let j = 0; j < h; j++) {\n\t\timgArr[j*w*4 + i*4 + 0] = arr[j*w+i]*255\n\t\timgArr[j*w*4 + i*4 + 1] = arr[j*w+i]*255\n\t\timgArr[j*w*4 + i*4 + 2] = arr[j*w+i]*255\n\t\timgArr[j*w*4 + i*4 + 3] = 255\n\t}\n}\nvar data = new ImageData(imgArr, w, h)\nctx.putImageData(data, 0, 0)\n```\n\n### dist = calcSdf(source, options?)\n\nCalculate distance field for the input `source` data, based on `options`. Returns 1-channel array with distance values from `0..1` range.\n\n#### Source:\n\nType | Meaning\n---|---\n_Canvas_, _Context2D_ | Calculates sdf for the full canvas image data based on `options.channel`, by default `0`, ie. red channel.\n_ImageData_ | Calculates sdf for the image data based on `options.channel`\n_Uint8ClampedArray_, _Uint8Array_ | Handles raw pixel data, requires `options.width` and `options.height`. Stride is detected from `width` and `height`.\n_Float32Array_, _Array_ | Handles raw numbers from `0..1` range, requires `options.width` and `options.height`. Stride is detected from `width` and `height`.\n\n#### Options:\n\nProperty | Default | Meaning\n---|---|---\n`cutoff` | `0.25` | Cutoff parameter, balance between SDF inside `1` and outside `0` of glyph\n`radius` | `10` | Max length of SDF, ie. the size of SDF around the `cutoff`\n`width` | `canvas.width` | Width of input data, if array\n`height` | `canvas.height` | Height of input data, if array\n`channel` | `0` | Channel number, `0` is red, `1` is green, `2` is blue, `3` is alpha.\n`stride` | `null` | Explicitly indicate number of channels per pixel. Not needed if `height` and `width` are provided.\n\n## See also\n\n* [font-atlas-sdf](https://github.com/hughsk/font-atlas-sdf) − generate sdf atlas for a font.\n* [tiny-sdf](https://github.com/mapbox/tiny-sdf) − fast glyph signed distance field generation.\n* [optical-properties](https://github.com/dfcreative/optical-properties) − glyph optical center and bounding box calculation\n\n## License\n\n(c) 2017 Dima Yv. MIT License\n\nDevelopment supported by plot.ly.\n"
- },
- "artifacts": [],
- "remote": {
- "resolved": "https://registry.yarnpkg.com/bitmap-sdf/-/bitmap-sdf-1.0.3.tgz#c99913e5729357a6fd350de34158180c013880b2",
- "type": "tarball",
- "reference": "https://registry.yarnpkg.com/bitmap-sdf/-/bitmap-sdf-1.0.3.tgz",
- "hash": "c99913e5729357a6fd350de34158180c013880b2",
- "integrity": "sha512-ojYySSvWTx21cbgntR942zgEgqj38wHctN64vr4vYRFf3GKVmI23YlA94meWGkFslidwLwGCsMy2laJ3g/94Sg==",
- "registry": "npm",
- "packageName": "bitmap-sdf",
- "cacheIntegrity": "sha512-ojYySSvWTx21cbgntR942zgEgqj38wHctN64vr4vYRFf3GKVmI23YlA94meWGkFslidwLwGCsMy2laJ3g/94Sg== sha1-yZkT5XKTV6b9NQ3jQVgYDAE4gLI="
- },
- "registry": "npm",
- "hash": "c99913e5729357a6fd350de34158180c013880b2"
- }
|