Skip to content

A generative art Twitter bot using the 2D superformula. Tweets new drawings every couple hours, and responds to @mentions with custom drawings.

Notifications You must be signed in to change notification settings

jasonwebb/superformulabot

Repository files navigation

Bot is currently ONLINE!

@superformulabot is a generative art Twitter bot by Jason Webb that shares drawings created using Johan Gielis' superformula equation based on the implementation provided in the book FORM+CODE.

Every two hours (+/- up to 15min) a new drawing is automatically generated and tweeted out using parameters based on the current timestamp.

Anyone can request a specific drawing be made for them by @mentioning the bot with a message containing a set of parameters (see Usage and About the parameters). The bot will generate a new drawing using the provided parameters, using randomized values for any that are not provided, then reply to the user with the drawing.

If you'd like to play around with the superformula in real-time and see the effects of all the parameters, try out my interactive web app SuperformulaSVG.

Usage

To request a custom drawing from the bot, @mention it in a tweet containing a list of parameters in the format of [... {key}:{value} ...]. For example:

@superformulabot [a:# b:# m:# n1:# n2:# n3:# iterations:# decay:# invert:#]

All parameters are optional and will be randomized within the ranges below if they are not explicitly provided. Provide as many or as few as you'd like!

  • All provided parameters will be automatically clamped to the ranges listed below to limit abuse.
  • If no parameters are provided ([]), or if anything other than a set of valid key/value pairs are provided (e.g [schwifty]), all parameters will be randomized within the ranges below.
  • If a mix of valid parameters and non-valid parameters are provided (e.g. [m:10 schwifty]), all valid parameters will be used and all non-valid parameters will be randomized within the ranges below.

All @mentions that do not include at least an empty parameter set ([]) will be silently ignored so that people can talk about the bot without triggering it.

About the parameters

The superformula itself makes use of a number of parameters that you can explicitly provide values for when requesting custom drawings. The formula itself is as follows:

Superformula equation

Each of the parameters have distinct effects on the resulting drawing, as described below. In an effort to minimize 'ugly' forms and prevent some abuse, constraints are added to each parameter (see table below). If you think these constraints should be changed, send me a message!

Parameter Type Description Range
a float Lateral stretch amount 0.01 - 8.0
b float Vertical stretch amount 0.01 - 8.0
m float Degree of rotational symmetry
- Positive even integers result in closed shapes, but are not required.
- When randomized, m will be rounded up to nearest even integer.
1.0 - 20.0
n1 float Affects convexity/concavity of edges, resulting in 'bloated' or 'pinched' shapes 0.01 - 40.0
n2 float Similar to n1 0.01 - 40.0
n3 float Similar to n2 0.01 - 40.0
iterations int Number of concentric drawings 1 - 10
decay float Amount of negative change to all parameters per iteration 0.05 - 0.2
invert boolean Invert colors
- Defaults to false for replies for predictability
- Changes to true for automated tweets overnight (8pm to 6am CST).
true | false

Examples

Status text Interpreted parameters
@superformulabot [a:1.0 b:1.0 m:3.0 n1:10.0 n2:10.0 n3:10.0 iterations:3 decay:.3 invert:true] Exactly as provided
@superformulabot [a:3.0 m:5 n2:3] All parameters not provided are randomized (except invert)
@superformulabot [] or @superformulabot [scwifty] All parameters are randomized (except invert)

Running continuously with forever

This script is run continuously on an EC2 instance using forever, invoked like so:

forever -o activity.log -e error.log -c "npm run deploy" start bot.js

You can find out if the script is still running at any point in the future by using:

forever list

And stop the script using:

forever stopall

Technologies used

References

About

A generative art Twitter bot using the 2D superformula. Tweets new drawings every couple hours, and responds to @mentions with custom drawings.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published