minilight: A SDL2-based graphics library, batteries-included.

[ graphics, library, mit, program ] [ Propose Tags ]

This package provides the wheel for a graphical application or a game.

Basic concepts and features:


[Skip to Readme]
Versions [faq] 0.1.0, 0.1.1, 0.2.0, 0.3.0, 0.4.0
Change log CHANGELOG.md
Dependencies aeson (>=1.4.2 && <1.5), aeson-diff (>=1.1.0 && <1.2), base (>=4.12.0 && <4.13), caster (>=0.0.2.0 && <0.1), containers (>=0.6.0 && <0.7), exceptions (>=0.10.1 && <0.11), FontyFruity (>=0.5.3 && <0.6), fsnotify (>=0.3.0 && <0.4), hashable (>=1.2.7 && <1.3), hashtables (>=1.2.3 && <1.3), lens (==4.17.*), linear (>=1.20.8 && <1.21), microlens, minilight, mtl (>=2.2.2 && <2.3), mwc-random (>=0.14.0 && <0.15), scientific (>=0.3.6 && <0.4), sdl2 (>=2.4.1 && <2.5), sdl2-gfx (==0.2.*), sdl2-image (>=2.0.0 && <2.1), sdl2-ttf (>=2.1.0 && <2.2), template-haskell (>=2.14.0 && <2.15), text (>=1.2.3 && <1.3), transformers (>=0.5.6 && <0.6), trifecta (>=2 && <2.1), unordered-containers (>=0.2.10 && <0.3), uuid (>=1.3.12 && <1.4), vector (>=0.12.0 && <0.13), yaml (>=0.11.0 && <0.12) [details]
License MIT
Author myuon
Maintainer ioi.joi.koi.loi@gmail.com
Category Graphics
Source repo head: git clone https://github.com/myuon/minilight.git
Uploaded by myuon at Sat Jun 1 07:43:08 UTC 2019
Distributions NixOS:0.4.0
Executables boids, button-counter
Downloads 234 total (41 in the last 30 days)
Rating (no votes yet) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user
Build status unknown [no reports yet]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for minilight-0.4.0

[back to package description]

minilight

CircleCI Hackage MIT license

A simple but powerful graphics library.

NB: This library is fairly unstable and highly experimental.

Build

You first need to install sdl2 packages.

For Ubuntu 18.04:

~$ sudo apt install -y libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-gfx-dev

Tutorial

Create a new project. Assume that you have the resource directory under the project root, which contains the resource stuff.

Here is an example, specifying resources/app.yml for the configuration file and resources for the watching directory (dynamic hot reloading).

import Control.Monad
import Data.Component.Resolver (resolver)
import MiniLight

main :: IO ()
main = runLightT $ do
  runMiniloop
    ( defConfig { appConfigFile        = Just "resources/app.yml"
                , hotConfigReplacement = Just "resources"
                , componentResolver    = resolver
                }
    )
    ()
    return

In resources/app.yml, you can write your application configuration.

_vars:
  window:
    width: 800
    height: 600
app:
  - name: layer
    properties:
      image: resources/background.png
      position:
        x: 0
        y: 0
  - name: message-layer
    properties:
      window:
        image: resources/window-base.png
        position:
          x: 0
          y: ${${var:window.height} - ${ref:..size.height}}
        size:
          width: ${var:window.width}
          height: 150
      next:
        image: resources/text-pause.png
        division:
          x: 1
          y: 6
        interval: 40
      engine:
        messages: This is a message.
        color: [255,255,255,255]
        font:
          family: IPAGothic
          size: 22

For the configuration syntax, see MiniLight.Loader.

For the pre-defined components, see the modules under Data.Component.

Examples

See examples