''设置屏幕并填充背景颜色
ScreenRes 320, 200, 32
Paint (0, 0), RGB(64, 128, 255)
''设置一个图像并绘制一些东西
Dim img As Any Ptr = ImageCreate( 32, 32, RGB(255, 0, 255) )
Circle img, (16, 16), 15, RGB(255, 255, 0), , , 1, f
Circle img, (10, 10), 3, RGB( 0, 0, 0), , , 2, f
Circle img, (23, 10), 3, RGB( 0, 0, 0), , , 2, f
Circle img, (16, 18), 10, RGB( 0, 0, 0), 3.14, 6.28
''将图像置于屏幕中央
Put (160 - 16, 100 - 16), img, Trans
''释放图像内存
ImageDestroy img
''等待按键
Sleep
Declare Function checkered_blend( ByVal src As UInteger, ByVal dest As UInteger, ByVal param As Any Ptr ) As UInteger
Screen 14, 32 ''设置320 * 240 * 32 gfx模式
Dim As Any Ptr sprite
Dim As Integer counter = 0
sprite = ImageCreate( 32, 32 ) ''为32x32精灵赋值内存
Line sprite, ( 0, 0 )-( 31, 31 ), RGBA(255, 0, 0, 64), bf ''画一个精灵...
Line sprite, ( 4, 4 )-( 27, 27 ), RGBA(255, 0, 0, 192), bf
Line sprite, ( 0, 0 )-( 31, 31 ), RGB(0, 255, 0), b
Line sprite, ( 8, 8 )-( 23, 23 ), RGBA(255, 0, 255, 64), bf
Line sprite, ( 1, 1 )-( 30, 30 ), RGBA(0, 0, 255, 192)
Line sprite, ( 30, 1 )-( 1, 30 ), RGBA(0, 0, 255, 192)
Cls
Dim As Integer i : For i = 0 To 63 ''画背景
Line( i,0 )-( i,240 ), RGB( i * 4, i * 4, i * 4 )
Next i
''演示所有绘图方法...
Put( 8,14 ), sprite, PSet
Put Step( 16,20 ), sprite, PReset
Put Step( -16,20 ), sprite, And
Put Step( 16,20 ), sprite, Or
Put Step( -16,20 ), sprite, Xor
Put Step( 16,20 ), sprite, Trans
Put Step( -16,20 ), sprite, Alpha, 96
Put Step( 16,20 ), sprite, Alpha
Put Step( -16,20 ), sprite, add, 192
Put Step( 16,20 ), sprite, Custom, @checkered_blend, @counter
''打印每个演示附近的描述
Draw String (100, 26), "< - pset"
Draw String Step (0, 20), "< - 预设"
Draw String Step (0, 20), "< - 和"
Draw String Step (0, 20), "<- or"
Draw String Step (0, 20), "< - xor"
Draw String Step (0, 20), "< - trans"
Draw String Step (0, 20), "< - alpha(uniform)"
Draw String Step (0, 20), "< - alpha(每像素)"
Draw String Step (0, 20), "< - 添加"
Draw String Step (0, 20), "< - 自定义"
ImageDestroy( sprite ) ''为sprite免费赋值内存
Sleep : End 0
''定制搅拌机功能:方格放置
Function checkered_blend( ByVal src As UInteger, ByVal dest As UInteger, ByVal param As Any Ptr ) As UInteger
Dim As Integer Ptr counter
Dim As UInteger pixel
counter = Cast(Integer Ptr, param)
pixel = IIf(((*counter And 4) Shr 2) Xor ((*counter And 128) Shr 7), src, dest)
*counter += 1
Return pixel
End Function