[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kstars-devel
Subject:    Re: [Kstars-devel] [PATCH] Prettier (?) stars
From:       Médéric_Boquien <mboquien () free ! fr>
Date:       2008-08-28 5:43:49
Message-ID: 200808280143.50087.mboquien () free ! fr
[Download RAW message or body]

Hello,

I have polished the patch to make it a bit cleaner and faster. I think it is 
ready for inclusion if you think it looks better than currently.
I have timed the speed difference with 4.1 branch. It is hard to compare 
directly as the number of stars is not the same but it seems to take about the 
same time. For information, on a core 2 Q9450 with a nvidia graphics card 
running the binary driver, with the extended catalogue (setting the number of 
stars on screen to the minimum), fairly zoomed out, it takes ~100ms/image. It 
looks a bit long, especially if we want to increase the number of stars 
displayed.

Regards,

Médéric

Le Thursday 21 August 2008 02:02:21 Jason Harris, vous avez écrit :
> Thanks Mederic.
>
> BTW, note that this shouldn't be any slower than the original star
> images, despite the fact that drawing them is more complicated.  Star
> images are cached and blitted to the screen.  So constructing the star
> image cache will be a bit slower, but that is a very rare operation.
>
> Jason
>
> On Wed, Aug 20, 2008 at 10:32 PM, Médéric Boquien <mboquien@free.fr> wrote:
> > Hello,
> >
> > I have made a patch which modifies the aspect of stars in the "Classic"
> > and "Moonless night" colour schemes. In summary, instead of drawing a
> > coloured annulus around the central white circle, i use the change the
> > saturation and the transparency in function of the radius, so it looks a
> > bit more smooth and blends with the background. The attached patch is
> > included if you want to play and if you find a better transfer function
> > for the saturation and the transparency channels. Note, it is not 100%
> > clean, and i do not expect it to be committed yet. For the most
> > impatient, i have also included a screenshot. What do you think of the
> > new stars. Are they better? Worse? How could they be improved?
> >
> > Thanks,
> >
> > Médéric
> >
> > _______________________________________________
> > Kstars-devel mailing list
> > Kstars-devel@kde.org
> > https://mail.kde.org/mailman/listinfo/kstars-devel


["colors_final.patch" (text/x-patch)]

Index: starobject.cpp
===================================================================
--- starobject.cpp	(révision 853600)
+++ starobject.cpp	(copie de travail)
@@ -240,6 +240,7 @@
 void StarObject::initImages() {
     SkyMap *map = SkyMap::Instance();
     double scale = 1.0;
+    const int starColorIntensity = Options::starColorIntensity();
 
     if ( map && map->scale() > 1.0 ) scale = map->scale();
 
@@ -278,32 +279,40 @@
     }
 
     foreach ( const QString &color, ColorMap.keys() ) {
-        QString imKey = color+"14";
-        QPixmap BigImage( int(14*scale), int(14*scale) ); 
+        QString imKey = color+"15";
+        QPixmap BigImage( static_cast<int>(15*scale), static_cast<int>(15*scale) ); 
         BigImage.fill( Qt::transparent );
 
         QPainter p;
         p.begin( &BigImage );
-        p.setRenderHint(QPainter::Antialiasing, true );
 
-        //Set the width of the pen according to starColorIntensity()
-        float w=2.0*scale;
         if ( Options::starColorMode() == 0 ) {
-            w = w*float(Options::starColorIntensity())/4.0;
-        }
-
-        p.setPen( QPen(ColorMap[color], w) );
-        if ( Options::starColorMode() == 0 ) {
-            p.setBrush( QColor(Qt::white) );
+            int i,j;
+            qreal h, s, v, a;
+            p.setRenderHint( QPainter::Antialiasing, false );
+            QColor starColor = ColorMap[color];
+            starColor.getHsvF(&h, &s, &v, &a);
+            for (i = 0; i < 8; i++ ) {
+                for (j = 0; j < 8; j++ ) {
+                    qreal dist = sqrt( pow( i-7., 2. ) + pow( j-7., 2. ) )/7.;
+                    starColor.setHsvF(h, qMin( 1., dist < \
starColorIntensity/10.?0:dist ), v, qMax( 0., dist < starColorIntensity/20.?1:1-dist \
) ); +                    p.setPen( starColor );
+                    p.drawPoint( i, j );
+                    p.drawPoint( 14-i, j );
+                    p.drawPoint( i, 14-j );
+                    p.drawPoint (14-i, 14-j);
+                }
+            }
         } else {
+            p.setRenderHint(QPainter::Antialiasing, true );
+            p.setPen( QPen(ColorMap[color]) );
             p.setBrush( p.pen().color() );
+            p.drawEllipse( QRectF( 2*scale, 2*scale, 10*scale, 10*scale ) );
         }
-
-        p.drawEllipse( QRectF( 2*scale, 2*scale, 10*scale, 10*scale ) );
         p.end();
         StarImage.insert( imKey, BigImage );
 
-        for ( int size = 13; size > 0; size-- ) {
+        for ( int size = 14; size > 0; size-- ) {
             imKey = color+QString("%1").arg(size);
             StarImage.insert( imKey, BigImage.scaled( size*scale, size*scale, \
Qt::KeepAspectRatio, Qt::SmoothTransformation ) );  }



_______________________________________________
Kstars-devel mailing list
Kstars-devel@kde.org
https://mail.kde.org/mailman/listinfo/kstars-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic