Python的簡潔矢量圖形工具:Gizeh

jopen 10年前發布 | 43K 次閱讀 Gizeh Python開發

Gizeh是一個用于Python的簡潔矢量圖形工具。

# Let's draw a red circle !
import gizeh
surface = gizeh.Surface(width=320, height=260) # in pixels
circle = gizeh.circle(r=30, xy= [40,40], fill=(1,0,0))
circle.draw(surface) # draw the circle on the surface
surface.write_to_png("circle.png") # export the surface as a PNG

Gizeh在 cairocffi 模塊的基礎上編寫,它是常用C語言庫Cairo的一個Python綁定。Cairo雖然強大,但難于學習和使用。Gizeh在Cairo基礎上實現一些類,它其更加直觀。

import gizeh

initialize surface

surface = gizeh.Surface(width=320, height=260) # in pixels

Now make a shape and draw it on the surface

circle = gizeh.circle(r=30, xy= [40,40], fill=(1,1,1)) circle.draw(surface)

Now export the surface

surface.get_npimage() # returns a (width x height x 3) numpy array surface.write_to_png("circle.png")</pre>

項目主頁:http://www.baiduhome.net/lib/view/home/1414721846481

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!