-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: allow constructing pattern with basic shapes #1226 * chore: update pattern's docs * chore: update docs for <gradient> * fix: avoid generating pattern key for empty id #1225 * Publish - @antv/g-camera-api@1.0.19 - @antv/g-canvas@1.9.18 - @antv/g-canvaskit@0.8.18 - @antv/g-components@1.7.30 - @antv/g-css-layout-api@1.0.19 - @antv/g-css-typed-om-api@1.0.19 - @antv/g-devtool@0.10.30 - @antv/g-dom-mutation-observer-api@1.0.19 - @antv/g-gesture@0.0.53 - @antv/g-image-exporter@0.5.30 - @antv/g-layout-blocklike@1.7.30 - @antv/g-lite@1.0.19 - @antv/g-lottie-player@0.0.16 - @antv/g-math@1.7.30 - @antv/g-mobile-canvas-element@0.6.30 - @antv/g-mobile-canvas@0.8.27 - @antv/g-mobile-svg@0.8.27 - @antv/g-mobile-webgl@0.7.33 - @antv/g-pattern@0.0.3 - @antv/g-plugin-3d@1.7.30 - @antv/g-plugin-a11y@0.4.30 - @antv/g-plugin-annotation@0.2.27 - @antv/g-plugin-box2d@1.7.30 - @antv/g-plugin-canvas-path-generator@1.1.30 - @antv/g-plugin-canvas-picker@1.8.27 - @antv/g-plugin-canvas-renderer@1.7.33 - @antv/g-plugin-canvaskit-renderer@1.1.31 - @antv/g-plugin-control@1.7.30 - @antv/g-plugin-css-select@1.7.30 - @antv/g-plugin-device-renderer@1.7.33 - @antv/g-plugin-dom-interaction@1.7.30 - @antv/g-plugin-dragndrop@1.6.30 - @antv/g-plugin-gpgpu@1.7.30 - @antv/g-plugin-html-renderer@1.7.30 - @antv/g-plugin-image-loader@1.1.31 - @antv/g-plugin-matterjs@1.7.30 - @antv/g-plugin-mobile-interaction@0.7.30 - @antv/g-plugin-physx@1.7.30 - @antv/g-plugin-rough-canvas-renderer@1.7.31 - @antv/g-plugin-rough-svg-renderer@1.7.31 - @antv/g-plugin-svg-picker@1.7.30 - @antv/g-plugin-svg-renderer@1.8.27 - @antv/g-plugin-webgl-device@1.7.30 - @antv/g-plugin-webgpu-device@1.7.30 - @antv/g-plugin-yoga@1.7.30 - @antv/g-shader-components@1.7.30 - @antv/g-svg@1.8.27 - @antv/g-web-animations-api@1.0.19 - @antv/g-web-components@1.7.30 - @antv/g-webgl@1.7.33 - @antv/g-webgpu@1.7.33 - @antv/g@5.14.1 - @antv/react-g@1.8.27
- Loading branch information
Showing
99 changed files
with
2,252 additions
and
1,091 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
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,62 @@ | ||
import { Canvas, Circle } from '@antv/g'; | ||
import { Renderer as CanvasRenderer } from '@antv/g-mobile-canvas'; | ||
import { createMobileCanvasElement } from '@antv/g-mobile-canvas-element'; | ||
import { createContext } from './util'; | ||
|
||
describe('canvas', () => { | ||
it('基础图形 canvas render', async () => { | ||
const context = createContext(); | ||
const canvasElement = createMobileCanvasElement(context); | ||
|
||
// 创建渲染器 | ||
const renderer = new CanvasRenderer(); | ||
const canvas = new Canvas({ | ||
canvas: canvasElement, | ||
devicePixelRatio: window.devicePixelRatio, | ||
renderer, | ||
}); | ||
|
||
// create a circle | ||
const circle = new Circle({ | ||
style: { | ||
cx: 100, | ||
cy: 100, | ||
r: 10, | ||
fill: '#1890FF', | ||
stroke: '#F04864', | ||
lineWidth: 2, | ||
shadowColor: 'black', | ||
shadowBlur: 20, | ||
}, | ||
}); | ||
|
||
await canvas.ready; | ||
canvas.appendChild(circle); | ||
|
||
canvas.addEventListener('pointerdown', (e) => { | ||
console.log('pointerdown'); | ||
}); | ||
canvas.addEventListener('pointerup', (e) => { | ||
console.log('pointerup'); | ||
}); | ||
canvas.addEventListener('pointermove', (e) => { | ||
console.log('pointermove'); | ||
}); | ||
canvas.addEventListener('pointerover', (e) => { | ||
console.log('pointerover'); | ||
}); | ||
canvas.addEventListener('dragstart', (e) => { | ||
console.log('dragstart'); | ||
}); | ||
canvas.addEventListener('drag', (e) => { | ||
console.log('drag'); | ||
}); | ||
canvas.addEventListener('dragend', (e) => { | ||
console.log('dragend'); | ||
}); | ||
|
||
canvas.addEventListener('click', (e) => { | ||
console.log('click'); | ||
}); | ||
}); | ||
}); |
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,30 @@ | ||
function delay(time) { | ||
return new Promise((resolve) => { | ||
setTimeout(resolve, time); | ||
}); | ||
} | ||
|
||
const createContext = ( | ||
title = '', | ||
{ width = 300, height = 300 } = {}, | ||
type = '2d', | ||
) => { | ||
if (title) { | ||
const titleEl = document.createElement('p'); | ||
titleEl.innerText = title + ':'; | ||
titleEl.style.fontSize = '12px'; | ||
document.body.appendChild(titleEl); | ||
} | ||
|
||
const $canvas = document.createElement('canvas'); | ||
const dpr = window.devicePixelRatio; | ||
$canvas.width = dpr * width; | ||
$canvas.height = dpr * height; | ||
$canvas.style.width = `${width}px`; | ||
$canvas.style.height = `${height}px`; | ||
document.body.appendChild($canvas); | ||
|
||
return $canvas.getContext(type) as CanvasRenderingContext2D; | ||
}; | ||
|
||
export { createContext, delay }; |
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
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
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
Oops, something went wrong.