如何设置我的Konva fillPatternImage 100%高度

问题描述 投票:1回答:1

我正在使用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)上有很多功能,但没有人在寻找我想要的东西。

我能怎么做 ?

reactjs canvas konvajs
1个回答
1
投票

您可以使用fillPatternScaleXfillPatternScaleY将图案图像缩放到所需的大小。您可能需要知道模式的原始图像大小才能计算出比例。

fillPatternScaleY={requiredHeight / patternImageHeight}

© www.soinside.com 2019 - 2024. All rights reserved.