1
Fork 0
This repository has been archived on 2025-04-09. You can view files and clone it, but cannot push or open issues or pull requests.
awesome-attractor-nd/AwesomeAttractorND/Canvas.hpp
2011-11-02 14:05:12 +01:00

37 lines
731 B
C++

//
// Canvas.hpp
// AwesomeAttractorND
//
// Created by Joshua Moerman on 10/28/11.
// Copyright 2011 Vadovas. All rights reserved.
//
#ifndef AwesomeAttractorND_Canvas_hpp
#define AwesomeAttractorND_Canvas_hpp
#include "nd_array.hpp"
class Canvas2D : public nd_array<unsigned int, 2>{
typedef Canvas2D self;
typedef nd_array<unsigned int, 2> super;
public:
Canvas2D(size_t width, size_t height)
: super(width, height)
{}
void plot(double const * const position){
const size_t width = get_size(0);
const size_t height = get_size(1);
const size_t x = position[0]*width + width*.5;
const size_t y = position[1]*width + height*.5;
if(x < width && y < height) {
(*this)[x][y]++;
}
}
};
#endif