92 for(uint8_t color_code = 255; color_code >= 0x40; --color_code)
261 int mindistance = 0xfffffff;
262 for(uint32_t i = 0; i <= 255; ++i) {
266 ((int) colour.red - (
int) c->red) * ((
int) colour.red - (int) c->red)
267 + ((int) colour.green - (
int) c->green) * ((
int) colour.green - (int) c->green)
268 + ((int) colour.blue - (
int) c->blue) * ((
int) colour.blue - (int) c->blue);
269 if(distance < mindistance) {
270 mindistance = distance;
278 return ((uint16_t) (colour.red & 0xF8)) << 8
279 | ((uint16_t) (colour.green & 0xFC)) << 3
280 | ((uint16_t) (colour.blue & 0xF8) >> 3);
283 return (uint32_t) colour.red << 16
284 | (uint32_t) colour.green << 8
285 | (uint32_t) colour.blue;
289 uint32_t red_hex = ((uint32_t) colour.red & 0xFF) << 16;
290 uint32_t green_hex = ((uint32_t) colour.green & 0xFF) << 8;
291 uint32_t blue_hex = (uint32_t) colour.blue & 0xFF;
292 uint32_t alpha_hex = ((uint32_t) colour.alpha & 0xFF) << 24;
294 uint32_t hex_value = red_hex | green_hex | blue_hex | alpha_hex;
477 bool y_0_is_smaller = y0 < y1;
478 int32_t y_min = y_0_is_smaller ? y0 : y1;
479 int32_t y_max = y_0_is_smaller ? y1 : y0;
490 if(y_min < 0) y_min = 0;
496 int32_t temp = y_max;
507 for(int32_t y = y_min; y <= y_max; ++y)
528 for(int32_t x = x0; x <= x1; ++x)
538 if(-1 <= slope && slope <= 1) {
540 for(int32_t x = x0; x <= x1; x++, y += slope)
550 for(int32_t y = y_min; y <= y_max; x += slope, y++)
void fill_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
Draws a circle on the screen, filled with a colour.
void put_pixel(uint32_t x, uint32_t y, const Colour &colour)
Renders a pixel to the screen (automatically converts the colour to an integer)
void draw_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a rectangle on the screen.
virtual uint8_t get_rendered_pixel_8_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 8 bit color depth.
virtual void render_pixel_8_bit(uint32_t x, uint32_t y, uint8_t colour)
Renders a pixel to the screen using the 8 bit color depth.
Colour get_pixel(uint32_t x, uint32_t y)
Gets the colour of a pixel, or returns black if the pixel is outside the screen.
static uint32_t colour_to_int(const Colour &colour, uint32_t color_depth)
Converts a colour to an integer value based on the current color depth.
virtual void render_pixel_24_bit(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen using the 24 bit color depth.
Colour int_to_colour(uint32_t)
Converts an integer value to a colour based on the current color depth.
virtual uint32_t get_rendered_pixel_24_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 24 bit color depth.
virtual uint16_t get_rendered_pixel_16_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 16 bit color depth.
virtual uint32_t get_rendered_pixel(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen, automatically uses the correct color depth.
virtual void render_pixel(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen based on the current color depth.
bool mirror_y_axis
Should the y axis be mirrored (0,0 is top left if false, bottom left if true)
virtual void render_pixel_32_bit(uint32_t x, uint32_t y, uint32_t colour)
Renders a pixel to the screen using the 32 bit color depth.
void fill_rectangle(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a rectangle on the screen, filled with a colour.
void draw_line(uint32_t x0, uint32_t y0, uint32_t x1, uint32_t y1, const Colour &colour)
Draws a line on the screen.
virtual void render_pixel_16_bit(uint32_t x, uint32_t y, uint16_t colour)
Renders a pixel to the screen using the 16 bit color depth.
virtual uint32_t get_rendered_pixel_32_bit(uint32_t x, uint32_t y)
Gets the colour of a pixel on the screen using the 32 bit color depth.
void draw_circle(uint32_t x0, uint32_t y0, uint32_t radius, const Colour &colour)
Draws a circle on the screen.
Defines a GraphicsContext class for drawing pixels, lines, rectangles and circles to the screen.