Skip to content

Instantly share code, notes, and snippets.

@tompng
Last active November 10, 2024 21:29
Show Gist options
  • Save tompng/ea75023be5e42318c8b7a97d3574a178 to your computer and use it in GitHub Desktop.
Save tompng/ea75023be5e42318c8b7a97d3574a178 to your computer and use it in GitHub Desktop.
srand 0
6.times do |index|
fg = "##{3.times.map{"%02x" % rand(0..100)}.join}"
bg = "##{3.times.map{"%02x" % rand(150..255)}.join}"
face = :"face#{index}"
Reline::Face.config(face) do
_1.define(:default, foreground: fg, background: bg)
end
pointClass = Data.define :x, :y
prev = nil
Reline.add_dialog_proc :"dialog#{index}", ->{
x, y, w, h, s = prev = prev && rand < 0.8 ? prev : [rand(40), rand(20), rand(10..18),rand(5..9), ["Dialog#{index} ", "#{index} "].sample]
s = ["Dialog#{index} ", "#{index} "].sample if rand < 0.3
contents = h.times.map do |y|
w.times.map do |x|
ix = x==0 ? 0 : x==w-1 ? 2 : 1
iy = y==0 ? 0 : y==h-1 ? 2 : 1
next '╭─╮│ │╰─╯'[ix+3*iy] if ix!=1||iy!=1
s[(x+4-y*5)%s.size]
end.join
end
Reline::DialogRenderInfo.new(
pos: pointClass.new(x:, y:),
contents: contents,
height: 10,
face: face
)
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment