[Kstars-devel] KDE/kdeedu/kstars/kstars/skyobjects

Médéric Boquien mboquien at free.fr
Mon Nov 2 22:44:05 CET 2009


On Monday 02 November 2009 16:11:50 Alexey Khudyakov wrote:
> @@ -294,8 +322,13 @@
>              starColor.getHsvF(&h, &s, &v, &a);
>              for (int i = 0; i < 8; i++ ) {
>                  for (int j = 0; j < 8; j++ ) {
> -                    qreal dist = sqrt( pow( i-7., 2. ) + pow( j-7., 2. )
> )/7.; -                    starColor.setHsvF(h, qMin( qreal(1), dist <
> (10-starColorIntensity)/10.?0:dist ), v, qMax( qreal(0), dist <
> (10-starColorIntensity)/20.?1:1-dist ) );
> +                    qreal x = i - 7;
> +                    qreal y = j - 7;

If i am not mistaken, x=i-7 could be moved one level up. Also, i have a naive 
question, won't it recreate the variables each time the inner loop is 
restarted? Wouldn't it be more efficient to create them outside the loops?

> +                    qreal dist = sqrt( x*x + y*y ) / 7.0;
> +                    starColor.setHsvF(h,
> +                                      qMin( qreal(1), dist <
> (10-starColorIntensity)/10.0 ? 0 : dist ), +                               
>       v,
> +                                      qMax( qreal(0), dist <
> (10-starColorIntensity)/20.0 ? 1 : 1-dist ) ); p.setPen( starColor );
>                      p.drawPoint( i, j );
>                      p.drawPoint( 14-i, j );

Regards,

Médéric


More information about the Kstars-devel mailing list