Class Pixel

java.lang.Object
fr.formiko.usuel.images.Pixel

public class Pixel extends Object
Pixel class used by images package.
Author:
Hydrolien
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private byte
     
    private byte
     
    private byte
     
    private byte
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Pixel​(byte r, byte g, byte b, byte a)
    Main constructor private. Use the int 1 to create a Pixel.
     
    Pixel​(int r, int g, int b)
    Secondary constructor.
     
    Pixel​(int r, int g, int b, int a)
    Main constructor with int.
     
    Secondary constructor that use Pheromone.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Color
    Return Color as a grey color.
    boolean
    equals​(Object o)
    Standard equals function.
    byte
     
    byte
     
    byte
     
    byte
     
    Return pixel as a Color.
    void
    setA​(byte x)
     
    void
    setB​(byte x)
     
    void
    setG​(byte x)
     
    void
    setR​(byte x)
     
    Return pixel as a String.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • r

      private byte r
    • g

      private byte g
    • b

      private byte b
    • a

      private byte a
  • Constructor Details

    • Pixel

      private Pixel(byte r, byte g, byte b, byte a)
      Main constructor private. Use the int 1 to create a Pixel.
      Parameters:
      r - Red value between -128 & 127.
      g - Green value between -128 & 127.
      b - Blue value between -128 & 127.
      a - Alpha value between -128 & 127.
    • Pixel

      public Pixel(int r, int g, int b, int a)
      Main constructor with int.
      Parameters:
      r - Red value between 0 & 255.
      g - Green value between 0 & 255.
      b - Blue value between 0 & 255.
      a - Alpha value between 0 & 255.
    • Pixel

      public Pixel(int r, int g, int b)
      Secondary constructor.
      It will set Alpha value to 255 (maximum value).
      Parameters:
      r - Red value between 0 & 255.
      g - Green value between 0 & 255.
      b - Blue value between 0 & 255.
    • Pixel

      public Pixel(Pheromone ph)
      Secondary constructor that use Pheromone.
      Parameters:
      ph - Pheromone of the Creature to colored. Pheromone have 3 color value: red, green, blue.
  • Method Details

    • getR

      public byte getR()
    • getG

      public byte getG()
    • getB

      public byte getB()
    • getA

      public byte getA()
    • setR

      public void setR(byte x)
    • setG

      public void setG(byte x)
    • setB

      public void setB(byte x)
    • setA

      public void setA(byte x)
    • equals

      public boolean equals(Object o)
      Standard equals function. Null & other class type proof.
      Overrides:
      equals in class Object
      Parameters:
      o - o is the Object to test. It can be null or something else than this class.
    • toString

      public String toString()
      Return pixel as a String.
      If alpha value is 127, it will not be print.
      Overrides:
      toString in class Object
    • piToColor

      public Color piToColor()
      Return pixel as a Color.
    • colorToGrey

      public static Color colorToGrey(Color c)
      Return Color as a grey color.