[問題] 關於畫橢圓fillOval

看板java作者 ( )時間15年前 (2010/10/10 09:32), 編輯推噓2(205)
留言7則, 5人參與, 最新討論串1/1
林邦傑"如何設計Java程式"書上是 fillOval(int x, int y, int width, int height) 其中(x,y)是中心座標 但是官網 http://download.oracle.com/javase/7/docs/api/java/awt/Graphics.html 上面的(x,y)則是 "x - the x coordinate of the upper left corner of the oval to be filled. y - the y coordinate of the upper left corner of the oval to be filled." 怎麼會不依樣? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.44.140.54

10/10 09:48, , 1F
做做實驗就知道哪個是對的囉?
10/10 09:48, 1F

10/10 09:51, , 2F
我關心的是演算法。為何先前版本用的是圓心
10/10 09:51, 2F

10/10 09:56, , 3F

10/10 12:21, , 4F
只是書上寫錯了
10/10 12:21, 4F

10/10 12:44, , 5F
請想像一下在長方型中劃一個圓
10/10 12:44, 5F

10/10 21:26, , 6F
官網講得比較正確 因為rec可以接受<0的height width
10/10 21:26, 6F

10/10 21:28, , 7F
但oval不能 一定要用左上的座標 反正就是方框內畫橢圓
10/10 21:28, 7F
文章代碼(AID): #1CiHUM3Q (java)