Use purrmitive
as lib
purrmitive = "*"
or install purr
as binary
cargo install --bin purr --features="cli" purrmitive
or
cargo run --release --features=cli --bin=purr -- -i ./assets/input.png -o output.gif -n 100
most primitive
flags are supported, it should be a dropin replacement in most cases.
USAGE:
purr [FLAGS] [OPTIONS] -i <input> -n <number> -o <output>
FLAGS:
-h, --help Prints help information
-v the level of verbosity, v/vv/vvv
-V, --version Prints version information
OPTIONS:
-a <alpha> alpha value
-b <background> starting background color (hex)
-i <input> input image
-m <mode> mode: 0=combo 1=triangle 2=rect 3=ellipse 4=circle 5=rotatedrect 6=beziers 7=rotatedellipse
8=polygon(default 1)
-n <number> number of shapes
-o <output> output image
-r <resize> input size
-s <size> output size
-j <thread> numebr of threads
Output Formats:
png, jpg, svg and gif are all supported. You can also include {}
in output file name, for example, -o "/tmp/out/out{}.png"
will save every frame in that directory as /tmp/out/outX.png
X in range of [1, n]
using
-i ./assets/input.png -o output.gif -n 150
primitive | input image | output image | process |
---|---|---|---|
triangle | |||
ellipse |
try it yourself for more.
All the graphs supported by primitive are implemented, and the output of all graphs (except the bezier curves) is basically the same.
The original primitive version of bezier curves supports line thickness adjustment, which is not possible in purr. But the result is still not bad.
The key options and parameters of purr are the same as primitive, and in most cases you can just replace primitive with purr.
The rest of the parameters not listed above have not been implemented yet(these parameters will be supported in the future)
All types of graphical fits are faster than primitive on my computer. See the next section for more specific data.
One possible factor is that in my implementation, the "next-step" buffer is skiped, by modified the diff function. It costs less comapring to copy the current buffer, update it then read it.
This program is CPU intensive, it does all rendering in memory.
Purr is faster than the original implementation.
Benchmark using -n 100 -m {0-8}
, see the results below.
hyperfine --parameter-scan m 0 8 -D 1 './target/release/purr -i ./assets/input.png -o assets/purr.{m}.png -n 100 -m {m}' '~/go/bin/primitive -i ./assets/input.png -o assets/primitive.{m}.png -n 100 -m {m}' --export-json benchmark.json