AddParticlePixel

Declaration: TParticles.AddParticlePixel (ClassIdx: integer; px, py: integer): integer;
The function AddParticlePixel adds the pixel at position [px,py] to particles of class ClassIdx. The pixel coordinates are zero-based (valid range 0..SizeX-1 and 0..SizeY-1), the class number is 1-based (valid range 1..NClasses).

The specified pixel is added to the particle list. Depending on the position of the pixel there are three kinds of outcomes:

  • the specified pixel has no neighbors1) of the specified particle class: the pixel is regarded as a new (single-pixel) particle
  • the specified pixel has one or more common edges with an existing particle of class ClassIdx: the pixel is added to the neighboring particle (the particle grows by one pixel)
  • the pixel has common edges with more than one particle of the specified class: the neighboring particles and the pixel are united to a new joint particle
The function returns the following error codes:
>0 ... everything is OK, the returned number is the particle index of the particle the pixel is assigned to
-1 ... invalid ClassIdx
-2 ... invalid px and/or py



1) A neigboring pixel has to have an edge in common. If the two pixels touch each other only at the corner, they are not considered to be neighbors.

Hint: In order to access the particles currently loaded in the particle editor you can use the pre-declared global variable PEData.