A pixel is a single dot of color in a picture.
It contains an x and y location, with (0, 0) at the top left of the picture.
It contains a color object which has red, green, and blue values between 0 and 255 (inclusive).
myBluePixel = Pixel(0, 0, red=0, green=0, blue=255)
pixels = picture.getPixels()
pixels[0] = myBluePixel
Parameters: |
|
---|
Return the x value of a pixel.
pixel = picture.getPixel(200, 10)
# This will print 200.
print(pixel.getX())
Return the y value of a pixel.
pixel = picture.getPixel(200, 10)
# This will print 10.
print(pixel.getY())
This function returns the Color object of the pixel.
color = pixel.getColor()
These functions return the red, green, and blue values of the pixel.
red = pixel.getRed()
green = pixel.getGreen()
blue = pixel.getBlue()
These functions allow you to set the color values of a pixel.
Parameters: | red (int) – between 0 and 255 (inclusive). |
---|
pixel.setRed(red)
Parameters: | green (int) – between 0 and 255 (inclusive). |
---|
pixel.setGreen(green)
Parameters: | blue (int) – between 0 and 255 (inclusive). |
---|
pixel.setBlue(blue)