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: hull plugin (convex hull, concave hull) #5626

Merged
merged 12 commits into from
Apr 11, 2024
Merged

feat: hull plugin (convex hull, concave hull) #5626

merged 12 commits into from
Apr 11, 2024

Conversation

yvonneyx
Copy link
Contributor

@yvonneyx yvonneyx commented Apr 7, 2024

此 PR 重新实现了插件 Hull (convex/concave hull)

Hull 功能点:

  1. Hull 基于 G 开发,并适配 PathStyleProps,样式设置更加灵活。此外,新增了三种拐角类型:rounded(圆角)、smooth(平滑)和 sharp(尖锐)
image image image
  1. 提供 API 动态修改数据与样式
const hull = graph.getPluginInstance<Hull>('hull');
hull.addMembers(['node1']);
hull.removeMembers(['node1'])
hull.updateMembers(preMembers => ...)
  1. 可设置凹度,从而在凸包(Convex Hull)与凹包之间进行选择,其中默认值为 Infinity,代表为凸包。
image image
interface HullOptions extends BasePluginOptions, HullStyleProps {
  /**
   * <zh/> Hull 内的元素
   * <en/> Elements in Hull
   */
  members?: ID[];
  /**
   * <zh/> 凹度,数值越大凹度越小;默认为 Infinity 代表为 Convex Hull
   * <en/> Concavity. Default is Infinity, which means Convex Hull
   */
  concavity?: number;
  /**
   * <zh/> 内边距,默认为 10
   * <en/> Padding, default is 10
   */
  padding?: number;
  /**
   * <zh/> 拐角类型,目前支持 'rounded'、'smooth' 和 'sharp'
   * <en/> Corner type, currently supports 'rounded', 'smooth' and 'sharp'
   */
  corner?: 'rounded' | 'smooth' | 'sharp';
}

type HullStyleProps = PathStyleProps & {
  label?: boolean;
} & PrefixObject<HullLabelStyleProps, 'label'>;

type HullLabelStyleProps = LabelStyleProps & {
  /**
   * <zh/> 标签位置,可选值为 'top'、'right'、'bottom'、'left'、'center';默认为 'bottom'
   * <en/> Label position, optional values are 'top', 'right', 'bottom', 'left', 'center'; default is 'bottom'
   */
  placement?: CardinalPlacement | 'center';
  /**
   * <zh/> 标签是否贴合轮廓,默认为 true
   * <en/> Whether the label is close to the contour, default is true
   */
  closeToHull?: boolean;
  /**
   * <zh/> 标签是否跟随轮廓旋转,默认为 true,仅在 closeToHull 为 true 时生效
   * <en/> Whether the label rotates with the contour, default is true. Only effective when closeToHull is true
   */
  autoRotate?: boolean;
  /**
   * <zh/> x 轴偏移量
   * <en/> Label x-axis offset
   */
  offsetX?: number;
  /**
   * <zh/> y 轴偏移量
   * <en/> Label y-axis offset
   */
  offsetY?: number;
  /**
   * <zh/> 文本的最大宽度,超出会自动省略
   * <en/> The maximum width of the text, which will be automatically ellipsis if exceeded
   */
  maxWidth?: number;
};

@yvonneyx yvonneyx changed the title feat: hull plugin WIP: feat: hull plugin Apr 7, 2024
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这块部分内容可以直接引 bubblesets 吗,比如 MarchingSquares LineStructure 这些

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后面会单独开发一个 Bubbleset 插件~

@yvonneyx yvonneyx changed the title WIP: feat: hull plugin feat: hull plugin (convex hull, concave hull) Apr 9, 2024
@yvonneyx yvonneyx requested a review from Aarebecca April 10, 2024 02:13
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Apr 11, 2024
@hustcc hustcc merged commit 09a62ab into v5 Apr 11, 2024
5 checks passed
@hustcc hustcc deleted the feat/hull branch April 11, 2024 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm This PR has been approved by a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Hull Plugin
3 participants