A Ruby library for authoring GUI applications
Getting started
In your Gemfile
gem "hokusai-zero", "0.1.7"
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
-
Install the following deps
-
Write your app
-
Run app with
SDL_PATH=/libpath/for/libsdl.(so|dylib) ruby <your app>.rb
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
- For SDL2
xmake q libsdl
xmake q libsdl_gfx
xmake q lbsdl_ttf
xmake q libsdl_image
- Build grammar and ast code
- Run specs
- Run a demo
License
Hokusai is released under the Peer Production License