Class IdenticonRenderer
java.lang.Object
network.ike.docs.koncept.IdenticonRenderer
Renders the Komet identicon for a koncept as a PNG.
The image is byte-identical to the one Komet draws
(dev.ikm.komet.framework.Identicon) because it uses the same
library (com.sparrowwallet:toucan), the same algorithm version
(LifeHashVersion.VERSION2), and the same input string (the
Tinkar idString produced by KonceptIdentity). LifeHash is
a deterministic visual hash: the SHA-256 of the UTF-8 input drives a
cellular-automaton render whose pattern depends only on the input and the
version — moduleSize merely scales pixel density (nearest
neighbour), never the pattern.
VERSION2 produces a 32×32 native grid; at DISPLAY_MODULE_SIZE
that is the 128×128 Komet renders at. Two output forms are provided:
dataUri(String)— a base64data:URI for inline HTML (html5and CSS-PDF backends).pngFile(String)— a PNG written to a content-addressed file, for backends that need a file reference (DocBook→FO, Prawn PDF).
idString.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intModule size for displayed identicons. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringRenders the identicon for anidStringas a base64data:image/pngURI suitable for an inline HTML<img src>.static byte[]Renders the identicon for anidStringas PNG bytes.static StringWrites the identicon for anidStringto a content-addressed PNG file and returns its absolute path.
-
Field Details
-
DISPLAY_MODULE_SIZE
public static final int DISPLAY_MODULE_SIZEModule size for displayed identicons. VERSION2's 32×32 native grid × 4 = 128×128, matching Komet's displayed size.- See Also:
-
-
Method Details
-
png
Renders the identicon for anidStringas PNG bytes.- Parameters:
idString- the TinkaridString(LifeHash input)moduleSize- the per-cell pixel size (must be > 0); the output is32 * moduleSizesquare for VERSION2- Returns:
- the PNG-encoded identicon
- Throws:
UncheckedIOException- if PNG encoding fails
-
dataUri
Renders the identicon for anidStringas a base64data:image/pngURI suitable for an inline HTML<img src>. Memoized peridString.- Parameters:
idString- the TinkaridString(LifeHash input)- Returns:
- a
data:image/png;base64,…URI - Throws:
UncheckedIOException- if PNG encoding fails
-
pngFile
Writes the identicon for anidStringto a content-addressed PNG file and returns its absolute path. Backends that cannot embed adata:URI (DocBook→FO via FOP/XEP, Prawn PDF) reference the file directly; withSafeMode.UNSAFE(used by the doc pipeline) absolute image paths resolve in all of them. The filename is derived from a hash of theidString, so identical concepts share one file and re-runs are stable. Memoized peridString.- Parameters:
idString- the TinkaridString(LifeHash input)- Returns:
- the absolute filesystem path of the written PNG
- Throws:
UncheckedIOException- if the file cannot be written
-