Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about the type of attribute-background that in interface CanvasConfig #1331

Open
1 task
notthistrain opened this issue Apr 15, 2023 · 4 comments
Open
1 task
Assignees
Labels

Comments

@notthistrain
Copy link

  • I have searched the issues of this repository and believe that this is not a duplicate.

What problem does this feature solve?

Passing Parameters: we can pass CanvasPattern, and typescript do not report syntax error

What does the proposed API look like?

finally this attribute is used for set fillStyle, so I think it can add a CanvasPattern type to background, like this, and it is worked I tried

@xiaoiver xiaoiver self-assigned this Jun 16, 2023
@xiaoiver
Copy link
Contributor

For now we have already support Pattern:
https://g.antv.antgroup.com/en/api/css/pattern

interface Pattern {
  image: string | CanvasImageSource | Rect;
  repetition?: 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
  transform?: string;
}

So maybe we can pass in a description of pattern:

new Canvas({
  background: {
    image: 'http://example.png',
    repetition: 'repeat',
    transform: 'rotate(30deg)',
  }
});

@notthistrain
Copy link
Author

notthistrain commented Jun 16, 2023

https://github.com/antvis/G/blob/next/packages/g-lite/src/types.ts#L482

new Canvas({
  background: {
    image: 'http://example.png',
    repetition: 'repeat',
    transform: 'rotate(30deg)',
  }
});

thanks for your answer, but i think it can not pass the typecheck

@xiaoiver
Copy link
Contributor

https://github.com/antvis/G/blob/next/packages/g-lite/src/types.ts#L482

new Canvas({
  background: {
    image: 'http://example.png',
    repetition: 'repeat',
    transform: 'rotate(30deg)',
  }
});

thanks for your answer, but i think it can not pass the typecheck

Yes, since I haven't implemented it yet. For now background only supports string.

@notthistrain
Copy link
Author

thats ok,栓q

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants