PCOPY
- 来源: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgPcopy
- 最后更新: 2023-07-09
将一个图形或文本页面复制到另一个页面
语法
declare function Pcopy ( byval source as long = -1, byval destination as long = -1 ) as long用法
Pcopy [ source ] [, destination ]参数
source
要复制的源页面
destination
目标页面
返回值
成功时返回零(0),失败时返回非零错误代码。
说明
将一个图形或文本视频页面复制到另一个页面。可用于在一个不可见的页面上绘制所有图形,然后将其复制到活动可见页面——实现平滑的图形和动画。这被称为"双缓冲"或"页面翻转"。
source 和 destination 指页面编号。调用 pcopy 时,"源"页面被复制到"目标"页面上。
如果省略 source 参数,假定为当前工作页面。如果省略 destination 页面,假定为当前可见页面。
如果 destination 页面被锁定,Pcopy 不起作用。
Pcopy 返回的错误代码可以在下一行使用 Err 检查。Pcopy 的函数版本直接将错误代码作为 32 位 Long 返回。
示例
start GeSHi
vb
'Sets up the screen to be 320x200 in 8-bit color with 2 video pages.
ScreenRes 320, 200, 8, 2
'Sets the working page to 1 and the displayed page to 0
ScreenSet 1, 0
'Draws a circle moving across the top of the screen
For x As Integer = 50 To 269
Cls 'Clears the screen so we can start fresh
Circle (x, 50), 50, 14 'Draws a yellow circle with a 50 pixel radius on page 1
PCopy 1, 0 'Copies our image from page 1 to page 0
Sleep 25 'Waits for 25 milliseconds.
Next x
'Wait for a keypress before the screen closes
Sleepend GeSHi
start GeSHi
vb
'' Compile with -lang fblite or qb
#lang "fblite"
'' Console mode example:
'' Set the working page number to 0, and the visible page number to 1
#if __FB_LANG__ = "QB"
Screen ,, 0, 1
#else
Screen , 0, 1
#endif
Dim As Integer i, frames, fps
Dim As Double t
t = Timer
Do
'' Fill working page with a certain color and character
Cls
Locate 1, 1
Color (i And 15), 0
Print String$(80 * 25, Hex$(i, 1));
i += 1
'' Show frames per second
Color 15, 0
Locate 1, 1
Print "fps: " & fps,
If Int(t) <> Int(Timer) Then
t = Timer
fps = frames
frames = 0
End If
frames += 1
'' Copy working page to visible page
PCopy
'' Sleep 50ms per frame to free up cpu time
Sleep 50, 1
'' Run loop until the user presses a key
Loop Until Len(Inkey$)end GeSHi
平台差异
- Windows 上文本页面的最大数量为 4。
- DOS 上文本页面的最大数量为 8。
- 所有其他目标上文本页面的最大数量为 1。
- 图形页面的最大数量取决于调用
Screen (Graphics)或Screenres语句时的指定值。
与 QB 的区别
- 无
另请参阅
ScreencopyFlipScreen (Graphics)
返回 目录