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

feat: support size attenuation in annotation plugin #1631

Merged
merged 2 commits into from
Feb 23, 2024
Merged

Conversation

xiaoiver
Copy link
Contributor

@xiaoiver xiaoiver commented Feb 23, 2024

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / Document optimization
  • TypeScript definition update
  • Refactoring
  • Performance improvement
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

When using @antv/g-plugin-annotation, we want the size of anchors & lineWidth of selectable UI to keep the fixed size, which means camera's zooming won't affect them.

It's quite similar to sizeAttenuation in Three.js.

Feb-23-2024 13-29-02

💡 Background and solution

Update the following deps:

  • @antv/g@5.18.24
  • @antv/g-plugin-annotation@0.4.21

Enabling enableSizeAttenuation will affect the selectable UI during initialization. Now the anchors, mask will change their lineWidth or r(Circle point) when camera's zooming changed.

import { runtime } from '@antv/g';

// Now canvas will listen to camera's changed event and modify each shape's `lineWidth` or `size` with `isSizeAttenuation` enabled.
runtime.enableSizeAttenuation = true;

When using drawer tool, just enable isSizeAttenuation when creating relative shape.

annotationPlugin.addEventListener('draw:complete', ({ type, path }) => {
  const circle = new Circle({
    style: {
      r: 10,
      isSizeAttenuation: true, // Enable this option when created.
    }
  });
});

There're some limitations for now:

  • When isSizeAttenuation enabled, lineWidth and r(for Circle) can't not be updated manually:
const circle = new Circle({
  style: {
    r: 10,
    isSizeAttenuation: true, // Enable this option when created.
  }
});
circle.style.r = 20; // whoops...

📝 Changelog

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self Check before Merge

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

@xiaoiver xiaoiver merged commit 11d23f3 into release Feb 23, 2024
2 of 3 checks passed
@xiaoiver xiaoiver deleted the feat-fixsize branch February 23, 2024 05:34
xiaoiver added a commit that referenced this pull request Feb 23, 2024
* feat: support size attenuation in annotation plugin (#1631)

* feat: support size attenuation in annotation plugin

* chore: commit changeset

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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant