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 » Community » Newbie corner » smoother drawing
Re: smoother drawing [message #27692 is a reply to message #27682] Thu, 29 July 2010 16:56 Go to previous messageGo to previous message
mr_ped is currently offline  mr_ped
Messages: 825
Registered: November 2005
Location: Czech Republic - Praha
Experienced Contributor
Ok, some upp "magic" for you, or how I would proceed further:

Select the PainterExamples package
Open Examples.h

.. notice the line with virtual void Paint(Draw& w); declaration, after all you told me you draw your things there, right? So move on that line with cursor on the "Paint" word.

Now Alt+J.

You should end in main.cpp at line 80 with function definition.

And that was quite easy to understand for me, because I recently did some code with Image/ImageBuffer/RasterImage/Painter and other upp classes of that family. For you it will be maybe more cryptic, so here we go:

	Size sz = GetSize();    //size of painting area of window
	if(ctrl.transparent) {  //this will create the color chessboard background if you tick that checkbox in app, otherwise the background is white
		for(int y = 0; y < sz.cy; y += 32)
			for(int x = 0; x < sz.cx; x += 32)
				w.DrawRect(x, y, 32, 32, (x ^ y) & 32 ? Color(254, 172, 120) : Color(124, 135, 253));
		//notice it's drawn into the old Draw thing without new Painter
	}
	ImageBuffer ib(sz);   //this is raw RGBA memory array for SW rendering (allocating the "canvas" for Painter)

//here's the Painter class finally - BufferPainter is nothing more than
//Painter class extended to paint into ImageBuffer, which was created a line above
	BufferPainter sw(ib, ctrl.quality);  //init it with desired ImageBuffer and desired antialiasing mode (from GUI control)
	DoPaint(sw);   //some custom function which does the actual drawing and I didn't bother to look inside
//of course just go on the DoPaint with cursor and hit Alt+J to see what's there, if you are curious enough
//but basically you just need to do sw.drawEllipse, etc.. as you wish     

	w.DrawImage(0, 0, ib);
//and the resulting SW rendered RGBA image is rendered back to OS's window area represented by the original Draw& w instance.


Looks simple to me, but I'm used to UPP, so keep asking if you don't get anything, I will try to explain better. Smile (but later, going off now)
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to adjust the height of an InfoCtrl frame’s height.
Next Topic: Initial settings for U++ application
Goto Forum:
  


Current Time: Fri May 10 17:29:33 CEST 2024

Total time taken to generate the page: 0.02414 seconds