ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
PixelGroup< pixelCount > Class Template Reference

Manages a collection of pixels with positions, colors, and spatial relationships. More...

#include <PixelGroup.h>

Inheritance diagram for PixelGroup< pixelCount >:
Collaboration diagram for PixelGroup< pixelCount >:

Public Member Functions

 PixelGroup (Vector2D size, Vector2D position, uint16_t rowCount)
 Constructs a rectangular PixelGroup.
 
 PixelGroup (const Vector2D *pixelLocations, Direction direction=ZEROTOMAX)
 Constructs a PixelGroup from arbitrary pixel locations.
 
 ~PixelGroup ()
 Destroys the PixelGroup object.
 
Vector2D GetCenterCoordinate () override
 Retrieves the center coordinate of the pixel group.
 
Vector2D GetSize () override
 Retrieves the size of the pixel group.
 
Vector2D GetCoordinate (uint16_t count) override
 Retrieves the coordinate of a specific pixel.
 
int GetPixelIndex (Vector2D location) override
 Retrieves the index of a pixel at a specific location.
 
RGBColorGetColor (uint16_t count) override
 Retrieves the color of a specific pixel.
 
RGBColorGetColors () override
 Retrieves the array of colors for the pixel group.
 
RGBColorGetColorBuffer () override
 Retrieves the color buffer for the pixel group.
 
uint16_t GetPixelCount () override
 Retrieves the total number of pixels in the group.
 
bool Overlaps (BoundingBox2D *box) override
 Checks if the pixel group overlaps with a bounding box.
 
bool ContainsVector2D (Vector2D v) override
 Checks if the pixel group contains a specific vector.
 
bool GetUpIndex (uint16_t count, uint16_t *upIndex) override
 Retrieves the index of the pixel above a given pixel.
 
bool GetDownIndex (uint16_t count, uint16_t *downIndex) override
 Retrieves the index of the pixel below a given pixel.
 
bool GetLeftIndex (uint16_t count, uint16_t *leftIndex) override
 Retrieves the index of the pixel to the left of a given pixel.
 
bool GetRightIndex (uint16_t count, uint16_t *rightIndex) override
 Retrieves the index of the pixel to the right of a given pixel.
 
bool GetAlternateXIndex (uint16_t count, uint16_t *index) override
 Retrieves an alternate X-axis index for a given pixel.
 
bool GetAlternateYIndex (uint16_t count, uint16_t *index) override
 Retrieves an alternate Y-axis index for a given pixel.
 
bool GetOffsetXIndex (uint16_t count, uint16_t *index, int x1) override
 Retrieves an offset X-axis index for a given pixel.
 
bool GetOffsetYIndex (uint16_t count, uint16_t *index, int y1) override
 Retrieves an offset Y-axis index for a given pixel.
 
bool GetOffsetXYIndex (uint16_t count, uint16_t *index, int x1, int y1) override
 Retrieves an offset XY-axis index for a given pixel.
 
bool GetRadialIndex (uint16_t count, uint16_t *index, int pixels, float angle) override
 Retrieves a radial index for a given pixel based on distance and angle.
 
void GridSort () override
 Sorts the pixels in a grid structure.
 

Private Attributes

const Vector2DpixelPositions
 Array of pixel positions.
 
Direction direction
 Direction of pixel traversal.
 
BoundingBox2D bounds
 Bounding box for the pixel group.
 
RGBColor pixelColors [pixelCount]
 Array of pixel colors.
 
RGBColor pixelBuffer [pixelCount]
 Array of color buffers for temporary use.
 
uint16_t up [pixelCount]
 Indices of pixels above each pixel.
 
uint16_t down [pixelCount]
 Indices of pixels below each pixel.
 
uint16_t left [pixelCount]
 Indices of pixels to the left of each pixel.
 
uint16_t right [pixelCount]
 Indices of pixels to the right of each pixel.
 
bool isRectangular = false
 Indicates if the group forms a rectangular grid.
 
uint16_t rowCount
 Number of rows in the grid.
 
uint16_t colCount
 Number of columns in the grid.
 
Vector2D size
 Size of the grid.
 
Vector2D position
 Position of the grid.
 
Vector2D tempLocation
 Temporary location for calculations.
 

Additional Inherited Members

- Public Types inherited from IPixelGroup
enum  Direction { ZEROTOMAX , MAXTOZERO }
 Specifies traversal directions for pixels. More...
 

Detailed Description

template<size_t pixelCount>
class PixelGroup< pixelCount >

Manages a collection of pixels with positions, colors, and spatial relationships.

The PixelGroup class provides methods for retrieving and manipulating pixel data, including spatial relationships and color properties. Supports both rectangular and arbitrary pixel arrangements.

Template Parameters
pixelCountThe total number of pixels in the group.

Definition at line 27 of file PixelGroup.h.

Constructor & Destructor Documentation

◆ PixelGroup() [1/2]

template<size_t pixelCount>
PixelGroup ( Vector2D  size,
Vector2D  position,
uint16_t  rowCount 
)

Constructs a rectangular PixelGroup.

Parameters
sizeSize of the rectangular grid.
positionPosition of the rectangular grid.
rowCountNumber of rows in the grid.

◆ PixelGroup() [2/2]

template<size_t pixelCount>
PixelGroup ( const Vector2D pixelLocations,
Direction  direction = ZEROTOMAX 
)

Constructs a PixelGroup from arbitrary pixel locations.

Parameters
pixelLocationsArray of pixel locations.
directionDirection of pixel traversal (default: ZEROTOMAX).

◆ ~PixelGroup()

template<size_t pixelCount>
~PixelGroup ( )

Destroys the PixelGroup object.

Member Function Documentation

◆ ContainsVector2D()

template<size_t pixelCount>
bool ContainsVector2D ( Vector2D  v)
overridevirtual

Checks if the pixel group contains a specific vector.

Parameters
vThe vector to check.
Returns
True if the group contains the vector, otherwise false.

Implements IPixelGroup.

◆ GetAlternateXIndex()

template<size_t pixelCount>
bool GetAlternateXIndex ( uint16_t  count,
uint16_t index 
)
overridevirtual

Retrieves an alternate X-axis index for a given pixel.

Parameters
countThe index of the current pixel.
indexPointer to store the alternate X index.
Returns
True if an alternate index exists, otherwise false.

Implements IPixelGroup.

◆ GetAlternateYIndex()

template<size_t pixelCount>
bool GetAlternateYIndex ( uint16_t  count,
uint16_t index 
)
overridevirtual

Retrieves an alternate Y-axis index for a given pixel.

Parameters
countThe index of the current pixel.
indexPointer to store the alternate Y index.
Returns
True if an alternate index exists, otherwise false.

Implements IPixelGroup.

◆ GetCenterCoordinate()

template<size_t pixelCount>
Vector2D GetCenterCoordinate ( )
overridevirtual

Retrieves the center coordinate of the pixel group.

Returns
The center coordinate as a Vector2D.

Implements IPixelGroup.

◆ GetColor()

template<size_t pixelCount>
RGBColor * GetColor ( uint16_t  count)
overridevirtual

Retrieves the color of a specific pixel.

Parameters
countThe index of the pixel.
Returns
Pointer to the RGB color of the pixel.

Implements IPixelGroup.

Referenced by BetaProtoController::Display(), ESP32DevKitV1::Display(), GammaControllerBack::Display(), GammaControllerFront::Display(), KaiborgV1Controller::Display(), KaiborgV1D1Controller::Display(), and ProtoDRController::Display().

◆ GetColorBuffer()

template<size_t pixelCount>
RGBColor * GetColorBuffer ( )
overridevirtual

Retrieves the color buffer for the pixel group.

Returns
Pointer to the color buffer array.

Implements IPixelGroup.

◆ GetColors()

template<size_t pixelCount>
RGBColor * GetColors ( )
overridevirtual

Retrieves the array of colors for the pixel group.

Returns
Pointer to the array of RGB colors.

Implements IPixelGroup.

◆ GetCoordinate()

template<size_t pixelCount>
Vector2D GetCoordinate ( uint16_t  count)
overridevirtual

Retrieves the coordinate of a specific pixel.

Parameters
countThe index of the pixel.
Returns
The coordinate of the pixel as a Vector2D.

Implements IPixelGroup.

◆ GetDownIndex()

template<size_t pixelCount>
bool GetDownIndex ( uint16_t  count,
uint16_t downIndex 
)
overridevirtual

Retrieves the index of the pixel below a given pixel.

Parameters
countThe index of the current pixel.
downIndexPointer to store the index of the pixel below.
Returns
True if a pixel below exists, otherwise false.

Implements IPixelGroup.

◆ GetLeftIndex()

template<size_t pixelCount>
bool GetLeftIndex ( uint16_t  count,
uint16_t leftIndex 
)
overridevirtual

Retrieves the index of the pixel to the left of a given pixel.

Parameters
countThe index of the current pixel.
leftIndexPointer to store the index of the pixel to the left.
Returns
True if a pixel to the left exists, otherwise false.

Implements IPixelGroup.

◆ GetOffsetXIndex()

template<size_t pixelCount>
bool GetOffsetXIndex ( uint16_t  count,
uint16_t index,
int  x1 
)
overridevirtual

Retrieves an offset X-axis index for a given pixel.

Parameters
countThe index of the current pixel.
indexPointer to store the offset X index.
x1The X-axis offset value.
Returns
True if an offset index exists, otherwise false.

Implements IPixelGroup.

◆ GetOffsetXYIndex()

template<size_t pixelCount>
bool GetOffsetXYIndex ( uint16_t  count,
uint16_t index,
int  x1,
int  y1 
)
overridevirtual

Retrieves an offset XY-axis index for a given pixel.

Parameters
countThe index of the current pixel.
indexPointer to store the offset XY index.
x1The X-axis offset value.
y1The Y-axis offset value.
Returns
True if an offset index exists, otherwise false.

Implements IPixelGroup.

◆ GetOffsetYIndex()

template<size_t pixelCount>
bool GetOffsetYIndex ( uint16_t  count,
uint16_t index,
int  y1 
)
overridevirtual

Retrieves an offset Y-axis index for a given pixel.

Parameters
countThe index of the current pixel.
indexPointer to store the offset Y index.
y1The Y-axis offset value.
Returns
True if an offset index exists, otherwise false.

Implements IPixelGroup.

◆ GetPixelCount()

template<size_t pixelCount>
uint16_t GetPixelCount ( )
overridevirtual

Retrieves the total number of pixels in the group.

Returns
The total pixel count.

Implements IPixelGroup.

◆ GetPixelIndex()

template<size_t pixelCount>
int GetPixelIndex ( Vector2D  location)
overridevirtual

Retrieves the index of a pixel at a specific location.

Parameters
locationThe location to search for a pixel.
Returns
The index of the pixel, or -1 if not found.

Implements IPixelGroup.

◆ GetRadialIndex()

template<size_t pixelCount>
bool GetRadialIndex ( uint16_t  count,
uint16_t index,
int  pixels,
float  angle 
)
overridevirtual

Retrieves a radial index for a given pixel based on distance and angle.

Parameters
countThe index of the current pixel.
indexPointer to store the radial index.
pixelsThe radial distance in pixels.
angleThe angle in degrees.
Returns
True if a radial index exists, otherwise false.

Implements IPixelGroup.

◆ GetRightIndex()

template<size_t pixelCount>
bool GetRightIndex ( uint16_t  count,
uint16_t rightIndex 
)
overridevirtual

Retrieves the index of the pixel to the right of a given pixel.

Parameters
countThe index of the current pixel.
rightIndexPointer to store the index of the pixel to the right.
Returns
True if a pixel to the right exists, otherwise false.

Implements IPixelGroup.

◆ GetSize()

template<size_t pixelCount>
Vector2D GetSize ( )
overridevirtual

Retrieves the size of the pixel group.

Returns
The size as a Vector2D.

Implements IPixelGroup.

◆ GetUpIndex()

template<size_t pixelCount>
bool GetUpIndex ( uint16_t  count,
uint16_t upIndex 
)
overridevirtual

Retrieves the index of the pixel above a given pixel.

Parameters
countThe index of the current pixel.
upIndexPointer to store the index of the pixel above.
Returns
True if a pixel above exists, otherwise false.

Implements IPixelGroup.

◆ GridSort()

template<size_t pixelCount>
void GridSort ( )
overridevirtual

Sorts the pixels in a grid structure.

Implements IPixelGroup.

◆ Overlaps()

template<size_t pixelCount>
bool Overlaps ( BoundingBox2D box)
overridevirtual

Checks if the pixel group overlaps with a bounding box.

Parameters
boxPointer to the bounding box.
Returns
True if the group overlaps with the box, otherwise false.

Implements IPixelGroup.

Member Data Documentation

◆ bounds

template<size_t pixelCount>
BoundingBox2D bounds
private

Bounding box for the pixel group.

Definition at line 31 of file PixelGroup.h.

◆ colCount

template<size_t pixelCount>
uint16_t colCount
private

Number of columns in the grid.

Definition at line 41 of file PixelGroup.h.

◆ direction

template<size_t pixelCount>
Direction direction
private

Direction of pixel traversal.

Definition at line 30 of file PixelGroup.h.

◆ down

template<size_t pixelCount>
uint16_t down[pixelCount]
private

Indices of pixels below each pixel.

Definition at line 35 of file PixelGroup.h.

◆ isRectangular

template<size_t pixelCount>
bool isRectangular = false
private

Indicates if the group forms a rectangular grid.

Definition at line 39 of file PixelGroup.h.

◆ left

template<size_t pixelCount>
uint16_t left[pixelCount]
private

Indices of pixels to the left of each pixel.

Definition at line 36 of file PixelGroup.h.

◆ pixelBuffer

template<size_t pixelCount>
RGBColor pixelBuffer[pixelCount]
private

Array of color buffers for temporary use.

Definition at line 33 of file PixelGroup.h.

◆ pixelColors

template<size_t pixelCount>
RGBColor pixelColors[pixelCount]
private

Array of pixel colors.

Definition at line 32 of file PixelGroup.h.

◆ pixelPositions

template<size_t pixelCount>
const Vector2D* pixelPositions
private

Array of pixel positions.

Definition at line 29 of file PixelGroup.h.

◆ position

template<size_t pixelCount>
Vector2D position
private

Position of the grid.

Definition at line 43 of file PixelGroup.h.

◆ right

template<size_t pixelCount>
uint16_t right[pixelCount]
private

Indices of pixels to the right of each pixel.

Definition at line 37 of file PixelGroup.h.

◆ rowCount

template<size_t pixelCount>
uint16_t rowCount
private

Number of rows in the grid.

Definition at line 40 of file PixelGroup.h.

◆ size

template<size_t pixelCount>
Vector2D size
private

Size of the grid.

Definition at line 42 of file PixelGroup.h.

◆ tempLocation

template<size_t pixelCount>
Vector2D tempLocation
private

Temporary location for calculations.

Definition at line 44 of file PixelGroup.h.

◆ up

template<size_t pixelCount>
uint16_t up[pixelCount]
private

Indices of pixels above each pixel.

Definition at line 34 of file PixelGroup.h.


The documentation for this class was generated from the following file: