恩……这个程序是根据帮助文件中的一个改得,增加了调整画笔粗细和颜色的按键。也是没什么说头的。
提示:GraphicsWindow.LastKey属性中的D0到D9指数字键。
status = True
clearWidth = 10
penWidth = 2
GraphicsWindow.BackgroundColor = "Black"
GraphicsWindow.PenColor = "White"
GraphicsWindow.BrushColor = "White"
GraphicsWindow.PenWidth = penWidth
GraphicsWindow.MouseDown = OnMouseDown
GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.KeyDown = OnKeyDown
GraphicsWindow.Title = "黑板"
GraphicsWindow.DrawText(0, 0, "X:擦除 1:白色 2:黄色 3:蓝色 4:绿色 5:红色 Q/W:调整粗细")
Sub OnMouseDown
prevX = GraphicsWindow.MouseX
prevY = GraphicsWindow.MouseY
EndSub
Sub OnKeyDown
If (GraphicsWindow.LastKey = "X") then
GraphicsWindow.PenColor = GraphicsWindow.BackgroundColor
GraphicsWindow.PenWidth = clearWidth
status = False
EndIf
If (GraphicsWindow.LastKey = "D1") then
GraphicsWindow.PenColor = "White"
GraphicsWindow.PenWidth = penWidth
status = True
EndIf
If (GraphicsWindow.LastKey = "D2") then
GraphicsWindow.PenColor = "Yellow"
GraphicsWindow.PenWidth = penWidth
status = True
EndIf
If (GraphicsWindow.LastKey = "D3") then
GraphicsWindow.PenColor = "Blue"
GraphicsWindow.PenWidth = penWidth
status = True
EndIf
If (GraphicsWindow.LastKey = "D4") then
GraphicsWindow.PenColor = "Lime"
GraphicsWindow.PenWidth = penWidth
status = True
EndIf
If (GraphicsWindow.LastKey = "D5") then
GraphicsWindow.PenColor = "Red"
GraphicsWindow.PenWidth = penWidth
status = True
EndIf
If (GraphicsWindow.LastKey = "Q") then
If (status = True) then
penWidth = penWidth - 1
GraphicsWindow.PenWidth = penWidth
Else
clearWidth = clearWidth - 1
GraphicsWindow.PenWidth = clearWidth
EndIf
EndIf
If (GraphicsWindow.LastKey = "W") then
If (status = True) then
penWidth = penWidth + 1
GraphicsWindow.PenWidth = penWidth
Else
clearWidth = clearWidth + 1
GraphicsWindow.PenWidth = clearWidth
EndIf
EndIf
EndSub
Sub OnMouseMove
x = GraphicsWindow.MouseX
y = GraphicsWindow.MouseY
If (Mouse.IsLeftButtonDown) then
GraphicsWindow.DrawLine(prevX, prevY, x, y)
endif
prevX = x
prevY = y
EndSub
提示:GraphicsWindow.LastKey属性中的D0到D9指数字键。
Small Basic
11/16/2008 10:25:00 上午