scripts/gen_artifacts.cr @ trunk
../src/gpcr/render
scale = 0.75 fontscale = 1.500 box wid 2.343 ht 0.340 with .nw at (0.035, -0.035) fill 0xCBD5E1 color 0xCBD5E1 box wid 2.343 ht 0.340 with .nw at (0.000, 0.000) fill 0x7C83E6 color 0x7C83E6 box wid 0.300 ht 0.065 rad 0.018 at (0.370, -0.022) fill 0xffffff color 0xffffff line from (0.140, 0.000) to (0.140, -0.340) color white line from (2.203, 0.000) to (2.203, -0.340) color white text "require '../src/gpcr/render'" color white at (1.172, -0.170)→ /pikchrshow
crystal source
require "../src/gpcr/render"
json block
{
"kind": "require",
"name": "../src/gpcr/render",
"doc": null,
"children": []
}
../src/gpcr/gallery
scale = 0.75 fontscale = 1.500 box wid 2.353 ht 0.340 with .nw at (0.035, -0.455) fill 0xCBD5E1 color 0xCBD5E1 box wid 2.353 ht 0.340 with .nw at (0.000, -0.420) fill 0x7C83E6 color 0x7C83E6 box wid 0.300 ht 0.065 rad 0.018 at (0.370, -0.443) fill 0xffffff color 0xffffff line from (0.140, -0.420) to (0.140, -0.760) color white line from (2.213, -0.420) to (2.213, -0.760) color white text "require '../src/gpcr/gallery'" color white at (1.177, -0.590)→ /pikchrshow
crystal source
require "../src/gpcr/gallery"
json block
{
"kind": "require",
"name": "../src/gpcr/gallery",
"doc": null,
"children": []
}
GALLERY_SRC = File.read(File.join(__DIR__, "..", "src", "gpcr", "gallery.cr"))
BLINK_SRC = File.read(File.join(__DIR__, "..", "examples", "blink.cr"))
OUT_DIR = File.join(__DIR__, "..", "artifacts", "dual-design")
Dir.mkdir_p(OUT_DIR)
# Reflect all @[GPCR::Primitive]/@[GPCR::Block] faces from the compiled program
# (std.cr + gallery.cr + draw.cr + render.cr etc.) so blocks render with full
# faces: correct shapes, labels, slot pills, and category colors.
FACES = GPCR.blocks_of
def extract_pikchr_fences(md : String) : String
fences = [] of String
md.scan(/```pikchr[^\n]*\n(.*?)```/m) { |m| fences << m[1] }
fences.join("\n")
end
["microblocks-compact", "blockly-zelos"].each do |ts_name|
["gallery", "blink"].each do |src_name|
src = src_name == "gallery" ? GALLERY_SRC : BLINK_SRC
GPCR::Tokens.use(ts_name)
md = render_source(src, nil, FACES, ts_name)
pikchr = extract_pikchr_fences(md)
out_path = File.join(OUT_DIR, "#{src_name}-#{ts_name}.pikchr")
File.write(out_path, pikchr)
puts "wrote #{out_path} (#{pikchr.lines.size} lines)"
end
end