skinnyjames/hokusai

该项目是一个与后端无关的 Ruby 框架,用于构建响应式桌面应用程序。

20 commits 10 branches 0 tags 4.3 MiB C 53.4% Ruby 43.7% Lua 1.1% JavaScript 0.9% Rust 0.5% Other 0.3% main

下载 ZIP 下载 TAR.GZ 下载 BUNDLE Open with VS Code Open with VSCodium Open with Intellij IDEA

skinnyjames 5380728dd8 Update README.md | 2025-05-09 16:06:59 +00:00

README.md

Hokusai

一个用于编写 GUI 应用程序的 Ruby 库

快速开始

在你的 Gemfile 中添加:

gem "hokusai-zero", "0.1.7"

为了运行应用程序,你需要安装一个后端

Raylib

SDL2

示例计数器应用程序

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

开发

该项目的构建工具是 xmake。 你需要它来编译依赖项和运行演示。 Hokusai 包含一个 tree-sitter 语法来解析模板,并使用 md4c 来解析 markdown。 当编译 Hokusai 的 C 部分时,tree-sitter 将被静态链接。

依赖:

步骤:

许可协议

Hokusai 在 Peer Production License 下发布。 Logo