Reference

Table of Contents  ▸  List of Commands  ▸  Image Drawing  ▸  pack_sprites◀  object3d    |    piechart  ▶

pack_sprites

Arguments:

Description:

Try to randomly pack as many sprites as possible onto the empty areas of an image.

Sprites can be eventually rotated and scaled during the packing process.
First selected image is the canvas that will be filled with the sprites.
Its last channel must be a binary mask whose zero values represent potential locations for drawing the sprites.
All other selected images represent the sprites considered for packing.
Their last channel must be a binary mask that represents the sprite shape (i.e. a 8-connected component).
The order of sprite packing follows the order of specified sprites in the image list.
Sprite packing is done on random locations and iteratively with decreasing scales.
nb_scales sets the number of decreasing scales considered for all specified sprites to be packed.
min_scale (in %) sets the minimal size considered for packing (specified as a percentage of the
original sprite size).
spacing can be positive or negative.
precision tells about the desired number of failed trials before ending the filling process.

Default values:

nb_scales=5, min_scale=25, allow_rotation=3, spacing=1, precision=7 and max_iterations=256.

Example of use:

$ gmic 512,512,1,3,"min(255,y*c/2)" 100%,100% circle 50%,50%,100,1,255 append c image.jpg resize2dy[-1] 24 to_rgba pack_sprites 3,25

Command: 512,512,1,3,"min(255,y*c/2)" 100%,100% circle 50%,50%,100,1,255 append c image.jpg resize2dy[-1] 24 to_rgba pack_sprites 3,25