这是 Small Basic 中的代码:
GraphicsWindow.CanResize = 0
GraphicsWindow.Width = 201
GraphicsWindow.Height = 300
X = 0
circumstance = 0
'Initialization
GraphicsWindow.SetPixel(100,0,"Black")
code = "01111111"
'Start
For i=1 To GraphicsWindow.Height
For X=0 To GraphicsWindow.Width
Program.Delay(1)
If X>0 Then
If GraphicsWindow.GetPixel(X-1,i-1) = "Black" Then
circumstance = circumstance + 1
EndIf
EndIf
If GraphicsWindow.GetPixel(X,i-1) = "Black" Then
circumstance = circumstance + 10
EndIf
If X<GraphicsWindow.Width Then
If GraphicsWindow.GetPixel(X+1,i-1) = "Black" Then
circumstance = circumstance + 100
EndIf
EndIf
TextWindow.WriteLine(circumstance)
EndFor
EndFor
它的作用是逐个像素地查看图形窗口。变量“情况”是它发现的。如果目标像素的左上角有黑色像素,则第一位为 1。如果目标像素的左上角有黑色像素,则第二位为 1。如果有黑色像素到目标像素的右上角,第三位数字为1。但无论我尝试什么情况总是输出000。