Skip to content

Commit

Permalink
Merge pull request #308 from miyanokomiya/for_svegif
Browse files Browse the repository at this point in the history
For svegif
  • Loading branch information
miyanokomiya committed Nov 21, 2020
2 parents 9066ec3 + 96f4658 commit 74f9e3f
Show file tree
Hide file tree
Showing 15 changed files with 1,585 additions and 897 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -13,7 +13,7 @@ yarn add okageo
```

```js
import okageo from 'okageo'
import * as okageo from 'okageo'

// parse SVG to polygons
const pathInfoList = okageo.svg.parseSvgGraphicsStr(svgString)
Expand Down
38 changes: 25 additions & 13 deletions demo/main.ts
Expand Up @@ -7,32 +7,44 @@ const ctx = canvas.getContext('2d')
if (ctx) {
ctx.clearRect(0, 0, canvas.width, canvas.height)

const p1 = [{ x: 0, y: 0 }, { x: 100, y: 0 }, { x: 0, y: 100 }]
const p2 = [{ x: -100, y: -100 }, { x: -100, y: 400 }, { x: 200, y: -100 }]
const p3 = [{ x: -200, y: -200 }, { x: 300, y: -200 }, { x: -200, y: 600 }]
const p1 = [
{ x: 0, y: 0 },
{ x: 100, y: 0 },
{ x: 0, y: 100 },
]
const p2 = [
{ x: -100, y: -100 },
{ x: -100, y: 400 },
{ x: 200, y: -100 },
]
const p3 = [
{ x: -200, y: -200 },
{ x: 300, y: -200 },
{ x: -200, y: 600 },
]
const pathInfoList: ISvgPath[] = [
{
d: [
{ x: -300, y: 50 },
{ x: 200, y: 50 },
{ x: 200, y: 100 },
{ x: -300, y: 100 }
{ x: -300, y: 100 },
],
style: {
...svg.createStyle(),
fill: true,
fillStyle: 'red'
}
fillStyle: 'red',
},
},
{
d: p3,
included: [p2, p1],
style: {
...svg.createStyle(),
fill: true,
fillStyle: 'blue'
}
}
fillStyle: 'blue',
},
},
]
const inRectList = svg.fitRect(
pathInfoList,
Expand All @@ -41,11 +53,11 @@ if (ctx) {
canvas.width,
canvas.height
)
inRectList.forEach(info => svg.draw(ctx, info))
inRectList.forEach((info) => svg.draw(ctx, info))
}

const fileInput = document.getElementById('input') as HTMLInputElement
fileInput.onchange = e => {
fileInput.onchange = (e) => {
const file = (e.target as HTMLInputElement).files
if (!file || file.length === 0) return

Expand All @@ -62,8 +74,8 @@ fileInput.onchange = e => {
canvas.width,
canvas.height
)
inRectList.forEach(info => {
geo.triangleSplit(info.d).forEach(points => {
inRectList.forEach((info) => {
geo.triangleSplit(info.d).forEach((points) => {
svg.draw(ctx, { d: points, style: info.style })
})
})
Expand Down
1 change: 1 addition & 0 deletions echo
@@ -0,0 +1 @@
abc
33 changes: 13 additions & 20 deletions package.json
@@ -1,8 +1,9 @@
{
"name": "okageo",
"version": "1.1.10",
"version": "2.0.0",
"description": "parse SVG to polygons",
"main": "./dist/okageo.min.js",
"module": "./dist/okageo.esm.min.js",
"author": "miyanokomiya",
"license": "MIT",
"repository": {
Expand All @@ -14,21 +15,22 @@
],
"types": "./dist/okageo.d.ts",
"scripts": {
"lint": "yarn eslint ./src ./test ./*.js --ext .js,.ts && yarn prettier -c ./*.json ./.*.json",
"lint:fix": "yarn eslint --fix ./src ./test ./*.js --ext .js,.ts && yarn prettier --write ./*.json ./.*.json",
"lint": "yarn eslint ./src ./test ./demo ./*.js --ext .js,.ts && yarn prettier -c ./*.json ./.*.json",
"lint:fix": "yarn eslint --fix ./src ./test ./demo ./*.js --ext .js,.ts && yarn prettier --write ./*.json ./.*.json",
"test": "jest --coverage",
"doc": "typedoc --out doc ./src/okageo.ts",
"demo": "parcel demo/index.html",
"build": "rm -rf ./dist && yarn bili",
"build": "rm -rf ./dist && yarn bili --format cjs-min --format esm-min",
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@types/jest": "^26.0.3",
"@typescript-eslint/eslint-plugin": "^2.13.0",
"@typescript-eslint/parser": "^2.13.0",
"babel-jest": "^26.0.1",
"@types/jest": "^26.0.9",
"@typescript-eslint/eslint-plugin": "^3.8.0",
"@typescript-eslint/parser": "^3.8.0",
"babel-jest": "^26.2.2",
"bili": "^5.0.5",
"coveralls": "^3.0.6",
"eslint": "^6.8.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.9.0",
"eslint-config-standard": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
Expand All @@ -37,21 +39,12 @@
"eslint-plugin-prettier": "^3.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"husky": "^4.2.3",
"jest": "^25.1.0",
"jest": "^26.2.2",
"parcel-bundler": "^1.11.0",
"prettier": "^2.0.5",
"rollup-plugin-typescript2": "^0.27.0",
"ts-jest": "^25.2.1",
"ts-jest": "^26.1.4",
"typedoc": "^0.19.1",
"typescript": "^3.7.4"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
},
"dependencies": {
"bili": "^5.0.5"
}
}

0 comments on commit 74f9e3f

Please sign in to comment.