MozTW 討論區

各項 Mozilla 相關軟體與技術討論
現在的時間是 2025-08-27, 00:55

所有顯示的時間為 UTC + 8 小時





發表新文章 回覆主題  [ 2 篇文章 ] 
發表人 內容
 文章主題 : 请教cairo的问题
文章發表於 : 2009-09-19, 02:27 
離線

註冊時間: 2009-09-19, 02:09
文章: 1
有个问题困扰我很久, 用cario画线怎样能画出只用一个像素的水平线或垂直线?我设置cairo_line_width为1也没用,我只是想画一条纯粹的线,比如(0, 0) - (300, 0) 我发现画出来的水平线高度始终最也要占用两个像素


回頂端
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6; .NET CLR 2.0.50727; CIBA; TheWorld)
 個人資料  
引用回覆  
 文章主題 : Re: 请教cairo的问题
文章發表於 : 2009-09-30, 23:21 
離線

註冊時間: 2006-08-12, 20:34
文章: 24
來自: 台中,台灣
剛好在某個 maillist 看到這篇文章,可以解答您的問題

http://www.daa.com.au/pipermail/pygtk/2008-September/015991.html

摘錄如下:

Jeffrey Drake wrote:
> In my code below, I set a line width of 1 and then when I go to draw a
> grid, what appears is an antialiased line of still width of 2. I need a
> single pixel, not the ugly 2 width beast as shown before.
>
> The problem is when drawing the horizontal grid below.
>
> Any ideas on how to fix this?

Add (or subtract) 0.5 to the x and y of your line endpoints.

In cairo, the top left pixel is a rectangle from (0,0) to (1,1). The
top left corner is (0,0) and the bottom right corner is (1,1). If you
have a 1-pixel wide line from (10,10) to (100,10) only half of that
1-pixel is in the 10th row, the other half being in the 9th row. Cairo
renders this by antialiasing, so you get a 2-pixel side 50% gray line
rather than the 1-pixel black line you were expecting.

--
Tim Evans
Applied Research Associates NZ
http://www.aranz.com/


回頂端
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.3) Gecko/20090910 Ubuntu/9.04 (jaunty) Shiretoko/3.5.3
 個人資料  
引用回覆  
顯示文章 :  排序  
發表新文章 回覆主題  [ 2 篇文章 ] 

所有顯示的時間為 UTC + 8 小時


誰在線上

正在瀏覽這個版面的使用者:沒有註冊會員 和 15 位訪客


不能 在這個版面發表主題
不能 在這個版面回覆主題
不能 在這個版面編輯您的文章
不能 在這個版面刪除您的文章
不能 在這個版面上傳附加檔案

搜尋:
前往 :  
Powered by phpBB® Forum Software © phpBB Group
正體中文語系由 竹貓星球 維護製作
© moztw.org, Mozilla Foundation
MozTW,Mozilla 台灣社群