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 #8196 is a reply to message #8140] Sat, 17 February 2007 15:24 Go to previous messageGo to previous message
mobilehunter is currently offline  mobilehunter
Messages: 87
Registered: November 2006
Member
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);

[Updated on: Sat, 17 February 2007 15:30]

Report message to a moderator

 
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 May 12 18:12:18 CEST 2025

Total time taken to generate the page: 0.00383 seconds