Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell 为什么';你不能翻译文本吗?_Haskell_Cairo - Fatal编程技术网

Haskell 为什么';你不能翻译文本吗?

Haskell 为什么';你不能翻译文本吗?,haskell,cairo,Haskell,Cairo,在下面的程序中,我使用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 co

在下面的程序中,我使用
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)
import Graphics.Rendering.Cairo
main=withSVGSurface“test.svg”600
(`renderWith`draw)
画=做
白色
矩形0 0 600 600
填满
新路径
黑色
翻译300 300
牵引箱
翻译200
牵引箱
(打、击等的)一下
drawSortBox=do
showText“VɅ”

a根据文档,
showText
从当前位置开始绘制文本<代码>平移
移动原点,但不移动当前位置。您必须使用
moveTo
而不是
translate
来选择文本的位置。(第一次调用时,
translate
恰好起作用的事实与
newPath
删除当前位置有关。)