Skip to content

Commit

Permalink
vermiculate
Browse files Browse the repository at this point in the history
  • Loading branch information
yekm committed May 20, 2023
1 parent 5ca9fb7 commit a542cc0
Show file tree
Hide file tree
Showing 7 changed files with 926 additions and 930 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ target_sources(cloudlife PUBLIC
cloudlife.cpp
mtron.cpp
timer.cpp
ifs.cpp)
ifs.cpp
vermiculate.cpp)
target_link_libraries(cloudlife IMGUI glfw GL colormap)
set_target_properties(cloudlife PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
19 changes: 18 additions & 1 deletion art.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
#include <string>
#include <vector>


template <typename T>
static inline void
fill0(T &container) {
std::fill(container.begin(), container.end(), 0);
}

class Art {
public:
Art(std::string _name)
Expand Down Expand Up @@ -31,20 +38,30 @@ class Art {

virtual void reinit() { resize(w, h); }

virtual ~Art() = default;

protected:
void default_resize(int _w, int _h) {
w = _w;
h = _h;
//data = (uint8_t *)xrealloc(data, w*h*sizeof(uint32_t));
pixels.resize(w*h);
clear();
/* TODO: fill square in drawdot() if pscale > 1
pscale = 1;
if (xgwa.width > 2560 || xgwa.height > 2560)
pscale = 3; // Retina displays
*/

}
void clear() {
std::fill(pixels.begin(), pixels.end(), 0);
fill0(pixels);
//std::fill(pixels.begin(), pixels.end(), 0);
}
int w, h;
//uint8_t *data() { return reinterpret_cast<uint8_t*>(pixels.data()); }
uint32_t *data() { return pixels.data(); }
std::vector<uint32_t> pixels;
std::string m_name;
};

4 changes: 3 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "cloudlife.hpp"
#include "mtron.hpp"
#include "ifs.h"
#include "vermiculate.h"

std::unique_ptr<Art> art;

Expand Down Expand Up @@ -162,7 +163,8 @@ int main(int argc, char *argv[])

//art.reset(new Cloudlife);
//art.reset(new Minskytron);
art.reset(new IFS);
//art.reset(new IFS);
art.reset(new Vermiculate);


IMGUI_CHECKVERSION();
Expand Down
13 changes: 13 additions & 0 deletions settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ bool PaletteSetting::RenderGui() {
}
return ret;
}

void PaletteSetting::rescale(uint32_t ncolours) {
value = value.rescale(0., ncolours);
}

uint32_t PaletteSetting::get_color(uint32_t color_n) {
auto c = value(color_n);
return 0xff000000 |
c.getRed().getValue() << 0 |
c.getGreen().getValue() << 8 |
c.getBlue().getValue() << 16;

}
7 changes: 6 additions & 1 deletion settings.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once
#include <string>

#include <stdint.h>

class Setting {
public:
virtual bool RenderGui() = 0;
Expand All @@ -26,8 +28,11 @@ class PaletteSetting : public Setting {
pal_t & operator*() {return value;}

pal_t value = colormap::palettes.at("inferno");

void rescale(uint32_t ncolours);
uint32_t get_color(uint32_t color_n);

private:
int item_current_idx = 0;

};

Loading

0 comments on commit a542cc0

Please sign in to comment.