'Soroban - Japanese Abacus - SKH302
'Harry Hardjono
'August 2012
'
'These Unicode Characters draw Card Suits: Spade, Heart, Diamond,Club
'TestStr=Text.GetCharacter(9828)+Text.GetCharacter(9825)+Text.GetCharacter(9826)+Text.GetCharacter(9831)
'
'Over one hour is wasted because the Unicode characters for CharCL (empty bead) DO NOT LINE UP.
'
InitLoop:
GraphicsWindow.MouseUp=OnMouse
GraphicsWindow.Title="Small Basic Abacus"
GraphicsWindow.Width = 400
GraphicsWindow.Height=400
GraphicsWindow.FontSize=20
'GraphicsWindow.FontName="Courier"
GraphicsWindow.Clear()
GraphicsWindow.Show()
GraphicsWindow.BrushColor="white"
GraphicsWindow.FillRectangle(0,0,GraphicsWindow.Width,GraphicsWindow.Height)
GraphicsWindow.BrushColor="black"
CharCL=text.GetCharacter(9508) '+text.GetCharacter(9474)+text.GetCharacter(9553)
SKB[0]=Text.GetCharacter(9556)
SKB[1]=Text.GetCharacter(9553)
SKB[2]=Text.GetCharacter(9553)
SKB[3]=Text.GetCharacter(9568)
SKB[4]=Text.GetCharacter(9553)
SKB[5]=Text.GetCharacter(9553)
SKB[6]=Text.GetCharacter(9553)
SKB[7]=Text.GetCharacter(9553)
SKB[8]=Text.GetCharacter(9553)
SKB[9]=Text.GetCharacter(9562)
DGT=" "
For i=1 To 15
SKB[0]=Text.Append(SKB[0],Text.GetCharacter(9572))
SKB[1]=Text.Append(SKB[1],Text.GetCharacter(9830))
SKB[2]=Text.Append(SKB[2],Text.GetCharacter(9830))
SKB[3]=Text.Append(SKB[3],Text.GetCharacter(9578))
SKB[4]=Text.Append(SKB[4],Text.GetCharacter(9830))
SKB[5]=Text.Append(SKB[5],Text.GetCharacter(9830))
SKB[6]=Text.Append(SKB[6],Text.GetCharacter(9830))
SKB[7]=Text.Append(SKB[7],Text.GetCharacter(9830))
SKB[8]=Text.Append(SKB[8],Text.GetCharacter(9830))
SKB[9]=Text.Append(SKB[9],Text.GetCharacter(9575))
IBB[i]=0
ISB[i]=0
DGT=Text.Append(DGT,(5*BB[i]+SB[i]))
EndFor
SKB[0]=Text.Append(SKB[0],Text.GetCharacter(9559))
SKB[1]=Text.Append(SKB[1],Text.GetCharacter(9553))
SKB[2]=Text.Append(SKB[2],Text.GetCharacter(9553))
SKB[3]=Text.Append(SKB[3],Text.GetCharacter(9571))
SKB[4]=Text.Append(SKB[4],Text.GetCharacter(9553))
SKB[5]=Text.Append(SKB[5],Text.GetCharacter(9553))
SKB[6]=Text.Append(SKB[6],Text.GetCharacter(9553))
SKB[7]=Text.Append(SKB[7],Text.GetCharacter(9553))
SKB[8]=Text.Append(SKB[8],Text.GetCharacter(9553))
SKB[9]=Text.Append(SKB[9],Text.GetCharacter(9565))
DrawLoop:
GraphicsWindow.FontSize=32
DKB=SKB
BB=IBB
SB=ISB
x= GraphicsWindow.MouseX
y= GraphicsWindow.MouseY
DGT=""
DoMouse()
DoBead()
For i=1 To 15
DGT=Text.Append(DGT,(5*BB[i]+SB[i]))
EndFor
GraphicsWindow.FontSize=32
GraphicsWindow.BrushColor="white"
GraphicsWindow.FillRectangle(30,254,334,35)
GraphicsWindow.BrushColor="black"
GraphicsWindow.DrawText(35,250,DGT)
GraphicsWindow.FontSize=40
For i=0 To 9
If (ODKB[i]<>DKB[i]) Then
GraphicsWindow.BrushColor="white"
GraphicsWindow.FillRectangle(39,14+i*25,315,25)
GraphicsWindow.BrushColor="black"
EndIf
GraphicsWindow.DrawText(20,i*25,DKB[i])
ODKB[i]=DKB[i]
EndFor
Program.Delay(150) 'Wait 150 miliseconds
Goto DrawLoop
Sub DoBead
For i=1 to 15
DKB[2-BB[i]]=Text.Append(Text.Append(Text.GetSubText(DKB[2-BB[i]],1,i),text.GetCharacter(9553)),Text.GetSubTextToEnd(DKB[2-BB[i]],i+2))
DKB[4+SB[i]]=Text.Append(Text.Append(Text.GetSubText(DKB[4+SB[i]],1,i),text.GetCharacter(9553)),Text.GetSubTextToEnd(DKB[4+SB[i]],i+2))
EndFor
EndSub
Sub DoMouse
map_var="mx1=39;mx2="+x+";mx3=354;my1=1;my3=16" 'Xcoord mapped to 1-15
map()
cx=Math.Floor(map_var["my2"])
If (cx>=1 and cx<=15) then
If (y>39 And y < 85) Then
map_var="mx1=39;mx2="+y+";mx3=85;my1=2;my3=0" 'Ycoord mapped to 1-0
map()
cy=Math.Floor(map_var["my2"])
If (cy>=0 And cy<=1) Then
BB[cx]=cy
EndIf
EndIf
If (y>114 And y < 237) Then
map_var="mx1=114;mx2="+y+";mx3=237;my1=0;my3=5" 'Ycoord mapped to 1-0
map()
cy=Math.Floor(map_var["my2"])
If (cy>=0 And cy<=5) Then
SB[cx]=cy
EndIf
EndIf
EndIf
EndSub
'----------------------------------------------
'map function
'----------------------------------------------
Sub map
'x1-x2-x3 y1-y2-y3
'(x2-x1)/(x3-x1)=(y2-y1)/(y3-y1)
'y1+(y3-y1)*(x2-x1)/(x3-x1)=y2
map_var["my2"]=((map_var["my3"]-map_var["my1"])*(map_var["mx2"]-map_var["mx1"])/(map_var["mx3"]-map_var["mx1"]))+map_var["my1"]
EndSub
'----------------------------------------------
'event function
'----------------------------------------------
Sub OnMouse
IBB=BB
ISB=SB
EndSub
No comments:
Post a Comment