我正在使用Konva(在React中)。
<Rect
x={x}
y={y}
width={width}
height={height}
...
fillPatternImage={this.state.image}
fillPatternRepeat="repeat-x"
/>
fill image正在显示,重复,但它的高度是我的源图像的初始高度。我想用它的形状“适合”它(高度100%/ Y盖)。
在the doc(fillPatternX,fillPatternOffsetX,fillPatternScaleX)上有很多功能,但没有人在寻找我想要的东西。
我能怎么做 ?
您可以使用fillPatternScaleX
和fillPatternScaleY
将图案图像缩放到所需的大小。您可能需要知道模式的原始图像大小才能计算出比例。
fillPatternScaleY={requiredHeight / patternImageHeight}