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 backgroundImagePtr progressFlt fSpeed)
   {
      
m_Background background;
      
m_Progress progress;
      
m_fSpeed fSpeed;      
   }
   
RotatingProgressBarcreate(C Rectrect)
   {
      
super.create(rect);
      
m_Background UID(358369789911914454273995744696973341463);
      
m_Progress UID(22296874011230117889258996991361919290);
      return 
T;
   }
   
   
virtual void draw(C GuiPCgpc);
   
   
ImagePtr m_Background;
   
ImagePtr m_Progress;
   
Flt m_fSpeed;     // degrees per second
   
Flt m_fProgress;
}

// ----------------------------------------------------------
void RotatingProgressBar::draw(C GuiPCgpc)
{
   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(widthheight);
   
Vec2 center rect().center() + gpc.offset;

   
// draw background right
   
m_Background->drawRotate(centersize0.0f);
   
   
// draw progress right
   
if (m_fProgress 0.5f)
      
m_Progress->drawRotate(centersizefAngle);
   else
      
m_Progress->drawRotate(centersize0.0f);
   
   
// draw background left
   
m_Background->drawRotate(centersizePI);
   
   
// draw progress left
   
if (m_fProgress >= 0.5f)
      
m_Progress->drawRotate(centersizefAngle);



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