Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.
Mircea Anton edited this page Feb 12, 2021 · 1 revision

Pixel

A class that encapsulates all the data associated to a pixel.
What a pixel stores is the intensity value for each color channel and the alpha.

Description

This class only stores 4 doubles, the red, green, blue and alpha channel intensities. These values are accesible only through getter and setter methods.

Of note inside this class are:

  • the limit(double) method which basically trims down each value bigger than 255 to 255, and every negative value to 0
  • the clip() method, which calls limit() on each channel intensity value

In order to simulate operator overloading, the following methods have been implemented:

  • multiply(Pixel) which multiplies the red channel of this pixel with the red channel of the given pixel, and so on, for all channels

  • multiply(int), multiply(double), multiply(float) which multiplies all channels with the given value

  • divide(Pixel) which divides the red channel of this pixel with the red channel of the given pixel, and so on, for all channels

  • divide(int), divide(double), divide(float) which divides all channels with the given value

  • add(Pixel) which adds the red channel of this pixel with the red channel of the given pixel, and so on, for all channels

  • add(int), add(double), add(float) which adds the given value to all channels

  • subtract(Pixel) which subtracts from the red channel of this pixel with the red channel of the given pixel, and so on, for all channels

  • subtract(int), subtract(double), subtract(float) which divides all channels with the given value

  • log() which applies the Math.log() function on each channel

  • pow(double) which applies the Math.pow() on all channels, the channel value being the base, and the given value is the exponent

  • and(Pixel) which performs a bitwise AND between the 2 pixels

  • or(Pixel) which performs a bitwise OR between the 2 pixels

  • xor(Pixel) which performs a bitwise XOR between the 2 pixels

Clone this wiki locally