Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Any function to draw gradient color?
Re: Any function to draw gradient color? [message #11382 is a reply to message #8196] Mon, 10 September 2007 19:07 Go to previous messageGo to previous message
piratalp is currently offline  piratalp
Messages: 26
Registered: September 2007
Location: Argentina
Promising Member
mobilehunter wrote on Sat, 17 February 2007 11:24

Hi Mirek,
This is my code modified from msdn examples. Hope i did the correct way. Btw where do you use GradientColor function?
edited: Ah sorry my code only fill to rectangular shape
void DrawRect(Draw& w,Rect rectClient,Color fromColor,Color toColor,int level)
{
  Rect rectFill;          // Rectangle for filling band
  float fStep;            // How large is each band?
	
  int iOnBand;  // Loop index
// Determine how large each band should be in order to cover the
// client with 256 bands (one for every color intensity level)
	
  fStep = (float)rectClient.bottom / level*1.0f;
	
// Start filling bands
  for (iOnBand = 0; iOnBand < level; iOnBand++) 
  {
	// Set the location of the current band	
	rectFill.Set(rectClient.left,rectClient.top+(int)(iOnBand * fStep), 
rectClient.right,rectClient.top+(int)((iOnBand+1) * fStep));
	w.DrawRect(rectFill, GradientColor(fromColor,toColor,iOnBand,level));	
  }
}

example usage:
  DrawRect(w,Rect(10,10,70,80),Yellow(),Black(),256);



There is a much easier way for drawing a gradient:

void DrawGradient(Draw &w, Rect r, Color c1, Color c2)
{
int i;

   for (i = r.top; i <= r.bottom; i++)
      w.DrawLine(i, r.left, i, r.right, GradientColor(c1, c2, i - r.Top, r.Height());
}


That's all

NOTE: I've just wrote it in seconds from what's in my mind, I've done a Ribbon Chameleon Skin for Ultimate++ that can render both Office 2003 and Office 2007 styles with any combination of colors, I would like to contribute it to Ultimate++ but I'll have to add some code to Chameleon to support very basic things like Palettes and also change some widgets that have no ChPaint calls, how can I stay in synch with development version (uvs?)? Mirek?

Regards, Mauricio
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Image zoom widget?
Next Topic: Bug in Picture Class
Goto Forum:
  


Current Time: Mon Jun 10 17:07:04 CEST 2024

Total time taken to generate the page: 0.01751 seconds