charPos returns the relative starting position of the given rune, in the overall RenderAll of all the text. These positions can be out of visible range: see CharRenderPos
(idx int)
| 1250 | // in the overall RenderAll of all the text. |
| 1251 | // These positions can be out of visible range: see CharRenderPos |
| 1252 | func (tf *TextField) charPos(idx int) math32.Vector2 { |
| 1253 | if idx <= 0 || len(tf.renderAll.Spans) == 0 { |
| 1254 | return math32.Vector2{} |
| 1255 | } |
| 1256 | pos, _, _, _ := tf.renderAll.RuneRelPos(idx) |
| 1257 | pos.Y -= tf.renderAll.Spans[0].RelPos.Y |
| 1258 | return pos |
| 1259 | } |
| 1260 | |
| 1261 | // relCharPos returns the text width in dots between the two text string |
| 1262 | // positions (ed is exclusive -- +1 beyond actual char). |
no test coverage detected