Home » Community » Newbie corner » smoother drawing
Re: smoother drawing [message #27692 is a reply to message #27682] |
Thu, 29 July 2010 16:56   |
mr_ped
Messages: 826 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. (but later, going off now)
|
|
|
 |
|
smoother drawing
By: cullam on Thu, 29 July 2010 14:33
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 15:10
|
 |
|
Re: smoother drawing
By: cullam on Thu, 29 July 2010 15:52
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 16:10
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 16:12
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 16:27
|
 |
|
Re: smoother drawing
By: cullam on Thu, 29 July 2010 16:42
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 16:56
|
 |
|
Re: smoother drawing
By: mr_ped on Thu, 29 July 2010 17:06
|
 |
|
Re: smoother drawing
By: cullam on Thu, 29 July 2010 18:11
|
 |
|
Re: smoother drawing
By: cullam on Thu, 29 July 2010 19:43
|
 |
|
Re: smoother drawing
By: mr_ped on Fri, 30 July 2010 10:08
|
 |
|
Re: smoother drawing
By: koldo on Fri, 30 July 2010 21:58
|
Goto Forum:
Current Time: Mon Apr 28 06:16:06 CEST 2025
Total time taken to generate the page: 0.00607 seconds
|