Skip to content
Snippets Groups Projects
Commit 0f05d361 authored by Yoel's avatar Yoel
Browse files

Added a setPixel function and replaced expression in setPixels with the new function

parent 281eea2e
No related branches found
No related tags found
No related merge requests found
#include "Image.h"
#include "../tools/Threadpool.h"
#include "StratifiedSampler.h"
namespace util {
......@@ -9,10 +10,13 @@ Image::Image(int width, int height) : width(width), height(height) {
vec.insert(vec.end(), color);
}
}
void Image::setPixel(int x, int y, Vec3 color) {
vec[width * y + x] = color;
}
void Image::setPixels(std::shared_ptr<Sampler> sampler) {
for (int x = 0; x != width; x++) {
for (int y = 0; y != height; y++) {
vec[width * y + x] = sampler->color(x, y);
setPixel(x, y, sampler->color(x, y));
}
}
}
......
......@@ -11,6 +11,7 @@ class Image {
public:
Image(int width, int height);
void setPixel(int x, int y, Vec3 color);
void setPixels(std::shared_ptr<Sampler> sampler);
Vec3 operator[](const std::array<int, 2>& i) const; // int x, int y
......@@ -20,7 +21,7 @@ class Image {
const int height;
private:
std::vector<util::Vec3> vec;
std::vector<Vec3> vec;
};
Image raytrace(const cam::CamObs& cam, const std::shared_ptr<Sampler>& sampler,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment