Realm
gno.land/r/moul/gallery/v0
Overview
Realm Path
gno.land/r/moul/gallery/v0
Exported Functions
1
State Entries
4
Source Files
6
Total Package Entries
15
Exported Functions
1 exported function
State
4 state entries
Source Code
FILES
catalog.gno
go
1package gallery
2
3import (
4 "gno.land/r/moul/demo/gnoface/v0"
5 "gno.land/r/moul/demo/millipede/v0"
6 "gno.land/r/moul/sapin/v0"
7)
8
9// piece is one entry in the index.
10//
11// The gallery stores no art. Every piece lives in somebody's realm and this is
12// a pointer to it, which is why there is no package-level state anywhere in
13// this realm and nothing here survives or needs to survive a redeploy.
14type piece struct {
15 Slug string
16 Title string
17 Author string
18 Origin string // realm path, without the gno.land prefix
19 License string
20 Note string
21
22 // Draw renders the piece live, by importing its source. It is nil when the
23 // source cannot be imported, which is the honest half of a curated index:
24 // a private realm or a package this repo has not vendored can be pointed
25 // at but not shown.
26 Draw func() string
27}
28
29// Live reports whether this realm can render the piece itself.
30func (p piece) Live() bool { return p.Draw != nil }
31
32// catalog is built per call rather than held in a package-level var: a func
33// value is not something to persist, and a realm that stores nothing should
34// not be paying storage for its own index.
35func catalog() []piece {
36 return []piece{
37 {
38 Slug: "gnoface",
39 Title: "gnoface",
40 Author: "moul",
41 Origin: "r/moul/demo/gnoface/v0",
42 License: "see the source realm",
43 Note: "A face generated from a seed. Every seed is a different face, and none of them are stored.",
44 Draw: func() string { return gnoface.Draw(42) },
45 },
46 {
47 Slug: "millipede",
48 Title: "millipede",
49 Author: "moul",
50 Origin: "r/moul/demo/millipede/v0",
51 License: "see the source realm",
52 Note: "A millipede of any length. The oldest piece here, and still the one that best explains why ASCII is the cheapest picture there is.",
53 Draw: func() string { return millipede.Draw(8) },
54 },
55 {
56 Slug: "sapin",
57 Title: "sapin",
58 Author: "moul",
59 Origin: "r/moul/sapin/v0",
60 License: "see the source realm",
61 Note: "A fir tree, sized on request.",
62 Draw: func() string { return sapin.Sapin(6) },
63 },
64 {
65 Slug: "settler25",
66 Title: "Settler #25",
67 Author: "the Settlers",
68 Origin: "r/g17khqpukees4237dtn3astzapmp462vjhsz6st4/settlers/nft",
69 License: "CC0 1.0",
70 Note: "moul's, soulbound, minted at block 409242. A 32x32 indexed sprite with 20 colours, which is what made it the test case for p/moul/art: a luminance ramp resolves those 20 to 9, and keying on the palette index keeps all 20.",
71 },
72 {
73 Slug: "asciiart",
74 Title: "asciiart",
75 Author: "moul",
76 Origin: "r/moul/x/daily/asciiart/v1",
77 License: "see the source realm",
78 Note: "Patterns from short deterministic algorithms, plus everyone's generations. Declared private = true, so it can be linked but never imported: that is the constraint, not an omission.",
79 },
80 {
81 Slug: "pixelcanvas",
82 Title: "pixelcanvas",
83 Author: "moul",
84 Origin: "r/moul/x/daily/pixelcanvas/v0",
85 License: "see the source realm",
86 Note: "A shared grid anyone can paint one pixel of.",
87 },
88 }
89}
90
91func find(slug string) (piece, bool) {
92 for _, p := range catalog() {
93 if p.Slug == slug {
94 return p, true
95 }
96 }
97 return piece{}, false
98}
99Raw Package Data
Raw JSON data