Liberty BASIC Community Forum
« Code appendix to LB for Blind Users. »

Welcome Guest. Please Login or Register.
Jun 25th, 2017, 05:27am


Rules|Home|Help|Search|Recent Posts|Notification


« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Code appendix to LB for Blind Users.  (Read 94 times)
raymcal
Junior Member
ImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 53
xx Code appendix to LB for Blind Users.
« Thread started on: Feb 10th, 2016, 8:54pm »

Code follows:

Code:
'BASIC Rules
'A blind-accessible graphics analyzer.
'Colored writing is covered by a box (tinted glass) with various colors and rules invoked.
'Notice all the keyboard commands.
'The main window, "\" messages, statictext, and combobox are all screen-reader friendly.
'The blind user uses the space bar to lock focus on combobox for rule change.
'The announcement about this is white on white, only visible to screen readers.
'Main window print-out lists colors as drawn and RGB values after rule change.
'A ding confirms that RGB print-out happened in main window.
'Status line at bottom of graphicbox tells what's presently happening.
'Rule "CopyPen (Over)" turns the colored box into an rGB color testing lab.
cls
[SetVariables]
test = 0
dim rule$(16)
dim rnum(16)
dim name$(7)
dim color(3)
fc = 0  'Focus control variable
rule = 1
choice = 1
name$(1) = "red."
name$(2) = "green."
name$(3) = "blue."
name$(4) = "cyan."
name$(5) = "yellow."
name$(6) = "magenta."
name$(7) = "all colors."
color(1) = 255
color(2) = 255
color(3) = 255
rgb$ = "100"
[readRuleNameData]
for k = 1 to 16
read a, a$
rnum(k) = a
rule$(k) = a$
next k
'Window setup
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
   statictext #g.s, "Choose Rule", 10, 505, 300, 100
combobox #g.c, rule$(),[select], 400, 505, 300, 200
graphicbox #g.g, 0, 0, 1333, 500
button #g.b, "Select", [choice], ul,900, 550, 100, 80
open "BASIC Rules" for window as #g
#g.s "!font 20"
#g.c "font 20"
#g.b "!font 20"

#g.c "select ";rule$(1)

#g "trapclose [quit]"
[work]
'Graphicbox message setup
#g.g "place 0 0 ; Color Black ; BackColor Black ; down ;BoxFilled 1332 200"
#g.g "font 40 70 ; down ; place 0 70 ; Color Red ; BackColor Green"
#g.g "\Red on green"
#g.g "place 0 140 ; down ; Color 255 160 0 ; BackColor Blue ; font 40 70"
#g.g "\Orange on blue"
#g.g "place 680 70 ; down ; Color Yellow ; BackColor 140 0 200 ; font 40 70"
#g.g "\Yellow on purple"
#g.g "place 680 140 ; down ; Color 100 100 100 ; BackColor White ; font 40 70"
#g.g "\Grey on white"
#g.g "place 0 250 ; down ; Color Black ; BackColor White ; font 20"
#g.g "\Press A for control of all colors of the tinted glass."
#g.g "\   R for red; G, green; B, blue; C, cyan; Y, yellow; M, magenta."
#g.g "\   0-9 to change selected color(s) to 1 of 10 values from 0-255."
#g.g "\   Arrow Keys to advance color(s) 1 notch at a time."
#g.g "\   P to print to screen current RGB list."
#g.g "\   Alt-F4 to close window."
'Make accessibility line visible only to screen readers.
#g.g "color white ; backcolor white ; down"
#g.g "\   Space Bar for blind-accessible combobox."
#g.g "flush messages"
#g.g "\"
#g.g "flush change"
gosub [printOut]
gosub [ruleChange]
[keyCheck] 'Get computer watching for key-presses.
scan
'Blind-accessibility focus control.
      if fc = 0 then
            #g.g "setfocus"
            #g.g "when characterInput [keyWork]"
else
#g.c "setfocus"
end if
wait
[keyWork] 'Act according to key presses.
k$ = Inkey$
key = asc(k$)
select case
case k$ = " "
fc = 1  'Allow blind users to have focus locked on combobox.
case (key >= 48) and (key <= 57) 'Number key control.
'Change only the selected values.
for k = 1 to 3
if mid$(rgb$,k,1) = "1" then color(k) = int(val(k$)*(255/9))
next k
gosub [ruleChange]
'Arrow key control.
case (asc(right$(k$,1)) =_VK_LEFT) or (asc(right$(k$,1)) =_VK_DOWN)
show = 0 'Status line and screen don't update if no change.
for k = 1 to 3
if mid$(rgb$,k,1) = "1" then color(k) = color(k) - 1
if color(k) < 0 then
color(k) = 0
else
show = 1
end if
next k
if show = 1 then gosub [ruleChange]
case (asc(right$(k$,1)) =_VK_RIGHT) or (asc(right$(k$,1)) =_VK_UP)
show = 0
for k = 1 to 3
if mid$(rgb$,k,1) = "1" then color(k) = color(k) + 1
if color(k) > 255 then
color(k) = 255
else
show = 1
end if
next k
if show = 1 then gosub [ruleChange]
'Set which RGB value(s) of tinted glass cover to change.
case upper$(k$) = "R"
rgb$ = "100"
choice = 1
gosub [ruleChange]
case upper$(k$) = "G"
rgb$ = "010"
choice = 2
gosub [ruleChange]
case upper$(k$) = "B"
rgb$ = "001"
choice = 3
gosub [ruleChange]
case upper$(k$) = "C"
rgb$ = "011"
choice = 4
gosub [ruleChange]
case upper$(k$) = "Y"
rgb$ = "110"
choice = 5
gosub [ruleChange]
case upper$(k$) = "M"
rgb$ = "101"
choice = 6
gosub [ruleChange]
case upper$(k$) = "A"
rgb$ = "111"
choice = 7
gosub [ruleChange]
'Send RGB print-out to main window with confirming ding.
case upper$(k$) = "P"
playwave "nofile.wav", async
gosub [printOut]
end select
goto [keyCheck]
[select]  'Access data from combobox.
#g.c "selectionindex? rule"
gosub [ruleChange]
'Blind accessibility focus control.
      if fc = 0 then
            #g.g "setfocus"
            #g.g "when CharacterInput [keyWork]"
else
#g.c "setfocus"
end if
wait
'Button action
[choice]
fc = 0
goto [select]
wait
[quit]
close #g
print
print "Press Alt-F4 to end program."
wait
[ruleChange]
'Remove what graphics will be changed.
#g.g "delsegment change ; redraw"
'Determine which rule to use.
#g.g "rule ";rnum(rule)
'Change message colors as directed.
#g.g "Color ";color(1);" ";color(2);" ";color(3)
#g.g "BackColor ";color(1);" ";color(2);" ";color(3)
#g.g "place 0 0 ; size 1 ; down ; BoxFilled 1332 200"
'Revise status line at bottom of graphicbox.
message$ = "Rule = ";rule$(rule) ; ", color ";color(1); " ";color(2);" ";color(3);", and changing ";name$(choice)
#g.g "font 20 ; place 0 485 ; Color 0 0 128 ; BackColor White ; down"
#g.g "\" ; message$
                                            'Flush new material.
#g.g "flush change"
'Blind accessible focus control.
      if fc = 0 then
            #g.g "setfocus"
            #g.g "when characterInput [keyWork]"
else
#g.c "setfocus"
end if
return
'Set in main window RGB values of messages through tinted glass.
[printOut]
'Notify differently for first print-out.
if test = 0 then
print "Original print-out, actual color values."
else
print
print "Rule = ";rule$(rule) ; ", glass color ";color(1); " ";color(2);" ";color(3)
end if
test = 1
'Use col$ function to get pixel values.
print "   Red: ";col$(7,40)
print "   Orange: ";col$(5,110)
print "   Yellow: ";col$(705,40)
print "   Green: "; col$(6,40)
print "   Blue: ";col$(4,110)
print "   Purple: ";col$(706,40)
print "   White: ";col$(755,110)
print "   Grey: ";col$(756,110)
print "   Black: ";col$(622,110)
                                       'Blind accessibility focus control.
                      if fc = 0 then
            #g.g "setfocus"
            #g.g "when characterInput [keyWork]"
else
#g.c "setfocus"
end if
return
[listOfRulesWithCodeNumbers]
data 10, "NotXOrPen, (XOr)", 7, "XOrPen", 9, "MaskPen", 8, "NotMaskPen"
data 3, "MaskNotPen", 5, "MaskPenNot", 15, "MergePen", 2, "NotMergePen"
data 12, "MergeNotPen", 14, "MergePenNot", 6, "Not", 13, "CopyPen (Over)",
data 4, "NotCopyPen", 1, "Black", 16, "White", 11, "NoOperation"
'Function col$ -- col$(x,y) finds RGB value for pixel x,y.
function col$(colorx,colory)
#g.g "getbmp gpv ";colorx;" ";colory;" 1 1"
bmpsave "gpv", "getpvaluetemp.bmp"
open "getpvaluetemp.bmp" for input as #gpv
colorresult$ = input$(#gpv, lof(#gpv))
close #gpv
if asc(mid$(colorresult$, 29, 1)) = 32 then
red = asc(mid$(colorresult$, 69, 1))
green = asc(mid$(colorresult$, 68, 1))
blue = asc(mid$(colorresult$, 67, 1))
end if
col$ = str$(red) + " " + str$(green) + " " + str$(blue)
end function

 

User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Rules|Home|Help|Search|Recent Posts|Notification

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls