Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New features: form, settings, GET variables, history, PNG and SVG downloads #3

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
server-script/*.csv
server-script/*.log
server-script/*.png
server-script/*.svg
server-script/index.conf.php
server-script/solacon.conf.sh
65 changes: 47 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
# solacon
# About Solacon

A *solacon* is a variation of an [identicon](https://en.wikipedia.org/wiki/Identicon), in the form of a solar/spiral/floral shape.
This is also known as a "visual hash".
A *solacon* is a variation of an [identicon](https://en.wikipedia.org/wiki/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.
## Examples

![Solacon.svg](Solacon.svg.png "Solacon.svg")
![Solacon examples](screenshots/solacon-examples.png)

## Example
## Form

Try out some [dynamical examples](https://naknomum.github.io/solacon-example/) of **solacons** in action.
The HTML file contains a form allowing to customize the image generation:

- **Random color:** If checked, a new color will be used for each image generation.
- **Background:** We can choose between no background (image with transparency), a white background or a colored background (shade of the main colour).
- **String:** If filled, the string will be used to generate the solacon. If empty, a random string will be used.

## Usage
At the end of the form, there are buttons to generate a new image or to download the solacon in PNG or SVG format.

```javascript
<object type="image/svg+xml" style="width: 500px; height: 500px;" id="svg-obj"
data="solacon.svg"
data-value="Hello world."
data-rgb="0, 30, 255"
></object>
![Solacon form](screenshots/solacon-form.png)

## GET variables

The image generation can also be customised using GET variables in the URL. Here is the list of all variables that can be used:

- `string=TEXT` where `TEXT` is the string used to generate the solacon. Example: `string=lorem`.
- `color=COLOR` where `COLOR` is the color of the solacon. Hex colors and RGB colors can be used. Examples: `color=#326496`, `color=326496`, `color=50,100,150`, `color=rgb(50,100,150)`.
- `background=TYPE` where `TYPE` is `white` or `colored`.
- `size=SIZE` where `SIZE` is the width and height in px. Example: `size=512`.
- `download=TYPE` where `TYPE` is `png` or `svg`. The image download will start automatically without having to click on the download button.

Examples:

- `index.html?string=hujMdpAtoaDztvZ&color=b079b4`
- `index.html?string=Lorem%20Ipsum&color=326496&background=white&download=png`

## JavaScript

The parent document can alter the solacon:

// the parent document can alter the solacon
```javascript
var svgObj = document.getElementById('svg-obj');
svgObj.setRGB('100, 150, 200');
svgObj.generate('some new value');
Expand All @@ -35,9 +49,24 @@ svgObj.setRGBFromHash(); // color is based off hashValue (default behavior)
svgObj.refresh(); // applies color change to current shape
```

## Server script

The file `server-script/solacon.sh` illustrates how to get solacon images on a server, without user interaction.

Run `solacon.sh -h` for more details.

## Live demo

Try out some [dynamical examples](https://misaki-web.github.io/solacon/) of **solacons** in action.

## Similar projects

Another identicon project of mine, [Hexicon.js](https://github.com/naknomum/hexicon).
- [Hexicon.js](https://github.com/naknomum/hexicon): hexagonal identicons
- [Awesome Identicons](https://github.com/drhus/awesome-identicons): a curated list of *visual hashes* maintained by **Husam ABBOUD**

## License

For related work, check out [Awesome Identicons](https://github.com/drhus/awesome-identicons), a curated list of _visual hashes_ maintained by **Husam ABBOUD**.
Copyright (c) 2022 Jon Van Oast <https://github.com/naknomum>
Copyright (C) 2023 Misaki F. <https://github.com/misaki-web>

Released under MIT License. See the file [LICENSE](LICENSE) for more details.
Binary file removed Solacon.svg.png
Binary file not shown.
21 changes: 0 additions & 21 deletions example.html

This file was deleted.

Loading