Skip to content

Instantly share code, notes, and snippets.

@ne1uno
Last active March 6, 2023 21:10
Show Gist options
  • Save ne1uno/d47124f9108b8c74d8415b3e62b2bfd9 to your computer and use it in GitHub Desktop.
Save ne1uno/d47124f9108b8c74d8415b3e62b2bfd9 to your computer and use it in GitHub Desktop.
chatGPT assisted mock eye chart experiment in AI pair programming in red language
s2334p3 chatGPT assisted mock eye chart
with riddles on progressively smaller font lines
an experiment in AI pair programming in red language it has limited training with.
it slips into rebol, python or javascript. inventing syntax and functions
it can mimic a REPL to show source of functions, which it also invents.
this is a crazy way to work
may or may not post the entire q&a, would need too much annotation
here's a screenshot...
http://...RSN
big thanks to openAI, all the beta testers, microsoft, google and others
the way chatGPT is able to derive intent, attempting to supply code is amazing
I could have easily spent three times as long scraping the web copying & pasting
https://www.red-lang.org/p/download.html
needed mezzinene functions zip, apply and fold, it did ok adding functionality.
I ended up modifying existing versions and finding tests the old fashion way.
the tests still need some tlc, all the script really needed was a three series zip
I wanted a more capable zip for my utils lib anyway.
started out with research type questions about eye charts and eye glass strength
then exploring creating a standard chart in svg base64 png that almost works.
ME
do it in red lang view
a red view mock eye chart with some amusing riddles for each smaller font size
decreasing number of words in each riddle. understand?
[respectable code template]
ME
unbelievable,
** Script Error: VID - invalid syntax at: [color 255.0.0 below]
[respectable code revision with apology]
wacky use of scroller.
can't keep c&p versions.
ME
need to use compose and make decreasing text font sizes
[respectable code iterations ]
move to a file, too many revs, would be annoying in vscode copilot
can't always get it to focus on one part. mixes in rebol view code
hard to piece this together easily. so close to being useful
my testing2018 utils zip isn't dynamic, why did I only expect two series?
chatGPT came up with a more dynamic one but needs apply & arity
got it to create a mezz and some asserts. then use my testing format
of course full of inaccuracies and errors. but also very close to usable syntax
Red [
Title: " mock eye chart "
Author: "ne1 with chatGPT assist" ; USER <>
Date: "2032-3-4"
File: cgpt-eyechart.red
;icon: %test.png ;for compile, no error if missing interpreted
rights: "you decide" ;riddles?
Needs: 'View ;can't have view cli
]
do %../R3/testing2018.r ;stacks not builtin, this works R3/Red not much tested R2
; tests, assert, map-each,
;what are the odds this zip & mezz works?
;need to start a fresh chat, starts to get forgetful with every revision
; the zip I have can also apply a function but wasn't dynamic
;I found some working arity should probably be in testing, need apply too probably
; ME
; what is the hof definition of apply, fold and zip
; A higher-order function (HOF) is a function that takes another
; function as an argument, or returns a function as a result.
; apply takes a function and a block of arguments,
; and applies the function to the arguments in the block.
; fold takes a binary function and a block of
; elements, and accumulates the results of the binary function over
; each element in the block.
; zip takes one or more series (blocks or strings) of
; equal length, and returns a block of blocks where each block
; contains the corresponding elements from each series.
; ME
; I'm going to need a red mezz with apply, arity-of arity? and anything else used.
; so I can stay compatible
; Here is a Red mezzanine implementation of apply, arity-of, and arity?:
;by chatGPT, problematic
; arity-of: func [
; "Returns the arity of a function."
; func [function!] "Function to get arity of."
; ][
; parse mold :func [
; any ['some [
; 'word! | 'set-word! | 'refinement! | 'issue! | 'char! | 'paren! | 'block! | 'lit-word! | 'lit-path! | 'lit-block! | 'get-word! | 'get-path! | 'get-block! | 'set | 'unset | 'dot | 'parens | 'path
; ]]
; ]
; length? pick first parse mold :func [
; some ['word! | 'set-word! | 'refinement! | 'issue! | 'char! | 'paren! | 'block! | 'lit-word! | 'lit-path! | 'lit-block! | 'get-word! | 'get-path! | 'get-block! | 'set | 'unset | 'dot | 'parens | 'path
; ]
; ]
; ]
;by chatGPT, problematic
; apply: func [
; "Apply a function with a list of arguments."
; func [function!] "Function to apply."
; args [block!] "Arguments to apply."
; /local arity
; ][
; arity: arity-of :func
; if length? args <> arity [
; if arity = 1 [args: reduce [args]]
; if length? args < arity [
; repeat i arity - length? args [
; append args none
; ]
; ]
; ]
; do compose [(reduce [to-path :func] args)]
; ]
;doesn't need arity. maybe I'm thinking of map-each, needs to apply to each cumulative
; that's why arity in chatGPT version, maybe need foldl
; functional.rd \gist\greggirwin\greggs-mezz.red
;# Higher-Order Functions (HOFs)
; Should args come first? That's the normal series-first model, but
; also backwards from normal func call order, which may be confusing.
apply: func [
"Apply a function to a block of arguments."
fn [any-function!] "Function to apply"
args [block!] "Arguments for function"
/only "Use arg values as-is, do not reduce the block"
][
; Renaud Gombert's simple approach. There is a reason Brian Hawley's
; R2 version is so complex. The question is whether the complexity
; is justified. It may very well be, but this is soooo Redbolish.
args: either only [copy args][reduce args]
do head insert args :fn
]
;is this gist @doc? how did I not attribute?
;
; We have other reflective functions (words-of, body-of, etc.), but
; this is a little higher level, sounded fun to do, and may prove
; useful as we write more Red tools. It also shows how to make your
; own typesets and use them when parsing.
arity-of: function [
"Returns the fixed-part arity of a function spec"
spec [any-function! block!]
/with refs [refinement! block!] "Count one or more refinements, and add their arity"
][
if any-function? :spec [spec: spec-of :spec] ; extract func specs to block
t-w: make typeset! [word! get-word! lit-word!] ; typeset for words to count
t-x: make typeset! [refinement! set-word!] ; typeset for breakpoint, set-word is for return:
n: 0
; Match our word typeset until we hit a breakpoint that indicates
; the end of the fixed arity part of the spec. 'Skip ignores the
; type and doc string parts of the spec.
parse spec rule: [any [t-w (n: n + 1) | t-x break | skip]]
; Do the same thing for each refinement they want to count the
; args for. First match thru the refinement, then start counting.
if with [foreach ref compose [(refs)] [parse spec [thru ref rule]]]
n
]
;how does /with affect anything since then n returned anyway?
;by chatGPT
arity?: :arity-of
;by chatGPT, problematic. different than apply, called by zip ;there is no reduce/only
; fold: func [
; {Applies a function to the accumulated result and each item of a block}
; values [block!]
; initial [any-type!]
; func [any-function!]
; /only "No reduction of the block"
; ][
; reduce [
; reduce/only reduce [initial first values]
; either only [
; values
; ] [
; tail values
; ]
; :func
; ] do reduce [
; [keep first values] [
; tail values
; ] :func
; ]
; ]
; from @HostileFork mod to return cumulative...
; foldl: func ["reduces the list using the binary operator, from left to right"
; f "arity 2 or if arity 1 then what"
; y "initial value?"
; xs
; /local x
; ][
; foreach x xs [f y x]
; ]
;out of my depth here. aoc-utils has another fold
;sums DSL "Euler1 dialecting example": "Torbjørn Marø" 19-Dec-2011
;
;mod ne1 for zip, add /r default /l, needs to work like apply or on multiple series?
; need to look at more advanced HOF efforts, not a big fan of functional programming
fold: function [{Generic high-order function that folds elements of a list left to right.
Example: fold func [acc x][acc * x] [1 2 3 4] evaluates to 24
}
f [any-function!] "The folding function arity 2 for now" ;was function! errored on :add
l [series!] "The elements to fold" ;was block!
;/r "foldr"
/local acc
][
acc: first l ; Start with first element, loop over rest
foreach x next l [acc: f acc x]
]
;by chatGPT, problematic, dangling keep
; interlace: func [series] [keep remove/only series 1]
; zip-fn: func [series /local result][
; result: copy []
; loop while [all [(not empty? series) (not empty? head series)]] [
; append result reduce apply :interlace series
; ]
; result
; ]
; This implementation of apply takes a function and a block of arguments and applies the function to the arguments. If the number of arguments is less than the arity of the function, it pads the arguments list with none values. If the arity of the function is 1 and the arguments list has more than 1 element, it wraps the arguments in a block. arity-of and arity? are implemented using the same method as the built-in arity? function.
; In this version of zip-fn, apply is used to pass each series to interlace as a separate argument instead of using reduce. This allows interlace to take any number of series as arguments.
; Here's an example of how to use zip-fn with three input series of different lengths:
; alternate dynamic zip doesn't use interlace or apply
; zip: func [
; {Takes one or more series and interlaces them into a new series, where each element is a block of the corresponding element from each input series.}
; data [block! word!] "One or more series to interlace"
; ][
; result: copy []
; loop length? first data [
; row: copy []
; foreach series data [
; append row series/1
; series: next series
; ]
; append result row
; ]
; result
; ]
; ME
; instead of first, should determine shortest length
; You're right. Instead of using first to get the first element of the first series,
; we should determine the length of the shortest series and use that as the limit for loop.
; Here's an updated version of the zip function with this modification:
; I would probably not thought to find shortest length like this,
; also return series if length less than 2.
; series: ["0123" "45" "6789"] first sort collect [foreach s series [keep length? s]]
;== 2
;was using loop instead of repeat i or i: 0, bit scatological
; still Script Error: length? does not allow word! for its series argument
;apply needs work, using fold for zip/with makes more sense but needs to be optional
; sometime fold sometimes apply or something else
;fn arity 1 may need to case but ok for now, isn't setup to return modified args
; cgpt wanted /refinements for /apply, /fold /map-whatever we settled on /use-fn
;/strict needs to decide ahead if suitable vrs inline tests, but it may not be critical
; likely timing zips have been done over the years, this may not be idomatic or optimal
zip: func [{Zip together one or more series, returning a block of blocks}
series [block!]
/use-fn fn "function to use instead of fold ex: :apply or maybe a modifying binary RSN"
/with f "fold function between elements of series by default or ex: /use-fn :apply"
; /strict "throw error on unequal length or wrong arity for fn"
/local result shortest i tmp ;s ;thought foreach also needs local
][
if 2 > length? series [return series] ;might still check /with or /use-fn and perform
fn: any [use-fn fn: :fold]
result: copy []
; probe series
shortest: first sort collect [foreach s series [keep length? s]]
repeat i shortest [
tmp: reduce collect [foreach s series [ keep pick s i]]
;cgpt wanted this here vrs checking equal length and arity sanity above
; if strict [
; if not all [all? collect [foreach s series [keep arity? :f]] length? s = i] [
; fail "Mismatch in length or arity of series elements"
; ]
; ]
append result either with [ ;/only
;apply :f tmp
fn :f tmp ;fn arity 1 may need to case
][
tmp
]
]
result ;might rejoin if was strings now chars
]
; ME
; there will be a calibration later to determine the font size range,
; the function should take big small rows params and return a geometric partition
; from big to small for number of rows
; Here's an example implementation of the function that partitions the font sizes geometrically based on the number of rows and the desired big and small font sizes:
; The function starts with the big font size and repeatedly multiplies it by a factor of 2^(1/rows) to get the smaller font sizes for each row, until it reaches the small font size. Finally, it reverses the list of font sizes and returns it.
;fail [34 27 22 18 14 11 10] <> : [10 62 56 51 46 42 38 34] Test 6 p-f-s #_7
; partition-font-sizes 34 10 7
; expected: [34 27 22 18 14 11 9 10] returns wrong result
; This means the geometric partition starts with a font size of 34 and drops down to 10 with 7 rows in between, where each row is progressively smaller than the previous by a constant factor (in this case, 2 ** (1/7)).
; ME
; that's a good theory. what went wrong?
; The step value is calculated based on the number of rows, but then the size is calculated based on the previous size multiplied by the step. This means that the final size will not necessarily match the small parameter that was passed in, since it is calculated based on the previous size and the step value.
; To fix this, you could calculate the step value based on the desired ratio between the big and small font sizes, rather than the number of rows. For example, if you want the smallest font size to be 10% of the largest font size, you could use a step value of (small / big) ** (1 / (rows - 1)). This should give you a more consistent partition of font sizes, regardless of the number of rows.
; ME
; ratio decreases geometrically
; That's correct. In a geometric series, the ratio between consecutive terms is constant. So, if you start with a term a and the ratio between consecutive terms is r, then the next term in the series will be a*r, the one after that will be a*r*r, and so on. The general term of a geometric series can be written as a*r^(n-1), where n is the position of the term in the series.
; ME
; you's saying correct but explaining the opposit
; I apologize for the confusion. You are correct that the ratio decreases geometrically. In other words, each step is a fixed ratio (such as half or one-third) of the previous step. This means that as the steps progress, the difference between them gets smaller and smaller, resulting in a geometric progression.
; ME
; i should be involved decreasing step size
; Yes, decreasing the step size will result in the font sizes decreasing more slowly as they approach the smaller end. One way to do this is to divide the big font size by the square root of the number of rows, and then multiply by the square root of the current row number.
; For example, if we have 7 rows and a big font size of 34, we would calculate the font size for each row as:
; Row 1: round(34 / sqrt(7)) = 13
; Row 2: round(34 / sqrt(7) * sqrt(2)) = 18
; Row 3: round(34 / sqrt(7) * sqrt(3)) = 22
; Row 4: round(34 / sqrt(7) * sqrt(4)) = 25
; Row 5: round(34 / sqrt(7) * sqrt(5)) = 28
; Row 6: round(34 / sqrt(7) * sqrt(6)) = 31
; Row 7: round(34 / sqrt(7) * sqrt(7)) = 34
; This will result in a slower decrease in font size as the rows get smaller, giving a more gradual change in size.
; we are both screwing this one up. cgpt seems totally out of it
; asking to see the function it just output, tellimg me wrong expected results
; partition-font-sizes: function [
; big [integer!]
; small [integer!]
; rows [integer!]
; ][
; ;step: 2 ** (1 / rows)
; size: big
; sizes: copy []
; repeat i rows [
; ;step: 2 ** (i / rows)
; step: round (size / sqrt(i) * sqrt(i))
; append sizes size
; size: round/to size * step 1
; ]
; ;reverse append sizes small
; append sizes small
; ]
; probe partition-font-sizes 34 10 7
; [34 1156 794172 -2147483648 1.630477228179456e18 7.950637853973799e35 1.6488855284334411e71 10]
; ME
; halt
; blank
; regenerate blank
; reboot
; Welcome back! How may I assist you today?
; partition-font-sizes: function [{
; geometric partition starts with a size of big and drops down to small
; in rows number of steps
; }
; big [integer!]
; small [integer!]
; rows [integer!]
; ][
; ;step: to-integer power 2 (1 / rows)
; size: big
; sizes: copy []
; repeat i rows - 1 [
; step: to-integer power 2 (i / rows)
; append sizes size
; ;size: size // step
; size: size - (size * step)
; ]
; ;reverse ;why does it keep wanting small first?
; append sizes small
; ;sizes
; ]
; probe partition-font-sizes 34 10 7
; ; [10 0 0 0 0 0 34]
; The step value should be the geometric mean of big and small, to ensure a gradual decrease in font sizes. Here's a corrected version of the function:
; log 10 or log e?
; The log function in Rebol/Red uses the natural logarithm (log base e).
; If you want to use log base 10, you can use the log10 function instead.
; Math Error: attempt to divide by zero
;went catatonic again
; soutce
; log: func [
; "Returns the natural logarithm (base e) of a number."
; value "The number to take the logarithm of."
; ][
; to-decimal math/log to-decimal value
; ]
;did log-b log-eb, log-e log-10 log-2 native!
; >> ? log
; log-10 native! Returns the base-10 logarithm.
; log-2 native! Return the base-2 logarithm.
; log-e native! Returns the natural (base-E) logarithm of the given value.
; partition-font-sizes: function [
; big [integer!]
; small [integer!]
; rows [integer!]
; ][
; ;step: probe to-integer power ((log-e big + log-e small) / rows) 2
; size: big
; sizes: copy []
; repeat i rows - 1 [
; append sizes size
; ;step: probe to-integer power ((log-e big + log-e small) / i) 2
; step: probe to-integer power ((log-e size + log-e small) / i) 2
; ;size: size // step
; size: size - step
; ;size: size - (size // step)
; ]
; ;reverse append sizes small
; append sizes small
; ]
; ; probe partition-font-sizes 34 10 7
; ; Math Error: attempt to divide by zero
; ; [10 18 18 18 19 22 34] after changing a few things, still wrong
; [34 22 20 19 19 19 10]
; probe partition-font-sizes 34 7 10
; ME, need new chat
; you are a reducer, a red-lang console. I am mocking up a classic eye chart
; starting with a large font, decreasing geometrically in rows numberv of steps.
; there will be a calibration later to determine the font size range,
; the function should take big small rows params and return a geometric partition
; from big to small for number of rows. eg: probe partition-font-sizes 34 7 10
; willl return somethhing like [34 22 20 19 19 19 10]
; write a few tests like
; report-form "Test 1 p-f-s" [34 27 22 18 14 11 10] partition-font-sizes 34 10 7
; As a Red-lang console, I can help you write the function to generate
; the geometric partition of font sizes for your eye chart.
; Here is the code for the partition-font-sizes function:
; [code]
; function more rebol than red and wrong
;prompt wasn't specific enough to get the test format right
; The partition-font-sizes function takes three parameters: big is the font size for the first row, small is the font size for the last row, and rows is the total number of rows. The function first calculates the geometric step size based on the big, small, and rows parameters. It then creates a block of size rows and sets the first element to big. Finally, it iterates over the remaining elements of the block and calculates the geometrically decreasing font sizes using the step size.
; To test the partition-font-sizes function, you can write a few test cases. Here are some examples:
; ; Test 1: Big font size, small font size, and more rows
; probe partition-font-sizes 34 7 10
; ; Output: [34.0 25.0 18.5 13.7 10.1 7.4 5.4 4.0 2.9 2.1]
; ; Test 2: Same big and small font size, and fewer rows
; probe partition-font-sizes 20 20 3
; ; Output: [20.0 20.0 20.0]
; ; Test 3: Big font size, small font size, and fewer rows
; probe partition-font-sizes 50 10 5
; ; Output: [50.0 25.0 12.5 6.2 3.1]
; ; Test 4: Big font size, small font size, and many rows
; probe partition-font-sizes 40 5 20
; ; Output: [40.0 33.2 27.6 22.9 19.0 15.8 13.1 10.9 9.1 7.6 6.3 5.2 4.3 3.6 3.0 2.5 2.1 1.7 1.4 1.2]
; You can also write a report using the report-form function to summarize the test results. Here is an example:
; report-form "Tests for partition-font-sizes function" [
; "Test 1: Big font size, small font size, and more rows" [
; 34 25 18.5 13.7 10.1 7.4 5.4 4.0 2.9 2.1
; ] partition-font-sizes 34 7 10
; "Test 2: Same big and small font size, and fewer rows" [
; 20 20 20
; ] partition-font-sizes 20 20 3
; "Test 3: Big font size, small font size, and fewer rows" [
; 50 25 12.5 6.2 3.1
; ] partition-font-sizes 50 10 5
; "Test 4: Big font size, small font size, and many rows"
; partition-font-sizes: function [big small rows] [
; step-size: exp (log-e small / log-e big / (rows - 1))
; ; sizes: make block! rows
; ; sizes/1: big
; sizes: append copy [] big
; ;for i 2 rows 1 [
; foreach i range/step 2 rows 1 [
; ;sizes/i: round/to big * (step-size ** (i - 1)) 0.1
; append sizes to-integer round/to big * (step-size ** (i - 1)) 0.1
; ]
; sizes
; ]
; probe partition-font-sizes 34 7 10
; [34 179 943 4966 26157 137759 725522 3821020 20123707 105983105]
; partition-font-sizes: function [big small rows] [
; step-size: exp (log-e small / log-e big / (rows - 1))
; sizes: make block! rows
; sizes/1: big
; foreach i range/step 2 rows 1 [
; sizes/:i: round/to big * (step-size ** (i - 1)) 0.1
; ]
; sizes
; ]
; probe partition-font-sizes 34 7 10
; you re-broke it. red needs something like array to initialize a list.
; what I pasted was syntactically correct. the math was wrong
; I apologize for the confusion. You're correct that append copy [] big is a valid way to initialize the sizes block with the first element big.
; Regarding the calculation of the geometric step size, I misunderstood your original code and didn't catch the mistake in the math. You're correct that log small should be log-e small.
; Here's the corrected code:
; partition-font-sizes: function [big small rows] [
; step-size: exp (log-e small - log-e big) / (rows - 1)
; sizes: append copy [] big
; foreach i range/step 2 rows 1 [
; append sizes to-integer round/to big * (step-size ** (i - 1)) 0.1
; ]
; sizes
; ]
; The step-size calculation now uses log-e small instead of log small, and the division is now outside the exponential. The sizes block is initialized using append copy [] big, and the foreach loop uses append to add the geometrically decreasing font sizes to the block.
; I apologize for any confusion I may have caused earlier. Please let me know if you have any further questions or concerns.
; probe partition-font-sizes 34 7 10
; [34 39 44 51 59 67 78 89 102 118] which is wrong, but potentially fixable as it increases instead of decreases
; I see. It seems like the font sizes are increasing instead of decreasing as expected. This is because the calculation for step-size is incorrect.
; To fix this, you can change the sign of the exponent in the step-size calculation. This will cause the font sizes to decrease geometrically instead of increase. Here's the corrected code:
; partition-font-sizes: function [big small rows] [
; step-size: exp (log-e small - log-e big) / (1 - rows)
; sizes: make block! rows
; sizes/1: big
; foreach i range 2 rows 1 [
; sizes/:i: round/to big * (step-size ** (i - 1)) 0.1
; ]
; sizes
; ]
; I've changed the range to range 2 rows 1 to simplify the loop, since we're starting at the second element. I also used make block! rows instead of append copy [] big to initialize the sizes block, since the make function is more efficient for creating blocks of a specific size.
; With these changes, the step-size should now be calculated correctly, and the font sizes should decrease geometrically from big to small over rows steps.
; ;fix back to append, fix 1 - rows
; partition-font-sizes: function [big small rows] [
; ;step-size: exp (log-e small - log-e big) / (rows - 1)
; step-size: exp (log-e small - log-e big) / (1 - rows)
; sizes: append copy [] big
; foreach i range/step 2 rows 1 [
; append sizes to-integer round/to big * (step-size ** (i - 1)) 0.1
; ]
; sizes
; ]
; probe partition-font-sizes 34 7 10
; you were correct! (1 - rows) ==[34 29 25 22 19 17 14 12 11 9]
; I'm glad to hear that the partition-font-sizes function is now generating the expected output! It's always satisfying to resolve a problem.
; If you have any further questions or issues, feel free to ask. I'm here to help!
; font-sizes: probe partition-font-sizes 52 6 length? riddles
; [52 48 44 40 37 34 32 29 27 25] still linear
; reverts to the version I keep fixing
; the issue is the math, not the append or range
partition-font-sizes: function [big small rows] [
;factor: (small / big) ** (1 / (rows - 1))
factor: (small / big) ** (1 / (1 - rows))
; sizes: make block! rows
; sizes/1: big
sizes: append copy [] big
foreach i range 2 rows [
;sizes/:i: round/to (big / (factor ** (i - 1))) 0.1
append sizes to-integer round/to (big / (factor ** (i - 1))) 0.1
]
sizes
]
; probe partition-font-sizes 52 6 10
; halt
#define_funcs
assert [1 = arity-of :arity?]
assert [1 = arity-of :zip]
assert [2 = arity-of :apply]
assert [2 = arity-of :fold]
;print [r: apply :+ [1 4 7 ] r = [12]]
print ["apply f" mold r: apply :add [1 4 7 ] r = 12] ;expected fails
print ["fold" mold r: fold :add [1 4 7 ] r = 12]
series-1: [1 2 3 4]
series-2: ["a" "b"]
series-3: ["x" "y" "z"]
result: zip reduce [series-1 series-2 series-3]
print ["zip" mold result result = [1 "a" "x" 2 "b" "y"]]
; It looks like there is a mismatched bracket in the print statement. cgpt found it
; The opening [ at the end of the statement is not properly closed with a ].
; print ["zip" mold r: zip [[1 2 3] [4 5 6] [7 8 9]] r = [1 4 7] [2 8 5] [3 6 9]]]
print ["zip" mold r: zip [[1 2 3] [4 5 6] [7 8 9]] r = [1 4 7] [2 8 5] [3 6 9]]
print ["zip/with" mold r: zip/with [[1 2 3] [4 5 6] [7 8 9]] :add r = [12 15 18]]
; need to use testiing
report-config/show 'all
;report-config/show 'failed
; ME
; write some tests with this format
; report-form {short test name} expected proposed
; expected is the desired result of the proposed statement
;more tests like that for apply and fold
;reverted to assert but whatever
;also tests for apply aren't making sense, needs more research
#define_teststa
; ME
;* Script Error: apply does not allow logic! for its args argument
;assert [apply :add [1 2 3] = 6] ;red evaluation requires 6 = apply form or parenthesis
; Apply tests
; assert [6 = apply :add [1 2 3]]
; assert [["c" "b" "a"] = apply :reverse ["a" "b" "c"]]
; assert [[3 2 1] = apply func [a b c] [c b a] [1 2 3]]
; ME
;flip these if you would
; Fold tests
; assert [fold :add [1 2 3] = 6]
; assert [fold :reverse ["a" "b" "c"] = ["c" "b" "a"]]
; assert [fold func [acc x] [x acc] [1 2 3 4] = [4 3 2 1]]
; Sure, here are the flipped assertions:
assert [6 = fold :add [1 2 3]]
;assert [["c" "b" "a"] = fold :reverse ["a" "b" "c"]]
;asserted [["c" "b" "a"] = fold :reverse ["a" "b" "c"]]
; reverse isn't really a good fit for a fold test in this case
;assert [[4 3 2 1] = fold func [acc x] [x acc] [1 2 3 4]]
; test zip function with /use-fn refinement
; doesn't get how refinements work, had to fix and didn't test default :fold
; apply still seems wrong, cgpt seems to think apply :add should work like fold :add
; also thought should still zip even though zip/with, tests barely usable
; *** Script Error: length? does not allow word! for its series argument
; *** Where: length?
; *** Near : keep length? s
; *** Stack: zip first collect
;needed zip reduce [], cgpt forgot I pointed it out earlier
;zip is returning flat list, needs /only to return blocks?
; not entirely sure what zip is expected to do, or map-each oon all cases
report-form "Test 0 zip empty" [[]] zip [[]] ;should zip/with still work on 1 list?
series-1: [1 2 3 4]
series-2: [10 20 30 40]
expected: [[1 10] [2 20] [3 30] [4 40]]
proposed: zip reduce [series-1 series-2]
report-form "Test 1 zip" expected proposed
series-1: [1 2 3]
series-2: [10 20 30 40]
expected: [11 22 33]
proposed: zip/use-fn/with reduce [series-1 series-2] :apply :add
report-form "Test 2 zip/use-fn/with" expected proposed
series-1: [1 2 3 4]
series-2: [10 20]
expected: [11 22]
proposed: zip/with reduce [series-1 series-2] :add
report-form "Test 3" expected proposed
series-1: ["one" "two" "three"]
series-2: [1 2 3]
series-3: [10 20 30]
expected: [["one" 1 10] ["two" 2 20] ["three" 3 30]]
proposed: zip/use-fn/with reduce [series-1 series-2 series-3] :map-each [s] s :apply
report-form "Test 4" expected proposed
series-1: [1 2 3 4]
series-2: [10 20]
expected: [11 22]
proposed: zip/with reduce [series-1 series-2] :add
report-form "Test 5 fold" expected proposed
#define_teststp
;it totally forgot how to write the test format, would need to repeat the prompt
; Test 1: big-size: 34, small-size: 6, step-size: -3, num-rows: 10, expected: [34 28 23 19 16 13 11 9 7 6]
; Test 2: big-size: 30, small-size: 12, step-size: -2, num-rows: 6, expected: [30 25 21 17 14 12]
; Test 3: big-size: 40, small-size: 8, step-size: -4, num-rows: 8, expected: [40 32 26 20 16 13 10 8]
;report-form "Test 6 -f-s" [34 27 22 18 14 11 10] partition-font-sizes 34 10 7
report-form "Test 6 -f-s" [34 24 18 13 9 7 5] partition-font-sizes 34 10 7
report-form "Test 7 -f-s" [34 29 25 22 19 17 14 12 11 9] partition-font-sizes 34 7 10
report-done ;lota fails, not exhaustive
comment {
halt
no luck having it critique apply, instead it mangled a different bad version of zip
which seems to work until use /with
hopefully I can work out the bugs and get back to the eye chart
not sure it's that instructive or useful trying to get cgpt to fix code
need to be very specific or it will just keep outputting random reverted code
forgetting previous fixes sometimes or ignoring branches apologizing all the way
IAQ /use-fn fn forgot fn, Syntax Error: (line 279) missing [ at ]
still error
was extra bracket in one of the tests
eating up alot of time not really knowing how apply should deal with fn series
assert also annoying to have to stop without running the rest of the tests
}
; earlier sets of cgpt tests that may need work
; continue
; Sure, what else can I assist you with?
; some asserts that prove the zip and mezz work well enough
; Sure, here are some assertions that you can use to test the zip function:
; data: [
; [1 2 3 4 5]
; ["a" "b" "c" "d" "e"]
; [#"x" #"y" #"z"]
; ]
; assert zip data = [
; [1 "a" #"x"]
; [2 "b" #"y"]
; [3 "c" #"z"]
; ]
; assert arity-of :zip = 1
; print {
; These assertions test that zip works as expected
; and has the correct arity (number of arguments).
; }
; halt
;it couldn't sort the list by length, a few could use rewrite to fit font size better
riddles: reverse [
"What starts with an E, ends with an E, but only contains one letter?"
"What can the strongest not hold more than a few minutes?"
"The more you take, the more you leave behind. What am I?"
"What is always in front of you but can't be seen?"
"What belongs to you but is used more by others?"
"What is a mile long but only a few feet wide?"
"What can be broken without being touched?"
"What is full of holes but still holds water?"
"What has a head and a tail but no body?"
"What has a heart that doesn't beat?"
]
; add a riddle like those shorter in length than 10
; Sure! Here's an example of a riddle shorter than 10 characters:
riddles: reverse [
"What starts with an E, ends with an E, but only contains one letter?"
"What can the strongest not hold more than a few minutes?"
"The more you take, the more you leave behind. What am I?"
"What is always in front of you but can't be seen?"
"What belongs to you but is used more by others?"
"What is a mile long but only a few feet wide?"
"What can be broken without being touched?"
"What is full of holes but still holds water?"
"What has a head and a tail but no body?"
"What has a heart that doesn't beat?"
"What has one eye?"
]
; What has a neck but no head, two arms but no hands?
; Answer: A shirt.
; I speak without a mouth and hear without ears. I have no body, but I come alive with wind. What am I?
; Answer: An echo.
; I am always hungry, I must always be fed. The finger I touch, will soon turn red. What am I?
; Answer: Fire.
; What has a heart that doesn't beat, but can still make others feel alive?
; Answer: A work of art.
; I am taken from a mine and shut up in a wooden case, from which I am never released, and yet I am used by almost every person. What am I?
; Answer: Pencil lead.
; I have cities, but no houses. I have mountains, but no trees. I have water, but no fish. What am I?
; Answer: A map.
; I speak without a mouth and hear without ears. I have no body, but I come alive with wind. What am I?
; Answer: An echo.
; I have a heart that doesn't beat, a mouth that doesn't speak, and a head that doesn't think. What am I?
; Answer: A jar.
; I hope this helps! Let me know if you have any further questions.
; ME
; camera?
; I'm sorry, but I'm not sure what you're asking about "camera". Could you please provide more context or information so I can better understand your question and assist you?
; ME
; need answer too, and r,g.b decimal linux color shade of lilac
; I apologize for the confusion. Here are the answers to the two questions you've asked:
; The RGB decimal Linux color shade of lilac is usually represented
; as #C8A2C8 in hexadecimal notation. In decimal notation, this shade of lilac
; can be represented as (200, 162, 200) or (0.784, 0.635, 0.784)
; in RGB values ranging from 0 to 1.
;hard to belive one minute get exactly what you ask for, next minute stumbles around
answers: reverse [
"An envelope"
"breath"
"Footsteps"
"future"
"a runway"
"name"
"promise"
"A sponge"
"A coin"
"artichoke"
"A needle"
]
; ME
; 10 colors on a hue gradient of linix color names and r.g.b decimal
; Here are ten colors on a hue gradient, with their Linux color names and RGB decimal values:
; told it in wrong order and neglected comment and dots. riddles needed rework too
colors: [ ;a few not ideal background colors, not safe for color blind
255.0.0 ; Red: #FF0000,
255.165.0 ; Orange: #FFA500,
255.255.0 ; Yellow: #FFFF00,
0.255.0 ; Lime: #00FF00,
0.128.0 ; Green: #008000,
64.224.208 ; Turquoise: #40E0D0,
;40.40.235 ; Blue: #0000FF, 0.0.255 ;too dark
135.206.235 ; sky Blue: #87CEEB
;168.40.118 ; Purple: #800080, 128.0.128 ;too dark
216.134.211 ;lighter Purple: #D886D3
255.0.255 ; Magenta: #FF00FF,
255.192.203 ; Pink: #FFC0CB,
200.162.200 ; lilac: #C8A2C8,
]
;cgpt weird made-up sort syntax
; sorted-riddles: sort riddles :length-of/part // reverse
; cgpt strange idea setting font sizes to length
; font-sizes: collect [
; foreach riddle sorted-riddles [
; riddle-words: split riddle " "
; append font-sizes (length? riddle-words) * 2
; ]
; ]
;font-sizes: probe range-tv/step 22 10 -2 ; R2 doesn't like range-tv
; font-sizes: probe range/step 34 6 -3 ; range has step? maybe I did work around R2
; font-sizes: probe partition-font-sizes 30 6 length? riddles
; font-sizes: probe partition-font-sizes 53 6 length? riddles
; font-sizes: probe partition-font-sizes 39 6 length? riddles
; [52 48 44 40 37 34 32 29 27 25] still linear and wonky though worked smaller numbers
; [52 40 32 25 19 15 12 9 7 6] ;shouls be better now
font-sizes: probe partition-font-sizes 28 6 ((length? riddles) - 1)
insert font-sizes ((first font-sizes) + ((last font-sizes) * 6)) ;make top line huge
; need apply to-integer and /step 2.4 to really tweak, but also pending calibration
; another problem, the margin also gets bigger. need to work around that somehow
; may need to draw text so can control width of lines maybe
;Script Error: VID - invalid syntax at: [#"^/" text "future"]
; vid/view doesn't ignore newline? new-line either
texts: func ["cgpt insisted on using rebol view code feel engage action color"
][
result: copy [] ;new-line
ps: 10x0
psc: 1
cnt: 0
dex: 20x20
; probe
foreach [riddle font-size color] zip reduce [riddles font-sizes colors] [
; tight not a word? how to reduce margins?
; may need to draw, woops font-size * 1.6 cuts decender
;still huge top margin
;bold no?
; >> d: 1 also d d: d + 1
; == 1 >> d == 2
repend result compose [ ;(psc + ps/y)
'textit (dex) (form font-size)
'textit
(also dex (dex/x: to-integer dex/x - to-integer (0.51 * psc)))
(form cnt: 1 + cnt)
'pad (ps)
'textit (as-pair
to-integer (font-size / 1.46 * length? riddle) to-integer (font-size * 1.8)
)
'font-size (font-size) (color) (rejoin [space riddle])
'on-over [
either event/away? [
face/color: face/color + 10.20.18
face/size: face/size + 2x1
][
;-face/color: (color)
face/color: face/color - 10.20.18
face/size: face/size - 2x1
]
]
'return
;new-line
]
;ps: ps + 26x0 ;needs graduation
;needs graduation. +1 is cumulative
;ps: ps + (as-pair (20 + ps/x) (psc + ps/y) psc: 0.04 + psc)
ps: ps + (as-pair 20 (psc: 0.0022 + psc))
]
;put hint hidden field that shows answer on mouseover of each riddle
; or hint, then answer
; foreach ans probe answers [
; repend result compose [
; 'text (ans) 'font-size (12)
; 'return
; ;newline
; ]
; ]
result
]
; grids: func [" block for base draw grids needs work"
; size [integer!] "Size of the grid in pixels"
; thickness [integer!] "Thickness of the lines in pixels"
; /local half-size half-thickness x y
; ][
; draw: copy []
; half-size: size / 2
; half-thickness: thickness / 2
; foreach i reduce [0.2 0.4 0.6 0.8] [
; x: half-size * i
; y: half-size * i
; repend draw [
; 'pen black
; 'line (x - half-thickness) 0 (x + half-thickness) 'size
; 'line 0 (y - half-thickness) 'size (y + half-thickness)
; ]
; ]
; probe repend draw [
; 'pen black
; 'line half-size 0 half-size 'size
; 'line 0 half-size 'size half-size
; ]
; ]
; Here's the corrected grids function with repend and compose:
; grids: func [" block for base draw grids needs work"
; size [integer!] "Size of the grid in pixels"
; thickness [integer!] "Thickness of the lines in pixels"
; /local half-size half-thickness x y draw
; ][
; draw: copy []
; half-size: size / 2
; half-thickness: thickness / 2
; foreach i reduce [0.2 0.4 0.6 0.8] [
; x: half-size * i
; y: half-size * i
; repend draw compose [
; pen black
; line (x - half-thickness) 0 (x + half-thickness) size
; line 0 (y - half-thickness) size (y + half-thickness)
; ]
; ]
; repend draw compose [
; pen black
; line half-size 0 half-size size
; line 0 half-size size half-size
; ]
; draw
; ]
;shouldn't it need a line count as well as grid size
; should be pairs?
; img: make image! 200x200 ? img
; draw img [pen black line 10x100 30x100] ? img
; need to do a simple diag or something. cgpt is not much help debugging dsl
; [pen black line 3x0 12x0] ;wtf, don't work
; canvas: base 150x150 white
; draw [text 50x50 "Hello!!!!" circle 70x60 40]
; grids: func [" block for base draw grids needs work"
; size [integer!] "Size of the grid in pixels"
; thickness [integer!] "Thickness of the lines in pixels"
; /local half-size half-thickness x y draw
; ][
; draw: reduce ['pen (black)]
; half-size: size / 2
; half-thickness: thickness / 2
; ; foreach i [0.2 0.4 0.6 0.8]
; foreach i range/step 1 (size ) to-integer (700 / size) [ ;[0.2 0.4 0.6 0.8] base 1
; x: half-size * i
; y: half-size * i
; repend draw compose [;/deep
; ; 'size (x + half-thickness) 'line (as-pair (x - half-thickness) 0)
; ; ;'line
; ; (as-pair 0 (y - half-thickness)) ;'size (y + half-thickness)
; 'line-width (to-integer (x + half-thickness))
; 'line (as-pair absolute to-integer (x - half-thickness) 1)
; ; 'line-width (to-integer (y + half-thickness))
; ; 'line
; (as-pair 1 absolute to-integer (y - half-thickness))
; ]
; ]
; repend draw compose [;/deep
; ; ;'pen (black)
; ; 'size (half-size) 'line (as-pair half-size 0)
; ; ;'line
; ; (as-pair 0 half-size) ;'size (half-size)
; 'line-width (to-integer (half-size + half-thickness))
; 'line (as-pair to-integer half-size 1)
; ;'line
; (as-pair 1 to-integer half-size)
; ]
; draw
; ;[pen black size 2.0 line 3x0 12x0]
; ; [pen black line 3x0 12x0]
; ]
; ME
; stick with the range solution
; can we overlay every other line like a pie crust
;and also includes type and docstring
; Here's the grids function using the range/step solution
; updated grids function that supports /skips
;probs should've got simple grid working first. complicated it 10x,
; will it actually overlay. halucination. could slight hue change x/y too
;
;only creates some lines from x direction
; grids: func ["Create a grid pattern"
; size [integer!] "Size of the grid in pixels"
; rows [integer!] "Number of rows/columns in the grid"
; /thick thk [integer!] "Thickness of the lines in pixels"
; /skips skps [integer!] "Number of lines to skip between each row/column"
; /local half-size half-thickness x y draw skip-count
; ][
; ;rows: either rows [rows] [to-integer half-size / (thk * (1 + skps))]
; skps: any [skps 1]
; thk: any [thk 3]
; draw: reduce ['pen black]
; half-size: size / 2
; half-thickness: thk / 2
; skip-count: 0
; foreach i range 1 rows [
; x: half-size * (i / rows)
; y: half-size * (i / rows)
; line-thickness: thk
; if (skip-count % skps) <> 0 [
; line-thickness: thk / 2
; ;line-thickness: any [thk half-thickness] ;all same
; ]
; repend draw compose [
; 'line-width (line-thickness)
; 'line (as-pair (x - half-size) (y - half-thickness))
; (as-pair (x + half-size) (y + half-thickness))
; ]
; skip-count: skip-count + 1
; if skip-count >= (rows * skps) [
; skip-count: 0
; ]
; ]
; ;draw: reduce draw
; ;reduce ['base size size draw]
; draw
; ]
;corrected for no y
;only creates some dots in the middle
; grids: func ["Create a grid pattern"
; size [integer!] "Size of the grid in pixels"
; rows [integer!] "Number of rows/columns in the grid"
; /thick thk [integer!] "Thickness of the lines in pixels"
; /skips skps [integer!] "Number of lines to skip between each row/column"
; /local half-size half-thickness x y draw skip-count
; ][
; skps: any [skps 1]
; thk: any [thk 3]
; draw: reduce ['pen black]
; half-size: size / 2
; skip-count: 0
; foreach i range 1 rows [
; x: half-size * (i / rows)
; y: half-size * (i / rows)
; line-thickness: thk
; if (skip-count % skps) <> 0 [
; either (skip-count / skps) = 1 [
; ; Vertical line
; half-thickness: thk / 2
; repend draw compose [
; 'line-width (line-thickness)
; 'line (as-pair (x - half-thickness) (absolute half-size))
; (as-pair (x + half-thickness) half-size)
; ]
; ][
; ; Horizontal line
; half-thickness: thk / 2
; repend draw compose [
; 'line-width (line-thickness)
; 'line (as-pair (absolute half-size) (y - half-thickness))
; (as-pair half-size (y + half-thickness))
; ]
; ]
; ]
; skip-count: skip-count + 1
; if skip-count >= (rows * skps) [
; skip-count: 0
; ]
; ]
; draw
; ]
; Now, the lines should have the correct thickness and extend all the way to the edge of the image.
; ME
; base 600x600 draw [pen 0.0.0 line-width 4 line 300x98 300x102 line-width 4 line 300x198 300x202 line-width 4 line 300x298 300x302]
; This draw command would only create vertical lines at x-coordinate 300 with a length of 4 pixels and a thickness of 4 pixels.
; ME
; thoughts why?
; It seems that the issue might be with the calculation of the x and y coordinates in the foreach loop. In the current implementation, x and y are calculated using the same formula for each iteration, regardless of whether the line should be skipped or not.
; To fix this issue, you could calculate the x and y coordinates separately for lines that should be drawn and lines that should be skipped. For lines that should be drawn, you could use the same formula as before:
; x: half-size * (i / rows)
; y: half-size * (i / rows)
; For lines that should be skipped, you could calculate the x and y coordinates as follows:
; x: half-size * (i / rows)
; y: half-size * ((i + 0.5) / rows)
; This will shift the skipped lines by half a cell in the y direction, while keeping the x coordinate the same. Here's how the updated code might look:
; my edit wasn't using thickness and now it revered to no overlay no y?
; Here's a possible implementation of grids function that draws both horizontal and vertical lines:
; grids: func [
; "Create a grid pattern"
; size [integer!] "Size of the grid in pixels"
; rows [integer!] "Number of rows in the grid"
; /skips skps [integer!] "Number of rows to skip between each row"
; /thick thk [integer!] "Thickness of the lines in pixels"
; /local half-size half-thickness x y draw skip-count
; ][
; skps: any [skps 1]
; thk: any [thk 3]
; draw: reduce ['pen black]
; half-size: size / 2
; half-thickness: thk / 2
; skip-count: 0
; foreach i range 1 rows [
; x: half-size * (i / rows)
; y: half-size * (i / rows)
; line-thickness: thk
; if (skip-count % (skps + 1)) <> 0 [
; line-thickness: thk / 2
; ]
; repend draw [
; 'line-width (line-thickness)
; 'line (as-pair (absolute half-size) (y - half-thickness))
; (as-pair half-size (y - half-thickness))
; 'line (as-pair (x - half-thickness) (absolute half-size))
; (as-pair (x - half-thickness) half-size)
; ]
; skip-count: skip-count + 1
; if skip-count >= (rows * (skps + 1)) [
; skip-count: 0
; ]
; ]
; draw
; ]
; Here's a modified version of the function that should draw both horizontal and vertical lines:
; ME
; (-half-size) if you forgot is (absolute half-size) in red
; Thank you for the correction. I apologize for the mistake.
; ME
; maybe negate half-size,, red is not a line noise language
; That's correct, you can use -half-size instead of absolute half-size in this case. This would make the code a bit more concise.
; ME
; if skip-count >= rows * (skps + 1)
; The condition skip-count >= rows * (skps + 1) checks if the current skip count is greater than or equal to the total number of lines that should be skipped before the next thicker line is drawn.
; Here, rows represents the total number of rows/columns in the grid, skps is the number of lines to skip between each row/column, and skip-count is the number of lines that have been drawn so far.
; The expression rows * (skps + 1) calculates the total number of lines that should be skipped before drawing the next thicker line. The +1 is added because there is always a thin line between two thicker lines.
; So the condition skip-count >= rows * (skps + 1) checks if enough thin lines have been drawn to skip and it's time to draw a thicker line.
; ME
; red evaluation order makes this kind of statement an error w/o parens or flipping the order
; a later complication would be cross hatching the intersections
; Here's an example of how you could add cross-hatching to the current grids function:
; [code]
; ME
; we'll shelve the intersection version for now. what would be the cause of the endpoints wrong?
; we have both h & v, we have alternating thickness. we don't have full lines, just dots
; There are a few potential issues that could cause the endpoints to be incorrect in the grid pattern. Here are a few possibilities:
; Incorrect calculation of the line endpoints: The calculation for the line endpoints could be incorrect, causing the lines to be drawn in the wrong location.
; Incorrect use of the absolute function: The absolute function is being used to calculate the line endpoints, but it might not be appropriate in this case. Depending on how the absolute function is used, it could cause the lines to be drawn in the wrong place.
; Incorrect use of the range function: The range function is used to generate the grid lines, but if the arguments to the function are incorrect or if the function is used improperly, it could cause the endpoints to be wrong.
; ME
; can you guess from the draw probe?
; Based on the draw probe, it seems like the lines are being drawn from
; the center of the canvas (250, 250) instead of the corners of the
; canvas. This is likely due to the half-size calculation in the grids
; function which is dividing the size by 2 and then dividing it again by
; rows, rather than subtracting the thickness and dividing by rows. This
; causes the lines to start and end at the wrong positions.
;time to start morphing into quadrants.
;add light/dark circles at intersections to simulate crosshatch
grids: func ["Create a grid pattern"
size [integer!] "Size of the grid in pixels"
rows [integer!] "Number of rows in the grid"
/thick thk [integer!] "Thickness of the lines in pixels"
/skips skps [integer!] "Number of rows to skip between each line"
/local half-size half-thickness x y draw skip-count
][
skps: any [skps 1]
thk: any [thk 3]
draw: reduce ['pen black]
half-size: size / 2
half-thickness: thk / 2
skip-count: 0
foreach i range 1 rows [
; Vertical line
x: half-size * (i / rows)
line-thickness: thk
if (skip-count % skps) <> 0 [
line-thickness: thk / 2
]
repend draw compose [
'line-width (line-thickness)
;'line (as-pair (x - half-thickness) (absolute half-size))
; (as-pair (x + half-thickness) half-size)
'line (as-pair (x) (1))
(as-pair (x) size) ;square
]
; Horizontal line
y: half-size * (i / rows)
line-thickness: thk
if (skip-count % skps) <> 0 [
line-thickness: thk / 2
]
repend draw compose [
'line-width (line-thickness)
; 'line (as-pair (absolute half-size) (y - half-thickness))
; (as-pair half-size (y + half-thickness))
'line (as-pair (1) (y - half-thickness) )
(as-pair (size) (y)) ;square
]
skip-count: skip-count + 1
if skip-count >= (rows * (skps + 1)) [
skip-count: 0
]
]
draw
]
;
#define_gview
;make window & panel sizes part of calibration step
gview: compose/deep [
title "Mock Eye Chart with Riddles"
size 820x650
backdrop ivory ;won't accept some color names tan snow, ivory leaf ok
style textit: text 75x20 ;mint "hexnow"
style fieldit: field 75x20 ;sand "hexnow"
below
tab-panel 810x580 [
"mock Jaeger chart" [
(texts)
]
"mock Amsler Grid" [
; This will create a 6x6 grid with 2 lines skipped between each row/column,
; with a size of 600 pixels and a thickness of 4 pixels.
base 500x500 draw [(probe grids/thick/skips 400 6 4 2)]
]
"mock macular Grid" [
box font-size 20 {
+---+---+---+---+
| N | | | E |
+---+---+---+---+
| | X | O | |
+---+---+---+---+
| | O | X | |
+---+---+---+---+
| W | | | S |
+---+---+---+---+} ;aschii placeholder for draw code
;each quadrant has a specific grid distortion to verify rods & cones are healthy
;I guess you look at each quadrant covering one eye at a time focus on center
; then maybe it rotates? dark spot, light spot, swirled grid, unchanged grid
;not sure how far down this road I need to go, it's just a lark to practice w/chatGPT
]] ;e panel
across
return
t: textit f: fieldit
button "Flip" [
]
button "Flop" [
]
]
print mold gview
; halt
; view/no-wait/flags/options gview ['resize][offset: 100x150]
view/flags/options/tight layout gview ['resize][offset: 100x100]
#define_view_end
; /tight didn't affect text margin. might in call
comment {
todo
add
needed more capable dynamic zip to do the eye chart, taking hours nailing it down
need comprehensive tests for zip, apply, fold, map-each
have no clue what they should do on edge cases or at all
tab-panel [
"F" [
foreach [riddle font-size color] zip sorted-riddles font-sizes colors [
'text riddle 'font-size (font-size)
'font
'return
]
]
"H" [
t: textit f: field
button "Flip" []
button "Flap" []
]
]
rusty, (texts) returning the foreach, not the result. needs to repend
ua2 ~10HR, closer but still not quite
zip doing the wrong thing, for some reason zips the riddles. forgot block
#"W" #"W" #"W" #"W" #"W" #"W" #"h" #"h" #"h" #"h" #"h" #"h" #"a" #"a"
foreach [riddle font-size color] probe zip reduce [riddles font-sizes colors]
need zip to reduce unless /only or something. must be block won't catch errors
ME
success, at least it's a start. needs some padding and mouseove
and hint buttons for each riddle instead of showing answers
You can use style to define the default style of the text face to
avoid repeating it in each repend block.
To add padding to the text face, you can use the pad style. For
example, pad 10x10 will add 10 pixels of padding to both the left
and right sides of the face and 10 pixels of padding to the top and
bottom.
You can add a field face to display the answer to the riddle when
the user hovers over the question. To do this, you can use show to
change the text of the field face when the text face is hovered
over.
[code rewrite]
taking way too long, but cgpt comes up with some interesting ideas
stuck in rebol view too, not 100% red-lang compatible but good effort
ME
this will be like a cog & eye test lie detector.
Interesting idea. Good luck with it!
thought it was going to lecture me
has ruler & point scale. should be able to overlay chart w/font size to match
add +- zoom buttons. block out a credit card size to match
\Downloads\1343830519-2524210-distance-visual-acuity-test4-www.hqtexture.com.jpg
http://hqtexture.com/uploads/posts/2012-08/
has side by side charts, should be 20 feet or 6 feet in UK? #8 is 20/20 average age 60
I can read 11 at laptop about 5 foot away with focus red glasses
\Downloads\tests-visual-acuity-testing-numerical-indexes-diagram-snellen-landoldt-c-golovin-sivtsev-s-table-130026011.jpg
still don't really know how to judge how much weaker one pair of glasses vrs another
ME
back to eye charts, not sure totally what the conversion to point size for each row in Jaeger chart
The conversion from the font size to point size in the Jaeger chart
depends on the distance at which the chart is being viewed.
For example, if the chart is being viewed from a distance of 20 feet,
then the font size for the 20/20 row would be 8.73 points. The point
size for each row is calculated by multiplying the font size by a
scaling factor, which is determined by the viewing distance. The
scaling factor is based on the distance at which a standard eye is able
to read the chart from a distance of 20 feet, which is considered
normal visual acuity.
ME
I do have one image that shows points, need to adjust zoom for arms length
20/20 is seventh row?
In the Snellen chart, 20/20 is the eighth row, while in the Jaeger chart,
20/20 is equivalent to the fourth row.
ME
it is 8th in Snellen I guess, Jaeger I thought stopped at 8
just grabbed sample images, no research beyond what cgpt said
ME
it might be fun to put a Amsler Grid in another tab.
what would the red draw on a base look like?
don't need to regenerate the whole program any more,
[code for grid]
not w/o error
have the riddles now displaying in decreasing size
actually should be the shortest is largest font
screenshot & shipit
got index showing decreased height default font
can't seem to debug grids, fixed size, pair absolute integer. why error
cgpt no help, but kept at it. finally have alternating thickness somewhat grid
doesn't continue past first quadrant crosshatch center
made offhand comment about pie crust crosshatch and it generated code
then to simulate the intersection overlap
probably polka dotting every other intersection,
it's just a background for the real job of distortions in each quadrant.
then rotating the grid to test each eye rod/cone in multiple ways
psychedelic posters will be another application
cgpt
That sounds like a fun project! Is there anything specific you need help with
in creating psychedelic posters?
not sure how bad I want the grid either. working on the chatGPT interaction
added a few more rows beyond 20/20 at row #8, point sizes not accurate yet
20/20 is actually better than required by most USA DMV but it's not a thesis
fixed skips 10th row, made geometric progression wrangling chatGPT
official chart has huge first row, drops off faster not linear
could still drop off faster, first row in classic chart is huge
took another few iterations, added 11th shorter riddle. good enough for now
the math would've been difficult for me to figure out,
would've ended up hardwireing 1..row font-size percent or something
[39 32 26 22 18 15 12 10 8 7 6]
7 6 4 4 3 3 2 2 1 1 still not great
FIXME:
need tweaks for symetry, mouseover answers, length of background, color choices
here's a screenshot...
not sure there is a path to running anything but a screenshot gif/mp4 in a browser
need to display point and row numbers
calibration block for ruler or credit card and +- zoom instructions
point size would change based on calibration, distance/dpi complexifies setup
macular degeneration quadrant test in another tab, rotation,
prompt to cover one eye
do a traditional eye chart
change or random riddles could be another option
copyright on riddles?
disclaimer, IANAO, this is not a substitute for competent eye care etc.
credit chatGPT openAI on screen. maybe animate about tab
https://gist.github.com/starred
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment