summaryrefslogtreecommitdiff
path: root/rotord/src
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/src')
-rw-r--r--rotord/src/nodes_drawing.h72
1 files changed, 35 insertions, 37 deletions
diff --git a/rotord/src/nodes_drawing.h b/rotord/src/nodes_drawing.h
index 14a0dce..6128e57 100644
--- a/rotord/src/nodes_drawing.h
+++ b/rotord/src/nodes_drawing.h
@@ -10,6 +10,10 @@ namespace Rotor {
public:
Draw_node(){
create_image_input("image input","Image input");
+ create_parameter("x","number","X coordinate","X",0.0f);
+ create_parameter("y","number","Y coordinate","Y",0.0f);
+ create_parameter("scale","number","Scale","Scale",1.0f);
+ create_parameter("rotation","number","Rotation","Rotation",0.0f);
//no title or description as it isn't intended for the user
};
Draw_node(map<string,string> &settings):Draw_node() {
@@ -33,13 +37,22 @@ namespace Rotor {
image.w*4);
cairo_t * cr = cairo_create (cs);
//do any kind of vector drawing
+ cairo_save(cr); //not really even necessary?
+ translate(cr,frame);
vector_output(cr,frame);
+ cairo_restore (cr); //not really even necessary?
//convert frame back to 24 bits
cv::cvtColor(chans,image.rgb,CV_RGBA2BGR,3);
cairo_destroy(cr);
cairo_surface_destroy(cs);
return &image;
}
+ virtual void translate(cairo_t * cr,const Frame_spec &frame){
+ cairo_translate(cr, frame.w/2, frame.h/2);
+ cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h);
+ cairo_scale(cr, parameters["scale"]->value , parameters["scale"]->value );
+ cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI);
+ }
protected:
Colour colour;
private:
@@ -75,7 +88,7 @@ namespace Rotor {
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, parameters["size"]->value*(((float)frame.w)/360.0f));
cairo_text_extents(cr, text.c_str(), &te);
- cairo_move_to (cr,(frame.w-te.width)/2,frame.h*0.6);
+ cairo_move_to (cr,-te.width/2,te.height/2);
cairo_show_text (cr, text.c_str());
cairo_fill(cr);
}
@@ -89,10 +102,6 @@ namespace Rotor {
Shape(){
title="Shape";
description="Draws filled shapes";
- create_parameter("x","number","X coordinate","X",0.0f);
- create_parameter("y","number","Y coordinate","Y",0.0f);
- create_parameter("scale","number","Scale","Scale",1.0f);
- create_parameter("rotation","number","Rotation","Rotation",0.0f);
create_attribute("shape","Shape to draw","Shape","square",{"circle","square","triangle"});
create_attribute("colour","Colour to fill","Colour","FFFFFF");
UID="88c30140-2d0b-11e3-8db2-679d596166c1";
@@ -105,11 +114,6 @@ namespace Rotor {
void vector_output(cairo_t * cr,const Frame_spec &frame){
colour=Colour(attributes["colour"]->value);
cairo_set_source_rgb(cr, colour.Rfloat(),colour.Gfloat(),colour.Bfloat());
- cairo_save(cr); //not really even necessary?
- cairo_translate(cr, frame.w/2, frame.h/2);
- cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h);
- cairo_scale(cr, parameters["scale"]->value , parameters["scale"]->value );
- cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI);
switch(attributes["shape"]->intVal) {
case SHAPE_square:
cairo_rectangle(cr,-frame.w/2,-frame.w/2,frame.w,frame.w);
@@ -125,7 +129,6 @@ namespace Rotor {
cairo_close_path(cr);
break;
}
- cairo_restore (cr); //not really even necessary?
cairo_fill(cr);
}
private:
@@ -135,6 +138,7 @@ namespace Rotor {
Audio_viz(){}
Audio_viz(map<string,string> &settings):Audio_viz() {
base_settings(settings);
+ audioactive=true;
};
~Audio_viz(){};
Audio_viz* clone(map<string,string> &_settings) { return new Audio_viz(_settings);};
@@ -171,7 +175,7 @@ namespace Rotor {
create_attribute("mode","Drawing mode","Mode","line",{"line","fill","both"});
create_attribute("channel","Channel to draw","Channel","left",{"left","right"});
create_parameter("width","number","Line width","Width",1.0f,0.0f,25.0f);
- create_parameter("scale","number","Scale","Scale",1.0f);
+ create_parameter("height","number","Height","Height",1.0f);
create_parameter("alpha","number","Alpha blend","Alpha",1.0f,0.0f,1.0f);
}
Waves(map<string,string> &settings):Waves() {
@@ -186,13 +190,14 @@ namespace Rotor {
if (attributes["mode"]->value=="fill"||attributes["mode"]->value=="both") {
cairo_set_source_rgba(cr, fill.Rfloat(),fill.Gfloat(),fill.Bfloat(),parameters["alpha"]->value);
cairo_save(cr);
- cairo_translate(cr, 0, frame.h/2);
- cairo_scale(cr,1.0f,parameters["scale"]->value);
- cairo_line_to(cr, 0, 0);
+ //cairo_translate(cr, 0, frame.h/2);
+ cairo_translate(cr,-frame.w/2,0);
+ cairo_scale(cr,1.0f,parameters["height"]->value);
+ //cairo_line_to(cr, 0, 0);
for (int i=0;i<frame.w;i++){
cairo_line_to(cr,i,(((int16_t)frame.audio->samples[i*frame.audio->channels]+channel)*frame.h)>>16);
}
- cairo_line_to(cr, frame.w, 0);
+ //cairo_line_to(cr, frame.w/2, 0);
cairo_close_path(cr);
cairo_restore (cr);
@@ -201,8 +206,8 @@ namespace Rotor {
if (attributes["mode"]->value=="line"||attributes["mode"]->value=="both") {
cairo_set_source_rgba(cr, stroke.Rfloat(),stroke.Gfloat(),stroke.Bfloat(),parameters["alpha"]->value);
cairo_save(cr);
- cairo_translate(cr, 0, frame.h/2);
- cairo_scale(cr,1.0f,parameters["scale"]->value);
+ cairo_translate(cr,-frame.w/2,0);
+ cairo_scale(cr,1.0f,parameters["height"]->value);
cairo_set_line_width (cr, parameters["width"]->value);
cairo_line_to(cr, 0, 0);
for (int i=0;i<frame.w;i++){
@@ -223,10 +228,6 @@ namespace Rotor {
Svg(){
title="SVG";
description="Draws svg files";
- create_parameter("x","number","X coordinate","X",0.0f);
- create_parameter("y","number","Y coordinate","Y",0.0f);
- create_parameter("scale","number","Scale","Scale",1.0f);
- create_parameter("rotation","number","Rotation","Rotation",0.0f);
create_attribute("filename","SVG file to draw","Filename","");
UID="88c30140-2d0b-11e3-8db2-679d596166c1";
rsvg=nullptr;
@@ -247,26 +248,23 @@ namespace Rotor {
};
Svg* clone(map<string,string> &_settings) { return new Svg(_settings);};
void vector_output(cairo_t * cr,const Frame_spec &frame){
- //to make it resolution independent
- //translate the difference between screen and drawing
-
if (rsvg){
- float scale=frame.w/dims.width;
-
- cairo_save(cr); //not really even necessary?
- cairo_translate(cr, frame.w/2, frame.h/2);
- cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h);
- cairo_scale(cr, parameters["scale"]->value*scale, parameters["scale"]->value*scale);
- cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI);
- cairo_translate(cr, -frame.w/2, -frame.h/2);
- cairo_translate(cr, frame.w/2-(dims.width/2), frame.h/2-(dims.height/2));
-
rsvg_handle_render_cairo(rsvg,cr);
-
- cairo_restore (cr); //not really even necessary?
cairo_fill(cr);
}
}
+ void translate(cairo_t * cr,const Frame_spec &frame){
+ cerr<<"svg translate "<<frame.time<<endl;
+ //to make it resolution independent
+ //translate the difference between screen and drawing
+ float scale=frame.w/dims.width;
+ cairo_translate(cr, frame.w/2, frame.h/2);
+ cairo_translate(cr, parameters["x"]->value * frame.w, parameters["y"]->value * frame.h);
+ cairo_scale(cr, parameters["scale"]->value*scale, parameters["scale"]->value*scale);
+ cairo_rotate(cr,(parameters["rotation"]->value/180.0f)*M_PI);
+ cairo_translate(cr, -frame.w/2, -frame.h/2);
+ cairo_translate(cr, frame.w/2-(dims.width/2), frame.h/2-(dims.height/2));
+ }
private:
RsvgHandle * rsvg;
RsvgDimensionData dims;