//x and y is absolute coordinate of the touchpad//dx and dy is the change in mouse position since the last acquisition// the variables screenX and screenY are the new positions x and y on the screenvar maxScreenX =800; // width Screenvar maxScreenY =300; // height Screenfunction transfer1(x,y,dx,dy){}觸摸板的尺寸為200x200,但我想在屏幕的尺寸上繪制800x300,以便我可以從一端繪制到另一端。我該怎么做?
1 回答

一只名叫tom的貓
TA貢獻1906條經驗 獲得超3個贊
不確定我是否正確理解了這個問題,但我假設你只想將x和y坐標從200x200轉換為800x300。
function transfer1(x,y,dx,dy)
{
dx += x*maxScreenX/200
dy += y*maxScreenY/200
}
這假設幀的中心是,因此值可以是負數,如果不是這種情況,您將需要一些語句來處理遞減[x=0, y=0]if