Newer
Older
#ifndef PRIMITIVES_JUPYTER_H
#define PRIMITIVES_JUPYTER_H
/**
Variante de primitives.h pour dessiner dans Jupyter, sans la SFML
CAVEAT: Ceci est une pure rustine, du genre que l'on bricole entre
minuit et 3h du mat pour sauver un TP, en attendant une solution
pérenne: backend Jupyter pour SFML, utilisation de xcanvas
(https://github.com/martinRenou/xcanvas) l'équivalent de ipycanvas
(https://ipycanvas.readthedocs.io/) pour C++, ou possibilité de
lancer des applications graphiques sur JupyterHub.
NE PRENNEZ PAS EXEMPLE DESSUS!
**/
Color White = "White";
Color Blue = "Blue";
Color Red = "Red";
Color Yellow = "Yellow";
Color Green = "#00CC00";
Color Black = "Black";
}
class Point {
public:
int x;
int y;
Point(int _x, int _y): x(_x), y(_y) {};
Point(double _x, double _y): x(_x), y(_y) {};
};
class VideoMode {
public:
int width;
int height;
VideoMode(int w, int h): width(w), height(h) {}
};
vm = _vm;
canvas = xc::canvas().initialize()
.width(vm.width)
.height(vm.height)
.finalize();
canvas.cache();
}
// Clear the canvas with the given color
void clear(Color::Color color) {
canvas.fill_style = color;
canvas.fill_rect(0, 0, vm.width, vm.height);
display();
}
void display() {
canvas.flush();
canvas.cache();
}
};
void draw_point(RenderWindow &window, Point p, Color::Color color) {
window.canvas.fill_style = color;
window.canvas.fill_rect(p.x, p.y, 1, 1);