Full credit to naknomum who created the original JS version. I just converted it to java with a little AI assistance.
A solacon is a variation of an identicon, in the form of a solar/spiral/floral shape. This is also known as a "visual hash".
The solacon is seeded with a value (string) which determines the shape, symmetry, and shades of the image.
The SVG file contains all the javascript needed to generate the content, so one only needs to set attributes (e.g. data-value
) on the object
that is embedding the svg.
Original javascript demo: Try out some dynamical examples of solacons in action.
Java implementation looks identical
val solaconGenerator = Solacon()
solacon = view.findViewById(R.id.solacon)
solacon.setOnClickListener { view ->
val hash = java.util.UUID.randomUUID().toString()
val size = 512 // desired size of the identicon in pixels
//3rd parameter is an optional color, must be formatted: "#XXXXXX"
val solaconBitmap = solaconGenerator.generateBitmap(hash, size)
solacon.setImageBitmap(solaconBitmap)
}
solacon.performClick()
For related work, check out Awesome Identicons, a curated list of visual hashes maintained by Husam ABBOUD.