在下面的程序中,我使用cairo-0.12.2
. 不幸的是,当我使用该translate
函数移动用户空间原点时,矩形被翻译但文本没有。
import Graphics.Rendering.Cairo
main = withSVGSurface "test.svg" 600 600
(`renderWith` draw)
draw = do
color white
rectangle 0 0 600 600
fill
newPath
color black
translate 300 300
drawSortBox
translate 200 200
drawSortBox
stroke
drawSortBox = do
showText "V Ʌ"
a <- textExtents "V Ʌ"
rectangle (textExtentsXbearing a - 2) (textExtentsYbearing a - 2) (textExtentsWidth a / 2 + 2) (textExtentsHeight a + 4)
rectangle (textExtentsXbearing a - 2) (textExtentsYbearing a - 2) (textExtentsWidth a + 4) (textExtentsHeight a + 4)
color (a,b,c) = setSourceRGB a b c
white = (255,255,255)
black =(0,0,0)