A backend agnostic ruby framework for building reactive desktop applications
Find a file
Sean Gregory d2999649a5
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
Merge pull request '0.1.8' (#9) from feature/di into main
Reviewed-on: #9
2025-05-18 14:44:20 +00:00
ast feat(windows support): Adds windows support 2025-03-25 10:19:20 -04:00
ext fix(compilation): Fixes compilation on windows and linux 2025-05-18 10:39:39 -04:00
grammar Fixup build scripts 2025-01-19 05:09:07 -05:00
ui refactor(spec): refactor providers spec 2025-05-18 10:39:39 -04:00
vendor Initial Commit 2024-11-21 12:40:30 -05:00
.gitignore Adds documentation 2025-03-10 21:26:18 -04:00
.rspec Initial Commit 2024-11-21 12:40:30 -05:00
.woodpecker.yml Fixup build scripts 2025-01-19 05:09:07 -05:00
.yardopts Adds documentation 2025-03-10 21:26:18 -04:00
Dockerfile Merge pull request 'Moves clamping and text logic to C' (#1) from clamping into main 2024-12-25 15:39:36 -05:00
docs.sh Adds documentation 2025-03-10 21:26:18 -04:00
Gemfile fix(dependencies): Removes colorize until license incompatibility is resolved 2025-05-10 02:13:18 -04:00
Gemfile.lock fix(dependencies): Removes colorize until license incompatibility is resolved 2025-05-10 02:13:18 -04:00
hokusai.gemspec fix(gemspec): fixes license and deps 2025-05-18 10:39:39 -04:00
LICENSE docs(license): changes to MIT license 2025-05-10 14:28:44 -04:00
README.md docs(readme): Updates readme 2025-05-18 10:39:39 -04:00
xmake.lua Fixup build scripts 2025-01-19 05:09:07 -05:00

Hokusai

A Ruby library for authoring GUI applications

status-badge guides docs license

Getting started

In your Gemfile

gem "hokusai-zero",  "0.1.8"

In order to run an application, you will need to install a backend

Raylib

  • Install raylib >= 5.0
  • Write your app
  • Run app with RAYLIB_PATH=/libpath/for/libraylib.(so|dylib) ruby <your app>.rb

SDL2

Example counter application

require "hokusai"
require "hokusai/backends/raylib"

class Counter < Hokusai::Block
  template <<-EOF
  [template]
    vblock
      hblock
        label {
          :content="count"
          size="130" 
          :color="count_color"
        }
      hblock
        vblock
          label { 
            content="Add"
            @click="increment" 
          }
        vblock
          label { 
            content="Subtract"
            @click="decrement" 
          }
  EOF

  uses(
    vblock: Hokusai::Blocks::Vblock,
    hblock: Hokusai::Blocks::Hblock,
    label: Hokusai::Blocks::Label,
  )

  attr_accessor :count

  def increment(event)
    self.count += 1
  end

  def decrement(event)
    self.count -= 1
  end

  def count_color
    self.count > 0 ? [0,0,255] : [255,0,0]
  end

  def initialize(**args)
    @count = 0

    super(**args)
  end
end

Hokusai::Backends::RaylibBackend.run(Counter) do |config|
  config.width = 500
  config.height = 500
  config.title = "Counter application"
end

Development

The build tooling of this project is xmake. You will need it to compile dependencies and run demos.

Hokusai contains a tree-sitter grammar to parse templates, and uses md4c to parse markdown.

When compiling the C portion of hokusai, tree-sitter will be statically linked.

Requirements:

  • xmake to build dependencies
  • Ruby to run applications

Steps:

  • Download project
  • Install dependencies
    • bundle install
    • xmake q hoku-tree-sitter
    • xmake q hoku-md4c
    • For Raylib
      • xmake q raylib
    • For SDL2
      • xmake q libsdl
      • xmake q libsdl_gfx
      • xmake q lbsdl_ttf
      • xmake q libsdl_image
  • Build grammar and ast code
    • xmake b hokusai
  • Run specs
    • xmake b -g test
  • Run a demo
    • xmake demo counter

License

Hokusai is released under the MIT License