Skip to content

Commit

Permalink
Release (#1473)
Browse files Browse the repository at this point in the history
* fix: path should downgrade to line and support billboard effect (#1469)

* fix: polyfill for performance.now

* chore: commit changeset

* fix: path should downgrade to line and support billboard effect #1443

* fix: remove redundant m commands when parsing path #1447

* fix: removing redundant m command should account for prev z command

* chore: commit changeset

* chore: use get-pixels loading local image instead of fetching in ssr #1471

* chore(release): bump version (#1472)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Aug 11, 2023
1 parent 9f11a3a commit e971431
Show file tree
Hide file tree
Showing 111 changed files with 858 additions and 87 deletions.
37 changes: 15 additions & 22 deletions __tests__/integration/__node__tests__/webgl/image.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const fs = require('fs');
const { createCanvas, Image: CanvasImage, loadImage } = require('canvas');
const getPixels = require('get-pixels');
const { createCanvas } = require('canvas');
const { Image, Canvas, Rectangle } = require('@antv/g');
const { Renderer } = require('@antv/g-webgl');
const { createPNGFromRawdata, sleep, diff } = require('../../util');
Expand Down Expand Up @@ -43,10 +44,6 @@ const canvas = new Canvas({
canvas: mockCanvas, // use headless-gl
renderer,
offscreenCanvas: offscreenNodeCanvas,
createImage: () => {
const image = new CanvasImage();
return image;
},
});

const RESULT_IMAGE = '/image.png';
Expand All @@ -65,7 +62,19 @@ describe('Render <Image> with g-webgl', () => {
it('should render image on server-side correctly.', async () => {
await canvas.ready;

const src = await loadImage(__dirname + '/antv.png');
// Load local image instead of fetching remote URL.
// @see https://github.com/stackgl/headless-gl/pull/53/files#diff-55563b6c0b90b80aed19c83df1c51e80fd45d2fbdad6cc047ee86e98f65da3e9R83
const src = await new Promise((resolve, reject) => {
getPixels(__dirname + '/antv.png', function (err, image) {
if (err) {
reject('Bad image path');
} else {
image.width = image.shape[0];
image.height = image.shape[1];
resolve(image);
}
});
});

// URL src
const image = new Image({
Expand All @@ -77,22 +86,6 @@ describe('Render <Image> with g-webgl', () => {
});
canvas.appendChild(image);

// <canvas> src
const nodeCanvasSrc = createCanvas(50, 50);
const context = nodeCanvasSrc.getContext('2d');
context.fillStyle = 'red';
context.fillRect(0, 0, 50, 50);
const image2 = new Image({
style: {
x: 100,
y: 100,
width: 100,
height: 100,
src: nodeCanvasSrc,
},
});
canvas.appendChild(image2);

await sleep(200);

const pixels = new Uint8Array(width * height * 4);
Expand Down
Binary file modified __tests__/integration/__node__tests__/webgl/snapshots/image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 55 additions & 0 deletions __tests__/unit/css/parser/path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,59 @@ describe('Property Path', () => {

mergePaths(path1, path2);
});

it('should remove redundant M commands correctly.', () => {
let parsed = parsePath('M 0 0 M 0 0 M 0 0 L 100 100');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['L', 100, 100],
]);

parsed = parsePath('M 0 0 L 100 100 Z M 0 0 L 0 0');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['L', 100, 100],
['Z'],
['M', 0, 0],
['L', 0, 0],
]);

parsed = parsePath('M 0 0 M 0 0 M 0 0 L 100 100 M 100 100 L 200 200');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['L', 100, 100],
['L', 200, 200],
]);

parsed = parsePath('M 0 0 C 50 0 100 0 100 100 M 100 100 L 200 200');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['C', 50, 0, 100, 0, 100, 100],
['L', 200, 200],
]);

parsed = parsePath('M 0 0 Q 50 0 100 100 M 100 100 L 200 200');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['Q', 50, 0, 100, 100],
['L', 200, 200],
]);

parsed = parsePath(
'M 0 0 A 50 0 0 0 0 100 100 M 100 100 M 100 100 M 100 100 L 200 200',
);
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['A', 50, 0, 0, 0, 0, 100, 100],
['L', 200, 200],
]);

parsed = parsePath('M 0 0 Q 50 0 100 100 M 200 100 L 200 200');
expect(parsed.absolutePath).toStrictEqual([
['M', 0, 0],
['Q', 50, 0, 100, 100],
['M', 200, 100],
['L', 200, 200],
]);
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"eslint-plugin-jest": "24.3.6",
"git-contributor": "~1.0.11",
"gl": "^6.0.2",
"get-pixels": "3.3.3",
"hammerjs": "^2.0.8",
"husky": "^7.0.4",
"is-ci": "2.0.0",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-camera-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-camera-api

## 1.2.12

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12

## 1.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-camera-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-camera-api",
"version": "1.2.11",
"version": "1.2.12",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
14 changes: 14 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @antv/g-canvas

## 1.11.13

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12
- @antv/g-plugin-canvas-path-generator@1.3.12
- @antv/g-plugin-canvas-picker@1.10.12
- @antv/g-plugin-canvas-renderer@1.9.12
- @antv/g-plugin-dom-interaction@1.9.12
- @antv/g-plugin-html-renderer@1.9.13
- @antv/g-plugin-image-loader@1.3.12

## 1.11.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "1.11.12",
"version": "1.11.13",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
14 changes: 14 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# @antv/g-canvaskit

## 0.10.13

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12
- @antv/g-plugin-canvas-path-generator@1.3.12
- @antv/g-plugin-canvas-picker@1.10.12
- @antv/g-plugin-canvaskit-renderer@1.3.12
- @antv/g-plugin-dom-interaction@1.9.12
- @antv/g-plugin-html-renderer@1.9.13
- @antv/g-plugin-image-loader@1.3.12

## 0.10.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvaskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvaskit",
"version": "0.10.12",
"version": "0.10.13",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-components

## 1.9.12

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12

## 1.9.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-components",
"version": "1.9.11",
"version": "1.9.12",
"description": "Components for g",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-dom-mutation-observer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-dom-mutation-observer-api

## 1.2.12

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12

## 1.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-dom-mutation-observer-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-dom-mutation-observer-api",
"version": "1.2.11",
"version": "1.2.12",
"description": "A simple implementation of DOM MutationObserver API.",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-gesture/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-gesture

## 2.2.14

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12

## 2.2.13

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-gesture/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-gesture",
"version": "2.2.13",
"version": "2.2.14",
"description": "G Gesture",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-image-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-image-exporter

## 0.7.12

### Patch Changes

- Updated dependencies [eb61cba4]
- Updated dependencies [eb61cba4]
- @antv/g-lite@1.2.12

## 0.7.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-image-exporter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-image-exporter",
"version": "0.7.11",
"version": "0.7.12",
"description": "A image exporter for G using DOM API",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-lite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-lite

## 1.2.12

### Patch Changes

- eb61cba4: Add polyfill for performance.now.
- eb61cba4: Remove redundant m command when parsing path.

## 1.2.11

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-lite",
"version": "1.2.11",
"version": "1.2.12",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down
3 changes: 3 additions & 0 deletions packages/g-lite/src/css/parser/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
getPathBBox,
hasArcOrBezier,
path2Segments,
removeRedundantMCommand,
} from '../../utils/path';

const internalParsePath = (path: string | PathArray) => {
Expand Down Expand Up @@ -47,6 +48,8 @@ const internalParsePath = (path: string | PathArray) => {
console.error(`[g]: Invalid SVG Path definition: ${path}`);
}

removeRedundantMCommand(absolutePath);

const hasArc = hasArcOrBezier(absolutePath);

const { polygons, polylines } = extractPolygons(absolutePath);
Expand Down
2 changes: 2 additions & 0 deletions packages/g-lite/src/display-objects/Polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface PolygonStyleProps extends BaseStyleProps {
*/
markerEndOffset?: number;
isClosed?: boolean;
isBillboard?: boolean;
}
export interface ParsedPolygonStyleProps extends ParsedBaseStyleProps {
points: {
Expand All @@ -41,6 +42,7 @@ export interface ParsedPolygonStyleProps extends ParsedBaseStyleProps {
markerStartOffset?: number;
markerEndOffset?: number;
isClosed?: boolean;
isBillboard?: boolean;
}

export class Polygon extends DisplayObject<
Expand Down
2 changes: 2 additions & 0 deletions packages/g-lite/src/display-objects/Polyline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface PolylineStyleProps extends BaseStyleProps {
* offset relative to original position
*/
markerEndOffset?: number;
isBillboard?: boolean;
}
export interface ParsedPolylineStyleProps extends ParsedBaseStyleProps {
points: {
Expand All @@ -43,6 +44,7 @@ export interface ParsedPolylineStyleProps extends ParsedBaseStyleProps {
markerEnd?: DisplayObject | null;
markerStartOffset?: number;
markerEndOffset?: number;
isBillboard?: boolean;
}

/**
Expand Down
Loading

0 comments on commit e971431

Please sign in to comment.