我有一些代碼可以檢測點擊拖動動作的開始和結束點,並將其保存到2個vector2點。然後,我使用此代碼進行轉換: public Rectangle toRect(Vector2 a, Vector2 b)
{
return new Rectangle((int)a.X, (int)a.Y, (int)(b.X - a.X), (int)(b.Y - a.Y));
}
上面的代碼不起
嘿所以我目前正在使用這篇文章在畫布上創建矩形,並且徘徊如何讓繪製的矩形比實際記錄的矩形大2px。這是可能的,如果是這樣的話,我會如何做到這一點,一直試圖解決它現在將是真正有用的最終有一個解決方案。 Point startPos; // mouse-down position
Point currentPos; // current mouse position
bool drawing;
import java.awt.Rectangle;
public class AddTester {
public static void main(String[] args) {
Rectangle box = new Rectangle(5, 10, 20, 30);
System.out.println(box);
//output: jav