Write and load a plugin
Run the sample plugins from the Plugins menu, then write your own plugin file with settings and formulas and load it into PixelForge.
Plugins add your own effects to the Plugins menu. PixelForge comes with three sample plugins, and you can write and load your own.
#Run a sample plugin
Open the Plugins menu and choose a sample:
- Duotone repaints the picture with one colour for the shadows and one for the highlights.
- Random Sticker Scatter scatters stars, hearts, sparkles and dots. The same Seed always gives the same scatter.
- Palette from Image finds the main colours of the picture. Click a colour to make it the foreground colour.
Choose the settings and click Run. A plugin works on the visible picture. Duotone and Random Sticker Scatter put their result on a new layer at the top, so the original layers are kept and Edit > Undo removes the result in one step. Palette from Image does not change the document.
#What a plugin is
A plugin is a small text file in JSON format, up to 64 KB. It describes its settings and one kind of work:
"pixels": a formula for each colour channel, computed for every pixel;"scatter": shapes scattered at random on a new layer;"palette": the main colours of the picture.
A plugin cannot run a program. It only computes numbers from its settings and the picture, so it cannot read your files, see your account or reach the internet.
#Start from a sample
- Choose Plugins > Plugin Manager….
- Click Save a Copy next to a sample. The file is saved as, for example,
my-duotone.pixelforge-plugin.json. - Open the file in a text editor and change it.
Here is a small complete plugin that turns the picture into a warm sepia:
{
"pixelforgePlugin": 1,
"id": "my.sepia",
"name": "Sepia",
"version": "1.0.0",
"params": [
{ "id": "strength", "type": "number", "label": "Strength", "min": 0, "max": 1, "step": 0.05, "default": 0.8 }
],
"run": {
"type": "pixels",
"r": "mix(r, lum * 1.07, strength)",
"g": "mix(g, lum * 0.74, strength)",
"b": "mix(b, lum * 0.43, strength)"
}
}
"pixelforgePlugin": 1marks the file as a PixelForge plugin.idmust be unique, in lower case, for examplemy.sepia. Ids starting withpixelforge.are kept for the samples.paramslists the settings shown in the plugin's dialog:"number"(a slider withmin,max,stepanddefault),"color"(a colour such as"#ff8800") or"toggle"(trueorfalse). Up to 16 settings.name,version,authoranddescriptionare shown in the Plugin Manager. Atranslationssection can give the name, description and setting labels in other languages, as the samples do.
#Formulas
A formula is a small calculation such as mix(r, 1 - r, amount). It can use numbers, + - * / %, comparisons (< <= > >= == !=), &&, ||, !, brackets and condition ? a : b.
In a "pixels" plugin, each of r, g, b and a (alpha) can have a formula. A channel without one keeps its value. Results go from 0 to 1. A formula can read:
r,g,b,aandlum(brightness), from 0 to 1;xandy(the pixel's position),uandv(the same from 0 to 1), andwandh(the picture's size);- each setting by its id; for a colour setting, its channels such as
tint.r,tint.gandtint.b.
The functions are abs, ceil, clamp, cos, exp, floor, fract, hash (a repeatable random value from two numbers), log, max, min, mix, pow, round, sin, smoothstep, sqrt and step, and the constant pi.
A "scatter" plugin gives formulas for count (1 to 500), minSize and maxSize (in percent of the picture's shorter side), rotation (in degrees) and seed, and lists its shapes (circle, square, diamond, star, heart, sparkle) and colors (colours such as "#ff5c8a" or the ids of colour settings). A "palette" plugin gives a formula for count (2 to 16). These formulas can read the settings, w and h.
#Load your plugin
- Choose Plugins > Plugin Manager….
- Click Load Plugin File… and choose your file. You can also open Paste a plugin, paste the file's text and click Load.
If something is wrong, the Plugin Manager says what, for example which formula has a mistake and at which character. Fix the file and load it again. Loading a plugin with the same id replaces it, which is how you update it.
Your plugin then appears in the Plugins menu. To remove it, click Remove next to it in the Plugin Manager.
Still stuck? See Troubleshooting or report a problem.