From 6849d583ae21a31b9bfe0af15a6dee1e465f438a Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Wed, 28 Oct 2026 15:11:33 -0400 Subject: [PATCH] Add Color and Image --- Rsconscript | 4 ++-- src/fart/Color.h | 14 ++++++++++++++ src/fart/Image.cpp | 12 ++++++++++++ src/fart/Image.h | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 src/fart/Color.h create mode 100644 src/fart/Image.cpp create mode 100644 src/fart/Image.h diff --git a/Rsconscript b/Rsconscript index aca65e2..7077338 100644 --- a/Rsconscript +++ b/Rsconscript @@ -1,10 +1,10 @@ configure do - check_cxx_compiler + check_cxx_compiler "clang++" check_cfg package: "libpng" end env do |env| - env["CCFLAGS"] += %w[-Wall -O2] + env["CCFLAGS"] += %w[-Wall -O2 -std=c++23] env["CPPPATH"] += %w[src] sources = glob("src/**/*.cpp") diff --git a/src/fart/Color.h b/src/fart/Color.h new file mode 100644 index 0000000..b53d09e --- /dev/null +++ b/src/fart/Color.h @@ -0,0 +1,14 @@ +#pragma once + +struct Color +{ + double r; + double g; + double b; + double a; + + Color(double r = 0.0, double g = 0.0, double b = 0.0, double a = 1.0) + : r(r), g(g), b(b), a(a) + { + } +}; diff --git a/src/fart/Image.cpp b/src/fart/Image.cpp new file mode 100644 index 0000000..c520094 --- /dev/null +++ b/src/fart/Image.cpp @@ -0,0 +1,12 @@ +#include + +Image::Image(size_t width, size_t height) + : width(width), height(height) +{ + this->pixels = new Color[width * height]; +} + +Image::~Image() +{ + delete[] this->pixels; +} diff --git a/src/fart/Image.h b/src/fart/Image.h new file mode 100644 index 0000000..a7bbd6f --- /dev/null +++ b/src/fart/Image.h @@ -0,0 +1,18 @@ +#pragma once + +#include +#include + +struct Image +{ + size_t width; + size_t height; + Color * pixels; + Image(size_t width, size_t height); + ~Image(); + + Color & operator[](size_t x, size_t y) + { + return this->pixels[this->width * y + x]; + } +};