[haiku-commits] Re: r40098 - in haiku/trunk/src/add-ons/screen_savers: . butterfly leaves

  • From: Jérôme Duval <korli@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 4 Jan 2011 09:45:37 +0100

2011/1/4  <leavengood@xxxxxxxxx>:
> Added: haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp
> ===================================================================
> --- haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp             
>                   (rev 0)
> +++ haiku/trunk/src/add-ons/screen_savers/butterfly/Butterfly.cpp       
> 2011-01-04 01:10:59 UTC (rev 40098)
> @@ -0,0 +1,161 @@
> +
> +#include <stdlib.h>
> +#include <math.h>
> +#include <sys/time.h>

Inclusion order is wrong.

> +
> +#include <View.h>
> +
> +#include <BuildScreenSaverDefaultSettingsView.h>
> +
> +
> +const float kOneSixth = 0.1666666666666666666f; // 1/2 * 1/3

I'd let the compiler compute this itself.
> +       struct timeval tv;
> +       gettimeofday(&tv, NULL);
> +       fT = tv.tv_usec * 0.01f;

The name fT doesn't look very meaningful. BTW why not use
system_time() instead of gettimeofday().

> +inline BPoint
> +Butterfly::_Iterate()
> +{
> +       float r = powf(2.718281828f, cosf(fT))
> +               - 2.f * cosf(4.f * fT)
> +               - powf(sinf(fT / 12.f), 5.f);

M_E should be used. I don't understand the use of the point with no
digit afterwards.

> +class Butterfly : public BScreenSaver {
> +public:
> +                                               Butterfly(BMessage* archive, 
> image_id imageId);
> +
> +       virtual void            StartConfig(BView* view);
> +       virtual status_t        StartSaver(BView* view, bool preview);
> +       virtual void            Draw(BView* view, int32 frame);
> +

A virtual destructor is needed.

Bye,
Jérôme

Other related posts: