【问题标题】:Haskell SDL binding: Why doesn't SDL draw a circle here?Haskell SDL绑定:为什么SDL这里不画圈?
【发布时间】:2011-09-03 20:09:04
【问题描述】:

我想使用 Haskell 的 SDL 绑定来绘制简单的对象(三角形、圆形等)。 Graphics.UI.SDL.Video 中有一个用于绘制矩形的函数,可以正常工作。但我无法让我找到的用于绘制其他图元(在 Graphics.UI.SDL.Primitives 中)的函数起作用。以下代码仅绘制一个矩形。有什么我错过的想法吗?

module Main where

import Graphics.UI.SDL as SDL
import Graphics.UI.SDL.Color
import Graphics.UI.SDL.Primitives

main = do
    SDL.init [SDL.InitVideo]
    screen <- SDL.setVideoMode 500 500 32 [SDL.HWSurface]

    SDL.fillRect screen Nothing (SDL.Pixel 0x0000FF) 

    fillRect screen (Just (SDL.Rect 10 10 30 30)) (SDL.Pixel 0x00FF0000)
    filledCircle screen 40 40 50 (SDL.Pixel 0x00FF0000)

    SDL.flip screen

    delay 2000

    SDL.quit

【问题讨论】:

    标签: haskell sdl


    【解决方案1】:

    您赋予填充圆形和填充矩形的像素颜色的 alpha 分量设置为零;试试SDL.Pixel 0x00FF00FF。 fillCircle 似乎尊重颜色的 alpha 分量,而 fillRect 显然没有。

    【讨论】:

      猜你喜欢
      • 2012-08-12
      • 1970-01-01
      • 2013-04-06
      • 1970-01-01
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多