我使用拼贴,这样元素就会放在盒子的中间。
import Graphics.Element exposing (show)
import Graphics.Collage exposing (collage)
textBox =
show "hello world"
main =
collage 1000 1000 [textBox]但在最后一行中有一个类型匹配错误,
Graphics.Element.Element
Graphics.Collage.Form因为,show函数返回Element,而collage只接受Form。我还可以使用什么其他函数来将文本内容定位在collage的中间
发布于 2015-07-26 13:39:53
可以使用Graphics.Collage.toForm将元素转换为窗体。
toForm : Element -> Formhttp://package.elm-lang.org/packages/elm-lang/core/2.1.0/Graphics-Collage#toForm
你的程序很简单
main = collage 1000 1000 [toForm textBox]发布于 2015-07-26 15:01:30
grumpyjames的回答是正确的,将Element转换为Form,将它们放在拼贴纸上。我只想指出,您不需要使用拼贴来将Element放在中间。Graphics.Element包有一个与拼贴类似的容器函数,但使用的是Element而不是Form。所以你也可以:
import Graphics.Element exposing (..)
main =
container 1000 1000 middle (show "Hello, World!")https://stackoverflow.com/questions/31636897
复制相似问题