[haiku-commits] r40112 - haiku/trunk/src/add-ons/screen_savers/butterfly

  • From: leavengood@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 4 Jan 2011 19:57:24 +0100 (CET)

Author: leavengood
Date: 2011-01-04 19:57:24 +0100 (Tue, 04 Jan 2011)
New Revision: 40112
Changeset: http://dev.haiku-os.org/changeset/40112

Modified:
   haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp
Log:
Use a real random number generator instead of using a time hack. Add myself to
authors.


Modified: haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp
===================================================================
--- haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp       
2011-01-04 18:00:43 UTC (rev 40111)
+++ haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp       
2011-01-04 18:57:24 UTC (rev 40112)
@@ -4,13 +4,14 @@
  *
  * Authors:
  *             Geoffry Song, goffrie@xxxxxxxxx
+ *             Ryan Leavengood, leavengood@xxxxxxxxx
  */
 #include "Butterfly.h"
 
 #include <math.h>
 #include <stdlib.h>
-#include <sys/time.h>
 
+#include <OS.h>
 #include <View.h>
 
 #include <BuildScreenSaverDefaultSettingsView.h>
@@ -50,9 +51,10 @@
 
        SetTickSize(20000);
 
-       struct timeval tv;
-       gettimeofday(&tv, NULL);
-       fBase = tv.tv_usec * 0.01f;
+       // Set fBase to a random radian value scaled by 1000. The scaling 
produces
+       // more interesting results.
+       srand48(system_time());
+       fBase = drand48() * 2 * M_PI * 1000;
 
        // calculate transformation
        BRect bounds = view->Bounds();


Other related posts:

  • » [haiku-commits] r40112 - haiku/trunk/src/add-ons/screen_savers/butterfly - leavengood