diff options
| author | Andrés Cuervo <andrescuervor@gmail.com> | 2023-10-23 22:27:20 +0000 |
|---|---|---|
| committer | Andrés Cuervo <andrescuervor@gmail.com> | 2023-10-23 22:27:20 +0000 |
| commit | d18e890179cd84194c41d9f613a89f1ceba7a2e6 (patch) | |
| tree | b1be46efdfd2c5406399638c6be3cb488fdd1fd2 /virtual-programs | |
| parent | Implement ctrl+a and ctrl+e (diff) | |
| download | folk-d18e890179cd84194c41d9f613a89f1ceba7a2e6.tar.gz folk-d18e890179cd84194c41d9f613a89f1ceba7a2e6.zip | |
Add debugging & multiple shift counts
Diffstat (limited to 'virtual-programs')
| -rw-r--r-- | virtual-programs/editor.folk | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/virtual-programs/editor.folk b/virtual-programs/editor.folk index 0c62f018..f8ead355 100644 --- a/virtual-programs/editor.folk +++ b/virtual-programs/editor.folk @@ -1,7 +1,3 @@ -# TODO: Make this not-hard-coded -# In fact, this shouldn't be "editor-1" at all but -# probably should be the MAC address or some Bluetooth -# thread ID? set id "editor-1" When /page/ is editor /n/ & /page/ has region /r/ { @@ -107,13 +103,6 @@ proc drawText {text cursor count region} { Display::text {*}[region centroid $region] 1 $text [region angle $region] NeomatrixCode } -####################################### -# In order to construct a cursor that's relative to the virtual keyboard you must -# know three things: -# 1. The center of the virtual region -# 2. The angle of the virtual region -# 3. The position of the cursor relative to the virtual region (this is rather involved because it requires calcualting from the center and then taking cursor units from that point) -####################################### proc rotateStroke {points center angle} { lmap v $points { set v [vec2 sub $v $center] @@ -153,44 +142,30 @@ proc drawCursor {cursorPosition lineShift region} { set cursorHeight 20 set cursorWidth 9 - set shiftMultiplier [list 10 10] + set shiftMultiplier [list 12 20] + # set shiftMultiplier [list 14 25] + # set shiftMultiplier [list 14 20] + set cursorScale [list 14 25] ;# OLD - # 20 20 scale is arbitrary, computing it off of Display or something ..... - # TODO: Pull these variables from the Display file - set cursorScale [list 20 20] ;# OLD - # set cursorScale [list $cursorHeight $cursorWidth] - - # Calculate the shift for the anchor point set lineShiftHalf [list [lindex $lineShift 0] 0] set multipliedShift [vec2::mult $shiftMultiplier $lineShift] - # This adjusted shift is seemingly wrong .... - set adjustedShift [sub $multipliedShift $lineShiftHalf] - # set adjustedShift $multipliedShift + # set adjustedShift [sub $multipliedShift $lineShiftHalf] + set adjustedShift $multipliedShift set shiftedAnchor [sub $anchor $adjustedShift] + debug [lindex [rotateStroke [list $shiftedAnchor] $anchor $angle] 0] white # add (x * width) to the shiftedAnchor position from the beginning of the line ... - # Calculate the final cursor position set scaledCursor [vec2::mult $cursorScale $cursorPosition] - # Something is going wrong here, I think set finalCursor [add $shiftedAnchor $scaledCursor] - # debug $finalCursor gold - # Rotate and display the cursor - set rotatedFinalCursor [lindex [rotateStroke [list $finalCursor] $anchor $angle] 0] + set rotatedFenalCursor [lindex [rotateStroke [list $finalCursor] $anchor $angle] 0] + # This is where the cursor point is relative to. - debug $rotatedFinalCursor white # cursor, green Display::stroke [rotateStroke \ [list $finalCursor \ [add $finalCursor [list 0 $cursorHeight]] \ ] \ $anchor $angle] 2 green - - # cursor box - Display::stroke [rotateStroke \ - [list $finalCursor \ - [add $finalCursor [list $cursorWidth 0]] \ - ] \ - $anchor $angle] 2 green } When $id has program code /code/ & the clock time is /t/ & the cursor is /cursor/ & $id has region /r/ { |
