]> git.dabkitsch.com - morphograph.git/commitdiff
fixed bug in drawing code that was causing only half the img to render
authorequilet <2237372+equilet@users.noreply.github.com>
Tue, 23 Jan 2024 02:37:06 +0000 (18:37 -0800)
committerequilet <2237372+equilet@users.noreply.github.com>
Tue, 23 Jan 2024 02:37:06 +0000 (18:37 -0800)
source/morphograph.cpp

index 8af15d9d254d9beaebb29dab52810da471305376..6a805be897cf69d7d6e5011f363965842d9cbde1 100644 (file)
@@ -128,21 +128,6 @@ public:
         //could be a memory leak here
     }
     
-    void begin_shape(){
-            
-        if(shape==std::string("linegraph")){
-            linestr = "<"; //open
-            //default strings for filewriter
-            float tx = (x / float(vecsize)) * float(params->width);
-            float ty = params->height;
-            object_post((t_object *)obj, "ty is: %f", ty);
-            calc_position_info(tx, ty);
-            
-            linestr.append("path d=\"M " + xs + " " + ys + " ");
-        }
-        
-    }
-    
     void eval_drawstyle(){
         switch(drawstyle){
             case 0: //stroke; consider stroke width
@@ -176,6 +161,22 @@ public:
 
     }
     
+    void draw_init(){
+        //any drawing initialization should happen here
+        
+        if(shape==std::string("linegraph")){
+            linestr = "<"; //open
+            //default strings for filewriter
+            float tx = (x / float(vecsize)) * float(params->width);
+            float ty = params->height;
+            object_post((t_object *)obj, "ty is: %f", ty);
+            calc_position_info(tx, ty);
+            
+            linestr.append("path d=\"M " + xs + " " + ys + " ");
+        }
+        
+    }
+    
     void draw(){
 
         lws = std::to_string(linewidth);
@@ -456,7 +457,7 @@ public:
         for (unsigned i = 0; i < layers.size(); ++i) {
             //how do we know that energy's size is the size of a vector???
             //need to look into this
-            long vsize = layers[i].desc.energy.size();
+            long vsize = layers[i].desc.energy.size() / 2;
             
             //j represents the analysis frame
             //why do we need to skip analysis frames?
@@ -468,8 +469,7 @@ public:
             swrite.set_drawstyle(x->l_style->s_name);
             swrite.set_vecsize(vsize);
             
-
-            swrite.begin_shape();
+            swrite.draw_init();
             
             for (unsigned j = 0; j < vsize; j += skip_by) {