首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >简单图形生成器[Haste]

简单图形生成器[Haste]
EN

Stack Overflow用户
提问于 2013-10-31 18:37:22
回答 1查看 282关注 0票数 1

有没有人能帮我一下?我有点卡住了,不知道为什么会收到这个错误消息:不在作用域类型构造函数或类'Point‘中

代码语言:javascript
复制
--import Haste hiding (eval)
--import Haste.Graphics.Canvas
import Data.Maybe
import Expr

-- calculates all points of the graph in pixels
points :: Expr -> Double -> (Int,Int) -> [Point]
points exp sca (w,h) = [(x,realToPix(eval exp(pixToReal x))) | x<- [0..w]]      
 where        
   pixToReal :: Int -> Double 
   pixToReal x = sca*((fromIntegral x)-(fromIntegral w)/2) 
   realToPix :: Double -> Int 
   realToPix x = round ((x/sca) + ((fromIntegral w)/2))        

-- calculates the lines that are going to be drawn between the points
linez :: Expr -> Double -> (Int,Int) -> [(Point,Point)]
linez exp sca (w,h) = zip (points exp sca (w,h)) (drop 1 (points exp sca (w,h)))

-- width and height of the window
sizeX, sizeY :: Int
sizeX = 300
sizeY = 300

  --main :: IO ()
  --main = do 
  --Just can <- getCanvasById "canvas" 
  --Just canElem <- elemById "canvas" 
  --Just func <- elemById "formula" 
  --Just d <- elemById "draw" 
  --onEvent d OnClick $ \_ (x,y) -> do 
      --f <- getProp func "value" 
      --w <- getProp canElem "width" 
      --h <- getProp canElem "height" 
      --render can (stroke (path (points (fromJust (readExpr f)) 0.04 (read w,read h))))
  --return()                             
EN

回答 1

Stack Overflow用户

发布于 2013-10-31 20:12:20

您必须导入为"Point“定义类型别名的"Haste.Graphics.Canvas”。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/19704197

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档