Skip to content

Commit

Permalink
fix: support size array in CustomSymbolClass
Browse files Browse the repository at this point in the history
  • Loading branch information
neuqzxy committed Nov 20, 2024
1 parent f39776a commit e56384d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/vrender-core/src/graphic/builtin-symbol/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isArray, type IBounds, AABBBounds } from '@visactor/vutils';
import { isArray, type IBounds, AABBBounds, isNumber } from '@visactor/vutils';
import { renderCommandList } from '../../common/render-command-list';
import type { IContext2d, ICustomPath2D, IGraphicAttribute, ISymbolClass } from '../../interface';

Expand Down Expand Up @@ -33,6 +33,7 @@ export class CustomSymbolClass implements ISymbolClass {
z?: number,
cb?: (path: ICustomPath2D, attribute?: Record<string, any>) => void
) {
size = this.parseSize(size);
if (this.isSvg) {
if (!this.svgCache) {
return false;
Expand All @@ -56,10 +57,16 @@ export class CustomSymbolClass implements ISymbolClass {
z?: number,
cb?: (path: ICustomPath2D, attribute?: Record<string, any>) => void
) {
size = this.parseSize(size);
return this.drawOffset(ctx, size, x, y, 0, z, cb);
}

protected parseSize(size: number | [number, number]): number {
return isNumber(size) ? size : Math.min(size[0], size[1]);
}

bounds(size: number, bounds: IBounds) {
size = this.parseSize(size);
if (this.isSvg) {
if (!this.svgCache) {
return;
Expand Down

0 comments on commit e56384d

Please sign in to comment.