react-konva矩形属性的随机值?

问题描述

我当前正在尝试在Web应用程序上映射用户组,以便每个用户组都显示为矩形。 目前,我需要它具有随机的x,y坐标和随机的填充/笔触颜色,其中两者将具有相同的颜色但具有不同的alpha值。

我当前的代码如下:

                        {this.state.breakoutGroups.map((breakoutGroup,index) => {
                            return (
                                <>
                                    <Group>
                                        <Rect
                                            name={breakoutGroup.name}
                                            x={this.getRandomInt(500)}
                                            y={this.getRandomInt(500)}
                                            width={300}
                                            height={300}
                                            fill={randomColor + "15"}    
                                            stroke={randomColor + "FF"} 
                                            strokeWidth={2}             
                                            cornerRadius={50}           
                                            dash={[20,10]}             
                                        >
                                        </Rect>
                                    </Group>
                                </>
                            );
                        })}
                    </Layer>

应该注意,“ randomColor”变量定义为render()顶部的Konva随机颜色函数

使用这样的代码,它将不断更改坐标和颜色,我不确定为什么。

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)