Add Color and Image
This commit is contained in:
1 parent
6d102b8de9
commit
6849d583ae
4 files changed
+46
-2
No files matched your search
+2
-2
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <fart/Image.h>
|
||||
|
||||
Image::Image(size_t width, size_t height)
|
||||
: width(width), height(height)
|
||||
{
|
||||
this->pixels = new Color[width * height];
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
delete[] this->pixels;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <fart/Color.h>
|
||||
#include <stddef.h>
|
||||
|
||||
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];
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user