MyNixOS website logo
Description

A SDL2-based graphics library, batteries-included.

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

Basic concepts and features:

  • Figure: convenient SDL texture, once created, it can be translated or rotated during rendering.

  • Component: a reusable widget with event handlers, its figures can also be cached.

  • Hot Config Replacement: view components can be constructed by an external yaml file with live preview.

  • built-in components: some common components are predefined. You can define a new component by yourself.

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

For ghc-8.8, use a version >= 0.4.3

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.

Metadata

Version

0.5.0

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows