summaryrefslogtreecommitdiff
path: root/rotord/nodes_drawing.h
diff options
context:
space:
mode:
authorTim Redfern <tim@herge.(none)>2013-07-26 17:06:55 +0100
committerTim Redfern <tim@herge.(none)>2013-07-26 17:06:55 +0100
commit7092eaaae3e844a68804b8a6b6825381e9a81443 (patch)
tree2d65ea068c5bc6c678f9dc3e2c456a6f6b15b83d /rotord/nodes_drawing.h
parent6f7be98c7289aedd9e45f9fafcc67ac6348cebf2 (diff)
cairo library and first drawing node
Diffstat (limited to 'rotord/nodes_drawing.h')
-rw-r--r--rotord/nodes_drawing.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/rotord/nodes_drawing.h b/rotord/nodes_drawing.h
new file mode 100644
index 0000000..11df2d6
--- /dev/null
+++ b/rotord/nodes_drawing.h
@@ -0,0 +1,43 @@
+#ifndef ROTOR_NODES_DRAWING
+#define ROTOR_NODES_DRAWING
+
+#include "rotor.h"
+#include <cairo.h>
+
+namespace Rotor {
+ class Draw: public Image_node {
+ public:
+ Draw(){image=nullptr;};
+ Draw(map<string,string> &settings) {
+ base_settings(settings);
+ };
+ ~Draw(){ if (image) delete image;};
+ Draw* clone(map<string,string> &_settings) { return new Draw(_settings);};
+ Image *output(const Frame_spec &frame){
+ if (image_inputs.size()) {
+ if (image_inputs[0]->connection){
+ //copy incoming image **writable
+ if (image) delete image;
+ image=(((Image_node*)image_inputs[0]->connection)->get_output(frame))->clone();
+ }
+ else image->setup(frame.w,frame.h);
+ }
+ else image->setup(frame.w,frame.h); //do this twice or use a goto
+ //draw onto new or input image
+ cairo_surface_t * cs = cairo_image_surface_create_for_data (image->RGBdata,
+ CAIRO_FORMAT_RGB24,
+ image->w,
+ image->h,
+ image->getStride());
+ cairo_t *c=cairo_create(cs);
+ cairo_rectangle(c, image->w/2, image->h/2, image->w, image->h);
+ cairo_set_source_rgb(c, 1.0, 0.0, 0.0);
+ cairo_fill(c);
+ return image;
+ }
+ private:
+ Image *image; //is an image generator
+ };
+}
+
+#endif \ No newline at end of file