This is an evolution of my own basic halftone effect using Drawbot.
Drawbot is a macOS powerful tool for creating graphics and animations. It is a great tool for generative art and graphic design. This script uses Drawbot to create a halftone effect from an image.
- Clone this repository.
git clone https://github.com/werls/drawbot-halftone.git
- Change to the repository directory.
cd drawbot-halftone
- Install the requirements.
pip install -r requirements.txt
- Run the script.
python drawbot_halftone.py --path /path/to/image.jpg
Parameter | Type | Description | Default |
---|---|---|---|
--path | string | The path to the image file. | None |
--resolution | int | The resolution of the halftone grid. | 100 |
--contrast | float | The maximum size of the halftone dots. | 1 |
--dot-min-size | float | The minimum size of the halftone dots. | 0 |
--angle | float | The angle of rotation for the halftone grid. | 45 |
--color | string | The color of the halftone dots. | 0,0,0,1 |
--color_mode | string | The color mode of the halftone dots (rgba or cmyk). | rgba |
--honeycomb | bool | Use a honeycomb grid instead of a square grid. | True |
--reescale_image | bool | Reescale the image to fit the canvas default size. | False |
--inverse | bool | Invert the colors of the image. | False |
--preset | string | A JSON string or file path of settings for the halftone effect. | None |
--verbose | bool | Print the settings of the halftone effect. | True |
You can create a JSON file with the settings for the halftone effect. Here is an example:
{
"resolution": 100,
"contrast": 1,
"angle": 45,
"color": "0,0,0,1",
"color_mode": "rgba",
"honeycomb": true,
"reescale_image": false,
"save": true
}
The preset file can be passed as a parameter to the script.
python drawbot_halftone.py --path /path/to/image.jpg --preset /path/to/preset.json
In the /presets/
folder you can find some examples of preset files.
You can use the following command to process multiple images with the same preset.
for file in folder/*; do python main.py --path "$file" --preset=presets/halftone-pc-portraits.json; done