Skip to content

Commit

Permalink
Library rewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas von Hertzen authored and niklasvh committed Jul 31, 2017
1 parent 83e9b85 commit 8a6fb5f
Show file tree
Hide file tree
Showing 70 changed files with 2,521 additions and 3,219 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["es2015", "flow"]
}
15 changes: 15 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"parser": "babel-eslint",
"plugins": [
"prettier"
],
"rules": {
"prettier/prettier": ["error", {
"singleQuote": true,
"bracketSpacing": false,
"parser": "flow",
"tabWidth": 4,
"printWidth": 100
}]
}
}
6 changes: 6 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[ignore]
[include]
[libs]
./flow-typed
[options]
[lints]
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/dist
/nbproject/
image.jpg
/.project
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

19 changes: 0 additions & 19 deletions .jshintrc

This file was deleted.

3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ env:
- secure: YI+YbTOGf2x4fPMKW+KhJiZWswoXT6xOKGwLfsQsVwmFX1LerJouil5D5iYOQuL4FE3pNaoJSNakIsokJQuGKJMmnPc8rdhMZuBJBk6MRghurE2Xe9qBHfuUBPlfD61nARESm4WDcyMwM0QVYaOKeY6aIpZ91qbUbyc60EEx3C4=
addons:
sauce_connect: true
before_script:
- npm install -g grunt-cli
- npm install -g uglify-js
notifications:
webhooks:
urls:
Expand Down
216 changes: 0 additions & 216 deletions Gruntfile.js

This file was deleted.

1 change: 1 addition & 0 deletions flow-typed/myLibDef.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare var __DEV__: boolean;
49 changes: 24 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "html2canvas",
"description": "Screenshots with JavaScript",
"main": "dist/html2canvas.js",
"version": "0.5.0-beta4",
"version": "1.0.0-alpha.1",
"author": {
"name": "Niklas von Hertzen",
"email": "niklasvh@gmail.com",
Expand All @@ -20,32 +20,31 @@
"url": "https://github.com/niklasvh/html2canvas/issues"
},
"devDependencies": {
"base64-arraybuffer": "^0.1.5",
"bluebird": "^3.0.6",
"browserify-derequire": "^0.9.4",
"grunt": "^0.4.5",
"grunt-browserify": "^4.0.1",
"grunt-cli": "^0.1.13",
"grunt-contrib-connect": "^0.11.2",
"grunt-contrib-jshint": "^0.11.3",
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-execute": "^0.2.2",
"grunt-mocha-cli": "^1.12.0",
"grunt-mocha-phantomjs": "^2.0.0",
"html2canvas-proxy": "0.0.5",
"humanize-duration": "^2.0.1",
"lodash": "^3.10.1",
"pngjs": "^2.2.0",
"requirejs": "^2.1.20",
"sauce-connect-launcher": "^0.13.0",
"wd": "^0.4.0"
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-eslint": "7.2.3",
"babel-loader": "7.1.1",
"babel-preset-es2015": "6.24.1",
"babel-preset-flow": "6.23.0",
"base64-arraybuffer": "0.1.5",
"eslint": "4.2.0",
"eslint-plugin-prettier": "^2.1.2",
"flow-bin": "0.50.0",
"prettier": "1.5.3",
"rimraf": "2.6.1",
"webpack": "3.4.1"
},
"scripts": {
"test": "grunt travis --verbose",
"start": "grunt server",
"sauceconnect": "tests/sauceconnect.js"
"build": "rimraf dist/ && babel src/ -d dist/npm/",
"build:browser": "webpack",
"format": "prettier --single-quote --no-bracket-spacing --tab-width 4 --print-width 100 --write \"src/**/*.js\"",
"flow": "flow",
"lint": "eslint src/**",
"test": "npm run flow && npm run lint"
},
"homepage": "http://html2canvas.hertzen.com",
"license": "MIT"
"license": "MIT",
"dependencies": {
"punycode": "2.1.0"
}
}
36 changes: 36 additions & 0 deletions src/BezierCurve.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import Vector from './Vector';

export default class BezierCurve {
start: Vector;
startControl: Vector;
endControl: Vector;
end: Vector;

constructor(start: Vector, startControl: Vector, endControl: Vector, end: Vector) {
this.start = start;
this.startControl = startControl;
this.endControl = endControl;
this.end = end;
}

lerp(a: Vector, b: Vector, t: number): Vector {
return new Vector(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t);
}

subdivide(t: number): [BezierCurve, BezierCurve] {
const ab = this.lerp(this.start, this.startControl, t);
const bc = this.lerp(this.startControl, this.endControl, t);
const cd = this.lerp(this.endControl, this.end, t);
const abbc = this.lerp(ab, bc, t);
const bccd = this.lerp(bc, cd, t);
const dest = this.lerp(abbc, bccd, t);
return [
new BezierCurve(this.start, ab, abbc, dest),
new BezierCurve(dest, bccd, cd, this.end)
];
}

reverse(): BezierCurve {
return new BezierCurve(this.end, this.endControl, this.startControl, this.start);
}
}
Loading

0 comments on commit 8a6fb5f

Please sign in to comment.