Elm 0.17 中的图像
images in Elm 0.17
我正在尝试使用单个图像的测试示例:
import Html exposing (Html)
import Graphics.Element
main = image 960 500 "starry-night.jpg"
我正在使用 elm-reactor 进行尝试,但这个简单的结果无法编译:
I cannot find module 'Graphics.Element'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
我尝试导入必要的图形包,evancz/elm-graphics
john@me:~/Documents/Elm$ cat elm-package.json
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.1 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0",
"elm-lang/svg": "1.0.0 <= v < 2.0.0",
"evancz/elm-graphics": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
我想出了:
import Html exposing (Html)
import Element exposing (image, toHtml)
main = toHtml ( image 960 500 "starry-night.jpg" )
模块的名称是Element
,不是Graphics.Element
,所以编译器找不到它。
此外,image
函数 returns 和 Element
,而 main
函数需要 Html
类型的东西。
您的程序的 运行 版本可能类似于
import Element exposing (..)
main =
toHtml (image 960 500 "starry-night.jpg")
我正在尝试使用单个图像的测试示例:
import Html exposing (Html)
import Graphics.Element
main = image 960 500 "starry-night.jpg"
我正在使用 elm-reactor 进行尝试,但这个简单的结果无法编译:
I cannot find module 'Graphics.Element'.
Module 'Main' is trying to import it.
Potential problems could be:
* Misspelled the module name
* Need to add a source directory or new dependency to elm-package.json
我尝试导入必要的图形包,evancz/elm-graphics
john@me:~/Documents/Elm$ cat elm-package.json
{
"version": "1.0.0",
"summary": "helpful summary of your project, less than 80 characters",
"repository": "https://github.com/user/project.git",
"license": "BSD3",
"source-directories": [
"."
],
"exposed-modules": [],
"dependencies": {
"elm-lang/core": "4.0.1 <= v < 5.0.0",
"elm-lang/html": "1.0.0 <= v < 2.0.0",
"elm-lang/svg": "1.0.0 <= v < 2.0.0",
"evancz/elm-graphics": "1.0.0 <= v < 2.0.0"
},
"elm-version": "0.17.0 <= v < 0.18.0"
}
我想出了:
import Html exposing (Html)
import Element exposing (image, toHtml)
main = toHtml ( image 960 500 "starry-night.jpg" )
模块的名称是Element
,不是Graphics.Element
,所以编译器找不到它。
此外,image
函数 returns 和 Element
,而 main
函数需要 Html
类型的东西。
您的程序的 运行 版本可能类似于
import Element exposing (..)
main =
toHtml (image 960 500 "starry-night.jpg")