Skip to content

Commit

Permalink
fix: paint visible no work
Browse files Browse the repository at this point in the history
  • Loading branch information
F-star committed Nov 30, 2024
1 parent 6356a61 commit c872003
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/core/src/graphics/ellipse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export class SuikaEllipse extends SuikaGraphics<EllipseAttrs> {
DOUBLE_PI,
);
for (const paint of attrs.fill ?? []) {
if (paint.visible === false) continue;
if (paint.type === PaintType.Solid) {
layerCtx.fillStyle = parseRGBAStr(paint.attrs);
layerCtx.fill();
Expand All @@ -90,6 +91,7 @@ export class SuikaEllipse extends SuikaGraphics<EllipseAttrs> {
if (attrs.strokeWidth) {
layerCtx.lineWidth = attrs.strokeWidth;
for (const paint of attrs.stroke ?? []) {
if (paint.visible === false) continue;
if (paint.type === PaintType.Solid) {
layerCtx.strokeStyle = parseRGBAStr(paint.attrs);
layerCtx.stroke();
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/graphics/frame/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ export class SuikaFrame extends SuikaGraphics<FrameAttrs> {
return this.children.length === 0;
}

protected override isFillShouldRender() {
// TODO: optimize
return true;
}

private _realDraw(
drawInfo: IDrawInfo,
overrideStyle?: {
Expand Down Expand Up @@ -144,6 +149,7 @@ export class SuikaFrame extends SuikaGraphics<FrameAttrs> {
// ctx.restore();

for (const paint of fill ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
ctx.fillStyle = parseRGBAStr(paint.attrs);
Expand All @@ -162,6 +168,7 @@ export class SuikaFrame extends SuikaGraphics<FrameAttrs> {
if (strokeWidth) {
ctx.lineWidth = strokeWidth;
for (const paint of stroke ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
ctx.strokeStyle = parseRGBAStr(paint.attrs);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/graphics/path/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ export class SuikaPath extends SuikaGraphics<PathAttrs> {
}

for (const paint of fill ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.fillStyle = parseRGBAStr(paint.attrs);
Expand All @@ -283,6 +284,7 @@ export class SuikaPath extends SuikaGraphics<PathAttrs> {
if (strokeWidth) {
layerCtx.lineWidth = strokeWidth;
for (const paint of stroke ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.strokeStyle = parseRGBAStr(paint.attrs);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/graphics/regular_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export class SuikaRegularPolygon extends SuikaGraphics<RegularPolygonAttrs> {
layerCtx.closePath();

for (const paint of fill ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.fillStyle = parseRGBAStr(paint.attrs);
Expand All @@ -141,6 +142,7 @@ export class SuikaRegularPolygon extends SuikaGraphics<RegularPolygonAttrs> {
if (strokeWidth) {
layerCtx.lineWidth = strokeWidth;
for (const paint of stroke ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.strokeStyle = parseRGBAStr(paint.attrs);
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/graphics/star.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export class SuikaStar extends SuikaGraphics<StarAttrs> {
layerCtx.closePath();

for (const paint of fill ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.fillStyle = parseRGBAStr(paint.attrs);
Expand All @@ -139,6 +140,7 @@ export class SuikaStar extends SuikaGraphics<StarAttrs> {
if (strokeWidth) {
layerCtx.lineWidth = strokeWidth;
for (const paint of stroke ?? []) {
if (paint.visible === false) continue;
switch (paint.type) {
case PaintType.Solid: {
layerCtx.strokeStyle = parseRGBAStr(paint.attrs);
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/graphics/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class SuikaText extends SuikaGraphics<TextAttrs> {
}

protected override isFillShouldRender() {
// TODO: optimize
return true;
}

Expand Down

0 comments on commit c872003

Please sign in to comment.