gzz-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gzz-commits] gzz/gfx librenderables/renderables.py demo/cale...


From: Matti Katila
Subject: [Gzz-commits] gzz/gfx librenderables/renderables.py demo/cale...
Date: Fri, 01 Nov 2002 08:38:23 -0500

CVSROOT:        /cvsroot/gzz
Module name:    gzz
Changes by:     Matti Katila <address@hidden>   02/11/01 08:38:22

Modified files:
        gfx/librenderables: renderables.py 
        gfx/demo       : calendarvobtest.py 

Log message:
        CalendarVob works ok.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/librenderables/renderables.py.diff?tr1=1.120&tr2=1.121&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gfx/demo/calendarvobtest.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: gzz/gfx/demo/calendarvobtest.py
diff -u gzz/gfx/demo/calendarvobtest.py:1.7 gzz/gfx/demo/calendarvobtest.py:1.8
--- gzz/gfx/demo/calendarvobtest.py:1.7 Thu Oct 31 12:34:07 2002
+++ gzz/gfx/demo/calendarvobtest.py     Fri Nov  1 08:38:22 2002
@@ -30,22 +30,23 @@
         gzz.vob.CalendarVob.setStatics(style_date, style_n, 2)
 
         # week number width, weekday height, month name height
-        gzz.vob.CalendarVob.setBounds(0.6, 0.5, 1.0)
+        gzz.vob.CalendarVob.setBounds(0.4, 0.5, 1.0)
 
         # scales: date, weeknum, weekday, month
         gzz.vob.CalendarVob.setScales(1.1, 0.55, 0.24, 1.3)
 
         # shift(something(x,y)): date, weeknum, weekday, month
-        gzz.vob.CalendarVob.setShifting(0.075, 0.55, 0.20, 1.1)
+        gzz.vob.CalendarVob.setShifting(0.15, 0.85, 0.0, 0.1)
 
         
        
         # annual calendar
         for i in range(1, 13):
-            cs_cal = vs.coords.affineCoordsys(cs_home , 0, 0 , i*9,  1,0,0,1)
+            cs_cal = vs.coords.affineCoordsys(cs_home , 0, 0 , i*9,  1.5, 0, 
0, 1.15)
             vs.matcher.add(cs_cal, "cs_cal"+str(i))
 
-            cs_text = vs.coords.affineCoordsys(cs_home, 0, 0, 0, 1.0, 0, 0, 
1.0)
+            cs_text = vs.coords.affineCoordsys(0, 0, 0, 0,w*self.scale, 0,0, 
h*self.scale)
+
             vs.matcher.add(cs_text, "cs_text"+str(i))
 
             vs.map.put(gzz.vob.CalendarVob(2002, i), cs_cal, cs_text)
Index: gzz/gfx/librenderables/renderables.py
diff -u gzz/gfx/librenderables/renderables.py:1.120 
gzz/gfx/librenderables/renderables.py:1.121
--- gzz/gfx/librenderables/renderables.py:1.120 Fri Nov  1 04:35:41 2002
+++ gzz/gfx/librenderables/renderables.py       Fri Nov  1 08:38:22 2002
@@ -1190,35 +1190,20 @@
             float scale;
             ZPt orig;
             
-           Vertexer(Coords &c, float scale, ZPt orig) : c(c), scale(scale), 
orig(orig) { }
+           Vertexer(Coords &c, float scale, ZPt orig) :
+                c(c), scale(scale), orig(orig) { }
 
            template<class T> void operator()(const T &x, const T &y) {
-            /*  horiz text 2
-               ZPt tmp(x + 1, y - orig_y + 1, 0);
-                tmp.x *= scale; tmp.y *= scale;
-                tmp.x -= 1; tmp.y += orig_y - 1;
-            */
-            /*
-               ZPt tmp(x, y, 0);
-                tmp.x *= scale; tmp.y *= scale;
-                tmp.x += orig.x; tmp.y += orig.y;
-            */
-            
-                ZPt tmp(x, y, 0);
 
-                orig.x *= scale; 
-                orig.y *= scale;
+                ZPt tmp(x*scale, y*scale, 0);
 
-                tmp.x -= orig.x;
-                tmp.y -= orig.y;
-                
-                tmp.x *= scale;
-                tmp.y *= scale;
+                tmp = c.transform(tmp);
 
                 tmp.x += orig.x;
                 tmp.y += orig.y;
 
-               c.vertex(tmp);
+                // already transformed from coords1, so:
+                glVertex3f(tmp.x, tmp.y, tmp.z);
            }
        };
        """,
@@ -1231,9 +1216,6 @@
             int weeks = (days + empty_days) / 7;
             if ( (days + empty_days) % 7 != 0) weeks++;
 
-            // Coordinating system
-            ZPt cs;
-
             glDisable(GL_TEXTURE_2D);
 
             glLineWidth(linewidth);
@@ -1242,93 +1224,73 @@
             glBegin(GL_LINES);
 
               // left -vert
-              cs = coords1.transform( ZPt(0.0, 0.0, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
-              cs = coords1.transform( ZPt(0.0, weeks + weekday_h + 
month_name_h, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
+              coords1.vertex( ZPt(0.0, 0.0, 0.0) );
+              coords1.vertex( ZPt(0.0, weeks + weekday_h + month_name_h, 0.0) 
);
 
               // right -vert
-              cs = coords1.transform( ZPt(7.0+ week_num_w, 0.0, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
-              cs = coords1.transform( ZPt(7.0+ week_num_w, weeks + weekday_h + 
month_name_h, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
+              coords1.vertex( ZPt(7.0+ week_num_w, 0.0, 0.0) );
+              coords1.vertex( ZPt(7.0+ week_num_w, weeks + weekday_h + 
month_name_h, 0.0) );
 
               // weekday - horiz
-              cs = coords1.transform( ZPt(0.0, month_name_h, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
-              cs = coords1.transform( ZPt(7.0+week_num_w, month_name_h, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
-
-              // top - horiz line
-              cs = coords1.transform( ZPt(0.0, 0.0, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
-              cs = coords1.transform( ZPt(7.0+week_num_w, 0.0, 0.0) );
-              glVertex3f(cs.x, cs.y, cs.z);
+              coords1.vertex( ZPt(0.0, month_name_h, 0.0) );
+              coords1.vertex( ZPt(7.0+week_num_w, month_name_h, 0.0) );
               
+              // top - horiz line
+              coords1.vertex( ZPt(0.0, 0.0, 0.0) );
+              coords1.vertex( ZPt(7.0+week_num_w, 0.0, 0.0) );
 
               // Calendar:
               // Vertical lines.
               for (int i=0; i<7; i++) {
-                  cs = coords1.transform( ZPt(i + week_num_w, month_name_h, 
0.0) );
-                  glVertex3f(cs.x, cs.y, cs.z);
-
-                  cs = coords1.transform( ZPt(i + week_num_w, month_name_h + 
weeks + weekday_h, 0.0) );
-                  glVertex3f(cs.x, cs.y, cs.z);
+                  coords1.vertex( ZPt(i + week_num_w, month_name_h, 0.0) );
+                  coords1.vertex( ZPt(i + week_num_w, month_name_h + weeks + 
weekday_h, 0.0) );
               }
               // Horizontal lines.
               for (int i=0; i<=weeks; i++) {
-                  cs = coords1.transform( ZPt(0.0, i+month_name_h+weekday_h, 
0.0) );
-                  glVertex3f(cs.x, cs.y, cs.z);
-
-                  cs = coords1.transform( ZPt(7.0+week_num_w, 
i+month_name_h+weekday_h, 0.0) );
-                  glVertex3f(cs.x, cs.y, cs.z);
+                  coords1.vertex( ZPt(0.0, i+month_name_h+weekday_h, 0.0) );
+                  coords1.vertex( ZPt(7.0+week_num_w, 
i+month_name_h+weekday_h, 0.0) );
               }
             glEnd();
 
             glEnable(GL_TEXTURE_2D);
-
-            ZPt p_text(2,2,0);
-            p_text = coords2.transform(p_text);
-
-            float date_shift = shifts[0];
             float date_scale = scales[0];
 
-            Vertexer<Coords> v_date(coords1, date_scale, p_text);
-
             for (int i=1; i<=days; i++) {
                 int column = (empty_days + i -1) % 7;
-                int row  = 1 + (empty_days + i -1) / 7; 
+                int row  =1+ (empty_days + i -1) / 7; 
 
                 static char buffer[64];
                 sprintf(buffer, "%i", i);
 
-                float fcol, frow;
-
-                fcol = week_num_w;
-                frow = weekday_h + month_name_h;
+                float fcol = week_num_w;
+                float frow = weekday_h + month_name_h;
 
                 if (i<10) {
-                    fcol += column + date_shift + 0.20;
-                    frow += row - date_shift - 0.15;
+                    fcol += column + 0.20;
+                    frow += row - 0.15;
                 } else {
-                    fcol += column + date_shift;
-                    frow += row - date_shift - 0.15;
+                    fcol += column;
+                    frow += row - 0.15;
                 }
 
                 glColor3f(1.0, 1.0, 1.0);
+
+                Vertexer<Coords> v_date(coords2, date_scale,
+                                        coords1.transform(ZPt(fcol, frow,0))
+                );
                 
                Text::renderIter(*r_date, buffer, buffer+strlen(buffer), 
-                     fcol*(1/date_scale) , frow*(1/date_scale), v_date
-                     //fcol, frow, v_date
+                     shifts[0], -shifts[0],
+                     v_date
                );
 
+                // use red for sundays..
                 if (column == 6) glColor3f(1.0, 0.0, 0.0);
                 else  glColor3f(0.0, 0.0, 0.0);
 
-               Text::renderIter(*r_date, buffer, buffer+strlen(buffer), 
-                     (fcol + 0.03)*(1/date_scale),
-                     (frow + 0.03)*(1/date_scale),
-                     v_date
+               Text::renderIter(*r_date, buffer, buffer+strlen(buffer),
+                    shifts[0] + 0.03, -shifts[0] + 0.03,
+                    v_date
                );
 
             }
@@ -1337,40 +1299,45 @@
 
             // Week numbers
             float week_num_scale = scales[1];
-           Vertexer<Coords> v_week_num(coords1, week_num_scale, p_text);
-
             for (int i=0; i<weeks; i++) {
+               Vertexer<Coords> v_week_num(coords2, week_num_scale,
+                    coords1.transform(ZPt(0, month_name_h + weekday_h + i,0))
+                );
+                    
                 static char buffer[64];
                 sprintf(buffer, "%i", first_week_number + i);
 
                Text::renderIter(*r, buffer, buffer+strlen(buffer), 
-                     (0.1)*(1/week_num_scale),
-                     (month_name_h + weekday_h + i + 
shifts[1])*(1/week_num_scale),
-                     v_week_num
+                    0.1, shifts[1],
+                    v_week_num
                );
             
             }
 
+
             // Weekdays
             float weekday_scale = scales[2];
-           Vertexer<Coords> v_weekday(coords1, weekday_scale, p_text);
-
             for (int i=0; i<7; i++) {
+
+               Vertexer<Coords> v_weekday(coords2, weekday_scale,
+                    coords1.transform(ZPt(week_num_w + i + 0.1, month_name_h + 
weekday_h - 0.15, 0 ))
+                );
+            
                Text::renderIter(*r, d_txt[i].begin(), d_txt[i].end(), 
-                     (week_num_w + i+ 0.1)*(1/weekday_scale),
-                     (month_name_h + weekday_h - shifts[2]) * 
(1/weekday_scale),
-                     v_weekday
+                    0, shifts[2],
+                    v_weekday
                );
             }
 
 
             // Month name
             float month_name_scale = scales[3];
-           Vertexer<Coords> v_month(coords1, month_name_scale, p_text);
+           Vertexer<Coords> v_month(coords2, month_name_scale,
+                coords1.transform(ZPt(week_num_w, month_name_h - 0.15, 0))
+            );
 
             Text::renderIter(*r, m_txt.begin(), m_txt.end(), 
-                (week_num_w+shifts[3])*(1/month_name_scale),  // x
-                (month_name_h-0.15)*(1/month_name_scale), // y
+                shifts[3], 0,
                 v_month
             );
             




reply via email to

[Prev in Thread] Current Thread [Next in Thread]