2
다음 프로그램에서는 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)