2012-02-23 106 views
2

如何在開窗鞋上使用開羅塔?開羅和紅寶石鞋

我正在嘗試爲Computer Graphics啓動一個學校項目。任何人都可以發佈一個簡單的代碼,在鞋子窗口上繪製一個圓圈嗎?我會很感激。我一直在尋找相當長的一段時間......我還沒有到達任何地方。所以,請幫助我! :)

回答

2

我不知道如何在Ruby中使用Cairo。這不是我的專業領域;然而,鞋中的畫圈並不難。以下示例允許從鼠標單擊和拖動創建圓圈。

Shoes.app do 
    ox,oy = nil,nil 
    click{|button, x, y| # on click, set the original x and y position 
     if button == 1 
      ox = x 
      oy = y 
     end 
    } 
    release{|button, x, y| #on mouse release, draw the circle 
     if button == 1 
      oval(
       :left => [ox, x].min, # furthest left point 
       :top => [oy, y].min, # furthest top point 
       :radius => ((ox-x).abs + (oy-y).abs)/2 # the average of the positive difference between original and final x and y points 
      ) 
     end 
    } 
end 

很明顯,根據您的具體要求,您需要決定是否足夠好。

根據我的經驗,Shoes是製作各種低至中等功率應用的體面平臺。然而,如果你想要構建一些實質性的東西,比如圖形包,那麼可能會有更好的解決方案。

+0

感謝SimonMayer回答這個問題。這讓我對事情有了一點啓發。但它仍然沒有解決問題。 我研究發現,鞋子也有線條畫功能,我可以使用。但我也需要繪製個別像素。我可以穿鞋嗎?如果沒有,任何其他方式來做到這一點? 謝謝! :) – 2012-02-24 02:17:26

+0

在http://shoesrb.com/tutorials上有一些鞋教程 - 具體來說,第一頁上有一個示例,名爲「Scribble」,它演示了繪製線條。您可能還想查看手冊:http://shoesrb.com/manual/Art.html – SimonMayer 2012-02-24 02:21:44