21 lines
457 B
C
21 lines
457 B
C
//
|
|
// Created by william on 16/05/24.
|
|
//
|
|
|
|
#include <assert.h>
|
|
#include <string.h>
|
|
#include "canvas.h"
|
|
|
|
void canvas_draw(Canvas *canvas, Pixel pixel, int x, int y) {
|
|
assert(x >= 0);
|
|
assert(x < CANVAS_WIDTH);
|
|
assert(y >= 0);
|
|
assert(y < CANVAS_HEIGHT);
|
|
|
|
int pixel_index = CANVAS_INDEX(x, y);
|
|
canvas->pixels[pixel_index] = pixel;
|
|
}
|
|
|
|
void canvas_reset(Canvas *canvas) {
|
|
memset(canvas->pixels, 0, sizeof(Pixel) * CANVAS_PIXEL_COUNT);
|
|
} |