]> granicus.if.org Git - poly2tri-c/commitdiff
Fix some small compilation errors
authorBarak Itkin <lightningismyname@gmail.com>
Sat, 5 May 2012 14:32:37 +0000 (17:32 +0300)
committerBarak Itkin <lightningismyname@gmail.com>
Sat, 5 May 2012 14:32:37 +0000 (17:32 +0300)
bin/main.c
render/svg-plot.c

index 5bceab111443ff1372fabd67b86f7f80bae8d107..68c02f32a9f5f93db1b6ad37ac2ac5315ff57894 100755 (executable)
@@ -163,6 +163,21 @@ read_points_file (const gchar       *path,
 #define P2TC_MAX_PATH PATH_MAX
 #endif
 
+/* Calculate a "deterministic random" color for each point
+ * based on its memory address. Since we know that least-significant bytes
+ * of the point address will change more than the mor-important ones, we
+ * make sure to take them into consideration in all the color channels.
+ */
+static void
+test_point_to_color (P2trPoint* point, gfloat *dest, gpointer user_data)
+{
+  gulong value = (gulong) point;
+  guchar b1 = value & 0xff, b2 = (value & 0xff00) >> 2, b3 = (value & 0xff0000) >> 4;
+  dest[0] = b1 / 255.0f;
+  dest[1] = (b1 ^ b2) / 255.0f;
+  dest[2] = (b1 ^ b2 ^ b3) / 255.0f;
+}
+
 gint main (int argc, char *argv[])
 {
   FILE *out;
@@ -244,7 +259,7 @@ gint main (int argc, char *argv[])
 
   im = g_new (gfloat, imc.cpp * imc.x_samples * imc.y_samples);
 
-  p2tr_mesh_render_scanline (dt->mesh->mesh, im, &imc, p2tr_test_point_to_color, NULL);
+  p2tr_mesh_render_scanline (dt->mesh->mesh, im, &imc, test_point_to_color, NULL);
 
   p2tr_write_ppm (out, im, &imc);
   fclose (out);
index f056de6a1ef5fc3fb1a7fc1ca889e4a898422104..6f12fcd909231f72fea878bc523c8a1adc23aca8 100755 (executable)
@@ -119,7 +119,7 @@ void
 p2tr_plot_svg_plot_triangle (P2trTriangle *self, const gchar* color, FILE* outfile)
 {
   P2trCircle c;
-  p2tr_triangle_circumcircle (self, &c);
+  p2tr_triangle_get_circum_circle (self, &c);
   p2tr_plot_svg_plot_edge (self->edges[0], color, outfile);
   p2tr_plot_svg_plot_edge (self->edges[1], color, outfile);
   p2tr_plot_svg_plot_edge (self->edges[2], color, outfile);
@@ -135,7 +135,7 @@ p2tr_plot_svg (P2trMesh *T, FILE *outfile)
   P2trHashSetIter  siter;
   P2trTriangle    *tr;
 
-  p2tr_debug ("Starting to write SVG output\n");
+  g_debug ("Starting to write SVG output\n");
   p2tr_plot_svg_plot_init (outfile);
 
   p2tr_hash_set_iter_init (&siter, T->triangles);
@@ -143,5 +143,5 @@ p2tr_plot_svg (P2trMesh *T, FILE *outfile)
     p2tr_plot_svg_plot_triangle (tr, "black", outfile);
 
   p2tr_plot_svg_plot_end (outfile);
-  p2tr_debug ("Finished writing SVG output\n");
-}
\ No newline at end of file
+  g_debug ("Finished writing SVG output\n");
+}