| 125 | } |
| 126 | |
| 127 | getRandomOp(): Op { |
| 128 | const op = this.randomAction<Op>( |
| 129 | [ |
| 130 | () => { |
| 131 | const x = this.randomInt(1000) |
| 132 | const y = this.randomInt(1000) |
| 133 | const width = this.randomInt(1, 1000) |
| 134 | const height = this.randomInt(1, 1000) |
| 135 | let parentId: TLShapeId | undefined |
| 136 | if (this.randomInt(2) === 0) { |
| 137 | parentId = this.randomElement<TLShape>( |
| 138 | this.editor.getCurrentPageShapes().filter((s) => s.type === 'frame') |
| 139 | )?.id |
| 140 | } |
| 141 | return { type: 'create-box', x, y, width, height, parentId } |
| 142 | }, |
| 143 | () => { |
| 144 | const x = this.randomInt(1000) |
| 145 | const y = this.randomInt(1000) |
| 146 | const width = this.randomInt(1, 1000) |
| 147 | const height = this.randomInt(1, 1000) |
| 148 | return { type: 'create-frame', x, y, width, height } |
| 149 | }, |
| 150 | // Need to disable arrows for the time being, the cleanup logic leads to state inconsistency. |
| 151 | // We need a better way to handle state updates. |
| 152 | // () => { |
| 153 | // let start: TLArrowTerminal = { |
| 154 | // type: 'point', |
| 155 | // x: this.randomInt(1000), |
| 156 | // y: this.randomInt(1000), |
| 157 | // } |
| 158 | // let end: TLArrowTerminal = { |
| 159 | // type: 'point', |
| 160 | // x: this.randomInt(1000), |
| 161 | // y: this.randomInt(1000), |
| 162 | // } |
| 163 | |
| 164 | // if (this.randomInt(2) === 0) { |
| 165 | // const boundShapeId = this.getRandomShapeId() |
| 166 | // if (boundShapeId) { |
| 167 | // start = { |
| 168 | // type: 'binding', |
| 169 | // boundShapeId: boundShapeId, |
| 170 | // isExact: true, |
| 171 | // normalizedAnchor: { x: 0.5, y: 0.5 }, |
| 172 | // } |
| 173 | // } |
| 174 | // } |
| 175 | |
| 176 | // if (this.randomInt(2) === 0) { |
| 177 | // const boundShapeId = this.getRandomShapeId() |
| 178 | // if (boundShapeId) { |
| 179 | // end = { |
| 180 | // type: 'binding', |
| 181 | // boundShapeId: boundShapeId, |
| 182 | // isExact: true, |
| 183 | // normalizedAnchor: { x: 0.5, y: 0.5 }, |
| 184 | // } |