-
Notifications
You must be signed in to change notification settings - Fork 649
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8eefd29
commit 91a14ed
Showing
32 changed files
with
106 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,44 @@ | ||
import { CanvasRenderer, Canvas } from '@antv/f-engine'; | ||
import { Canvas } from '@antv/f-engine'; | ||
import { deepMix } from '@antv/util'; | ||
import Layout from './base/layout'; | ||
import defaultTheme from './theme'; | ||
import { px2hd as defaultPx2hd, batch2hd } from './util'; | ||
|
||
class f2Canvas extends Canvas { | ||
layout: Layout; | ||
// class f2Canvas extends Canvas { | ||
// layout: Layout; | ||
|
||
constructor(props) { | ||
const theme = deepMix({}, defaultTheme, props.theme); | ||
props = { | ||
...props, | ||
px2hd: props.px2hd ? batch2hd(props.px2hd) : defaultPx2hd, | ||
renderer: props.renderer || new CanvasRenderer(), | ||
theme, | ||
}; | ||
super(props); | ||
// constructor(props) { | ||
// const theme = deepMix({}, defaultTheme, props.theme); | ||
// props = { | ||
// ...props, | ||
// px2hd: props.px2hd ? batch2hd(props.px2hd) : defaultPx2hd, | ||
// renderer: props.renderer || new CanvasRenderer(), | ||
// theme, | ||
// }; | ||
// super(props); | ||
|
||
const { style: customStyle, px2hd } = props; | ||
const { width: canvasWidth, height: canvasHeight } = this.getCanvasConfig(); | ||
// const { style: customStyle, px2hd } = props; | ||
// const { width: canvasWidth, height: canvasHeight } = this.getCanvasConfig(); | ||
|
||
const style = px2hd({ | ||
left: 0, | ||
top: 0, | ||
width: canvasWidth, | ||
height: canvasHeight, | ||
padding: theme.padding, | ||
...customStyle, | ||
}); | ||
// const style = px2hd({ | ||
// left: 0, | ||
// top: 0, | ||
// width: canvasWidth, | ||
// height: canvasHeight, | ||
// padding: theme.padding, | ||
// ...customStyle, | ||
// }); | ||
|
||
const layout = Layout.fromStyle(style); | ||
this.layout = layout; | ||
// const layout = Layout.fromStyle(style); | ||
// this.layout = layout; | ||
|
||
this.setContext({ | ||
left: layout.left, | ||
top: layout.top, | ||
width: layout.width, | ||
height: layout.height, | ||
}); | ||
} | ||
} | ||
// this.setContext({ | ||
// left: layout.left, | ||
// top: layout.top, | ||
// width: layout.width, | ||
// height: layout.height, | ||
// }); | ||
// } | ||
// } | ||
|
||
export { f2Canvas }; | ||
export default Canvas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* expand Vec2 | ||
*/ | ||
import { angle as vec2Angle } from 'gl-matrix/vec2'; | ||
|
||
const vec2Direction = (v1, v2) => { | ||
return v1[0] * v2[1] - v2[0] * v1[1]; | ||
}; | ||
|
||
const vec2Zero = (v) => { | ||
return v[0] === 0 && v[1] === 0; | ||
}; | ||
|
||
const vec2AngleTo = (v1, v2, direction) => { | ||
const angle = vec2Angle(v1, v2); | ||
const angleLargeThanPI = vec2Direction(v1, v2) >= 0; | ||
if (direction) { | ||
if (angleLargeThanPI) { | ||
return Math.PI * 2 - angle; | ||
} | ||
|
||
return angle; | ||
} | ||
|
||
if (angleLargeThanPI) { | ||
return angle; | ||
} | ||
return Math.PI * 2 - angle; | ||
}; | ||
|
||
export { vec2Zero, vec2AngleTo }; |
Binary file added
BIN
+12.6 KB
packages/f2/test/__image_snapshots__/index-test-ts-index-index-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+8.57 KB
...nents/interval/__image_snapshots__/interval-test-tsx-interval-render-2-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+13.8 KB
...ponents/legend/__image_snapshots__/pie-test-tsx-geometry-attr-不传size-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.