Skip to content

Commit

Permalink
Release (#1696)
Browse files Browse the repository at this point in the history
* fix: support gradient text (#1694)

* fix: render correctly in canvas when stroke is empty #1616

* chore: commit changeset

* fix: support gradient text in canvas & svg #1572

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

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

* chore: transform d3-color in jest

* fix: skip filling on text

---------

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 committed May 23, 2024
1 parent 7e06b54 commit 0d2b174
Show file tree
Hide file tree
Showing 38 changed files with 496 additions and 199 deletions.
2 changes: 1 addition & 1 deletion __tests__/demos/2d/transform-text.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Circle, Text, runtime } from '../../../packages/g';
import { Circle, Text } from '../../../packages/g';

export async function transformText(context) {
const { canvas } = context;
Expand Down
55 changes: 55 additions & 0 deletions __tests__/demos/bugfix/1572.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Text, Rect } from '../../../packages/g';

export async function gradient_text(context) {
const { canvas } = context;
await canvas.ready;

const rect = new Rect({
style: {
x: 0,
y: 0,
width: 100,
height: 100,
fill: 'linear-gradient(90deg, red 0%, green 100%)',
},
});
canvas.appendChild(rect);

const text = new Text({
style: {
text: `两种渐变都有一个叫做 gradientUnits(渐变单元)的属性,它描述了用来描述渐变的大小和方向的单元系统。该属性有两个值:userSpaceOnUse 、objectBoundingBox。默认值为 objectBoundingBox,我们目前看到的效果都是在这种系统下的,它大体上定义了对象的渐变大小范围,所以你只要指定从 0 到 1 的坐标值,渐变就会自动的缩放到对象相同大小。userSpaceOnUse 使用绝对单元,所以你必须知道对象的位置,并将渐变放在同样地位置上。在每个.shp,.shx与.dbf文件之中,图形在每个文件的排序是一致的。也就是说,.shp的第一条记录与.shx及.dbf之中的第一条记录相对应,如此类推。此外,在.shp与.shx之中,有许多字段的字节序是不一样的。因此用户在编写读取这些文件格式的程序时,必须十分小心地处理不同文件的不同字节序。`,
x: 0,
y: 0,
// dy: 10,
textBaseline: 'top',
wordWrap: true,
wordWrapWidth: 800,
fill: 'linear-gradient(90deg, red 0%, green 100%)',
},
});
canvas.appendChild(text);

const rect2 = new Rect({
style: {
x: 0,
y: 200,
width: 100,
height: 100,
fill: 'linear-gradient(90deg, red 0.1%, green 100%)',
},
});
canvas.appendChild(rect2);
const text2 = new Text({
style: {
text: `两种渐变都有一个叫做 gradientUnits(渐变单元)的属性,它描述了用来描述渐变的大小和方向的单元系统。该属性有两个值:userSpaceOnUse 、objectBoundingBox。默认值为 objectBoundingBox,我们目前看到的效果都是在这种系统下的,它大体上定义了对象的渐变大小范围,所以你只要指定从 0 到 1 的坐标值,渐变就会自动的缩放到对象相同大小。userSpaceOnUse 使用绝对单元,所以你必须知道对象的位置,并将渐变放在同样地位置上。在每个.shp,.shx与.dbf文件之中,图形在每个文件的排序是一致的。也就是说,.shp的第一条记录与.shx及.dbf之中的第一条记录相对应,如此类推。此外,在.shp与.shx之中,有许多字段的字节序是不一样的。因此用户在编写读取这些文件格式的程序时,必须十分小心地处理不同文件的不同字节序。`,
x: 0,
y: 200,
// dy: 10,
textBaseline: 'top',
wordWrap: true,
wordWrapWidth: 800,
fill: 'linear-gradient(90deg, red 0.1%, green 100%)',
},
});
canvas.appendChild(text2);
}
1 change: 1 addition & 0 deletions __tests__/demos/bugfix/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { scale0 } from './scale0';
export { dirty } from './dirty';
export { image } from './1636';
export { shadowroot_offset } from './1677';
export { gradient_text } from './1572';
11 changes: 7 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const packages = readdirSync(basePath).filter((name) => {
return lstatSync(path.join(basePath, name)).isDirectory();
});

// Installing third-party modules by tnpm or cnpm will name modules with underscore as prefix.
// In this case _{module} is also necessary.
const esm = ['internmap', 'd3-*', 'lodash-es']
.map((d) => `_${d}|${d}`)
.join('|');

// @see https://blog.ah.technology/a-guide-through-the-wild-wild-west-of-setting-up-a-mono-repo-part-2-adding-jest-with-a-breeze-16e08596f0de
const moduleNameMapper = {
...packages.reduce(
Expand Down Expand Up @@ -60,8 +66,5 @@ module.exports = {
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
modulePathIgnorePatterns: ['dist'],
transformIgnorePatterns: [
// @see https://stackoverflow.com/a/69179139
'/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)',
],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!(?:.pnpm/)?(${esm}))`],
};
12 changes: 7 additions & 5 deletions jest.node.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ const packages = readdirSync(basePath).filter((name) => {
return lstatSync(path.join(basePath, name)).isDirectory();
});

// Installing third-party modules by tnpm or cnpm will name modules with underscore as prefix.
// In this case _{module} is also necessary.
const esm = ['internmap', 'd3-*', 'lodash-es']
.map((d) => `_${d}|${d}`)
.join('|');

// @see https://blog.ah.technology/a-guide-through-the-wild-wild-west-of-setting-up-a-mono-repo-part-2-adding-jest-with-a-breeze-16e08596f0de
const moduleNameMapper = {
...packages.reduce(
Expand Down Expand Up @@ -40,12 +46,8 @@ module.exports = {
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
modulePathIgnorePatterns: ['dist'],
transformIgnorePatterns: [
// @see https://stackoverflow.com/a/69179139
'/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)',
],
globalSetup: './scripts/jest/setup.js',
globalTeardown: './scripts/jest/teardown.js',
testEnvironment: './scripts/jest/environment.js',
testPathIgnorePatterns: ['<rootDir>/__tests__/main.ts'],
transformIgnorePatterns: [`<rootDir>/node_modules/(?!(?:.pnpm/)?(${esm}))`],
};
9 changes: 9 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @antv/g-canvas

## 2.0.6

### Patch Changes

- Updated dependencies [a4d7c7e0]
- Updated dependencies [a4d7c7e0]
- @antv/g-plugin-canvas-renderer@2.0.6
- @antv/g-plugin-canvas-picker@2.0.6

## 2.0.5

### 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": "2.0.5",
"version": "2.0.6",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-canvaskit

## 1.0.6

### Patch Changes

- @antv/g-plugin-canvas-picker@2.0.6

## 1.0.5

### 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": "1.0.5",
"version": "1.0.6",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
9 changes: 9 additions & 0 deletions packages/g-mobile-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @antv/g-mobile-canvas

## 1.0.6

### Patch Changes

- Updated dependencies [a4d7c7e0]
- Updated dependencies [a4d7c7e0]
- @antv/g-plugin-canvas-renderer@2.0.6
- @antv/g-plugin-canvas-picker@2.0.6

## 1.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-canvas",
"version": "1.0.5",
"version": "1.0.6",
"description": "A renderer implemented with Canvas2D API in mobile environment",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-mobile-svg/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-mobile-svg

## 1.0.7

### Patch Changes

- Updated dependencies [a4d7c7e0]
- @antv/g-plugin-svg-renderer@2.0.7
- @antv/g-plugin-svg-picker@2.0.7

## 1.0.6

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-mobile-svg/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-mobile-svg",
"version": "1.0.6",
"version": "1.0.7",
"description": "A renderer implemented by SVG in mobile environment",
"keywords": [
"antv",
Expand Down
8 changes: 8 additions & 0 deletions packages/g-plugin-canvas-picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @antv/g-plugin-canvas-picker

## 2.0.6

### Patch Changes

- Updated dependencies [a4d7c7e0]
- Updated dependencies [a4d7c7e0]
- @antv/g-plugin-canvas-renderer@2.0.6

## 2.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-canvas-picker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-canvas-picker",
"version": "2.0.5",
"version": "2.0.6",
"description": "A G plugin for picking in canvas",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-plugin-canvas-renderer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-plugin-canvas-renderer

## 2.0.6

### Patch Changes

- a4d7c7e0: Support gradient text in canvas & svg renderer.
- a4d7c7e0: Render correctly in canvas when stroke is emtpy.

## 2.0.5

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-plugin-canvas-renderer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-plugin-canvas-renderer",
"version": "2.0.5",
"version": "2.0.6",
"description": "A G plugin of renderer implementation with Canvas2D API",
"keywords": [
"antv",
Expand Down
6 changes: 4 additions & 2 deletions packages/g-plugin-canvas-renderer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Plugin extends AbstractRendererPlugin<{
[Shape.ELLIPSE]: defaultRenderer,
[Shape.RECT]: defaultRenderer,
[Shape.IMAGE]: new ImageRenderer(imagePool),
[Shape.TEXT]: new TextRenderer(),
[Shape.TEXT]: new TextRenderer(imagePool),
[Shape.LINE]: defaultRenderer,
[Shape.POLYLINE]: defaultRenderer,
[Shape.POLYGON]: defaultRenderer,
Expand All @@ -48,7 +48,9 @@ export class Plugin extends AbstractRendererPlugin<{
this.context.defaultStyleRendererFactory = defaultStyleRendererFactory;
this.context.styleRendererFactory = defaultStyleRendererFactory;

this.addRenderingPlugin(new CanvasRendererPlugin(canvasRendererPluginOptions));
this.addRenderingPlugin(
new CanvasRendererPlugin(canvasRendererPluginOptions),
);
}
destroy(): void {
this.removeAllRenderingPlugins();
Expand Down
Loading

0 comments on commit 0d2b174

Please sign in to comment.