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

[Bug Report]: 拖拽出的图片尺寸不对 #2061

Open
aaronchen2k opened this issue Feb 10, 2025 · 3 comments
Open

[Bug Report]: 拖拽出的图片尺寸不对 #2061

aaronchen2k opened this issue Feb 10, 2025 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@aaronchen2k
Copy link

aaronchen2k commented Feb 10, 2025

发生了什么?

使用以下代码新拖出来的菱形,尺寸没有按照预设置的properties值渲染?

Image Image Image

logicflow/core版本

2.0.10

logicflow/extension版本

none

logicflow/engine版本

No response

浏览器&环境

No response

@aaronchen2k aaronchen2k added the bug Something isn't working label Feb 10, 2025
@ChangeSuger ChangeSuger removed the bug Something isn't working label Feb 10, 2025
@ChangeSuger
Copy link
Collaborator

这个需要配合 NodeModel 的 setAttributes 方法使用,看代码截图是用的自定义节点,可能是继承的节点原先没有相关的设置,这种情况下需要重写 setAttributes 方法,具体可以参考 PolygonNode 的实现:

setAttributes() {
super.setAttributes()
const { points, width, height } = this.properties
// DONE: 如果设置了 points,又设置了节点的宽高,则需要做如下操作
// 1. 将 points 的位置置零,即将图形向原点移动(找到 points 中 x,y 的最小值,所有坐标值减掉该值)
// 2. 按宽高的比例重新计算最新的 points
// if (points) {
// this.points = points
// }
const nextPoints = points || this.points
this.points = normalizePolygon(nextPoints, width, height)
}

@ChangeSuger ChangeSuger added the documentation Improvements or additions to documentation label Feb 10, 2025
@aaronchen2k
Copy link
Author

aaronchen2k commented Feb 10, 2025

@ChangeSuger 没明白什么意思。我使用的是內置的diamond的类型。

@ChangeSuger
Copy link
Collaborator

ChangeSuger commented Feb 10, 2025

@ChangeSuger 没明白什么意思。我使用的是內置的diamond的类型。

关于 setAttributes 方法,简单来说就是这个方法决定节点怎么利用 properties 中的属性,因此,要让 properties 中的属性能正常生效,需要了解该方法的实现(查文档或者看源码)。

DiamondNodeModel 为例:

setAttributes() {
super.setAttributes()
const { rx, ry } = this.properties
if (rx) {
this.rx = rx
}
if (ry) {
this.ry = ry
}
}

因此,如果是直接使用内置的 Diamond 节点的话,需要把 widthheight 改为 rxry,并注意下两者之间的对应关系。

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

No branches or pull requests

2 participants