
import win.ui;
/*DSG{{*/
var winform = win.form(text="奔跑的猎豹 (演示无尽滚动的背景)";right=719;bottom=463;border="dialog frame";clipch=1;max=false)
winform.add(
plus={cls="plus";left=0;top=0;right=720;bottom=464;clipch=1;db=1;dl=1;dr=1;dt=1;z=1}
)
/*}}*/
winform.show();
winform.plus.text = "请稍候...";
// 加载背景图
import inet.http;
var bgImg = gdip.bitmap("https://cdn.vectorstock.com/i/500p/69/58/cartoon-seamless-nature-landscape-vector-7566958.jpg");
var animalImg = gdip.bitmap("https://www.icegif.com/wp-content/uploads/cheetah-running-icegif-8.gif");
winform.plus.text = "";
var bgX = 0; //动态的图片left坐标
var speed = 15; // 移动速度
winform.plus.onDrawBackground = function(graphics,rc,backgroundColor,foregroundColor){
var winW = rc.width();
var winH = rc.height();
graphics.pixelOffsetMode = 4/*_PixelOffsetModeHalf*/;
graphics.interpolationMode = 1/*_InterpolationModeLowQuality*/;
// 画两个背景图()
graphics.drawImageRect(bgImg, bgX, 0, winW, winH);
graphics.drawImageRect(bgImg, bgX + winW, 0, winW, winH);
//画猎豹
var centerX = (winW-animalImg.width)/2;
graphics.fastDrawBitmap(animalImg, centerX, winH-200);
graphics.fastDrawBitmap(animalImg, centerX-animalImg.width, winH-200);
// 更新位移
bgX -= speed;
// 如果第一张图完全移出左侧边界,重置坐标
if (bgX <= -winW) {
bgX += winW;
}
return true;
}
winform.setInterval(
function(){
winform.plus.redraw();
return animalImg.eachFrame()() * 3;
},16
)
win.loopMessage();