About Store Forum Documentation Contact



Post Reply 
Avoiding edges around rendered images
Author Message
MrPi Offline
Member

Post: #1
Avoiding edges around rendered images
I'm trying to realize a circular progress bar with this code for testing:
PHP Code:
// ---------------------------------------------------------------
class RotatingProgressBar : GuiCustom
{
   
RotatingProgressBar()
   {
      
m_Background = NULL;
      
m_Progress = NULL;
      
Reset();            
   }
   
void Reset()
   {
      
m_fProgress = 0.0f;
      
m_fSpeed = PI/4;
   }
   
void Init(ImagePtr background, ImagePtr progress, Flt fSpeed)
   {
      
m_Background = background;
      
m_Progress = progress;
      
m_fSpeed = fSpeed;      
   }
   
RotatingProgressBar& create(C Rect& rect)
   {
      
super.create(rect);
      
m_Background = UID(3583697899, 1191445427, 3995744696, 973341463);
      
m_Progress = UID(222968740, 1123011788, 925899699, 1361919290);
      return 
T;
   }
   
   
virtual void draw(C GuiPC& gpc);
   
   
ImagePtr m_Background;
   
ImagePtr m_Progress;
   
Flt m_fSpeed;     // degrees per second
   
Flt m_fProgress;
}

// ----------------------------------------------------------
void RotatingProgressBar::draw(C GuiPC& gpc)
{
   if (!
gpc.visible || !visible() || !m_Background || !m_Progress)
      return;

   
D.clip(gpc.clip);
      
   
m_fProgress += 0.2 * Time.d();
   if (
m_fProgress >= 1.0f)
      
m_fProgress -= 1.0f;

   
Flt fAngle = PI - (m_fProgress * PI2);
      
   
Flt width = rect().w();
   
Flt height = rect().h();
   
Vec2 size(width, height);
   
Vec2 center = rect().center() + gpc.offset;

   
// draw background right
   
m_Background->drawRotate(center, size, 0.0f);
   
   
// draw progress right
   
if (m_fProgress < 0.5f)
      
m_Progress->drawRotate(center, size, fAngle);
   else
      
m_Progress->drawRotate(center, size, 0.0f);
   
   
// draw background left
   
m_Background->drawRotate(center, size, PI);
   
   
// draw progress left
   
if (m_fProgress >= 0.5f)
      
m_Progress->drawRotate(center, size, fAngle);
} 


It is using two half circles, one for the background and the other for the progress. I can't get it to look quite the way I want. There are always edges on the blue part, see image.
   
It's not in the image, I tested it in Photoshop. These are the images I used.
       

How can I avoid these edges? Or is there a better way to achieve what I want?
11-28-2013 12:12 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Avoiding edges around rendered images
Hi,

Please see that your texture has white pixels where the opacity is zero, due to texture filtering, they get blended together with the blue ones, which is possibly the source of your problem.
11-30-2013 07:46 AM
Find all posts by this user Quote this message in a reply
MrPi Offline
Member

Post: #3
RE: Avoiding edges around rendered images
I fixed it by using a TGA with only the color as RGB and the alpha as A. Now it's very clean.
11-30-2013 07:31 PM
Find all posts by this user Quote this message in a reply
Post Reply