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 » Draw/Paint speed slow
Draw/Paint speed slow [message #39112] Sat, 16 February 2013 10:30 Go to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi,

I am making spirograph ( Epitrochoid/Hypotrochoid curves) drawing app. Paint derived from Examples/PainterExamples.

I have attached the project.

To draw spirograph with 12300 path points my routine take approximately 500 ms.

Want some suggestions to improve speed of draw.

I want to show animation like this

http://en.wikipedia.org/wiki/File:EpitrochoidOn3-generation. gif

Logged time data

Prepare S : 17183790
Prepare E : 17183790

Time paint0 start : 17183806
Time paint0 end  : 17185335

 Path points : 12313

Draw Image S : 17185335
Draw Image E : 17185350
  • Attachment: GeoFun.7z
    (Size: 2.73KB, Downloaded 280 times)


Warm Regards

Deepak
Re: Draw/Paint speed slow [message #39120 is a reply to message #39112] Sat, 16 February 2013 19:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Not sure what is your CPU, but mine 2.6Ghz Celeron does it in 25ms.

Do you benchmark it in Optimal mode? (For painter there is a HUGE difference...)

About optimizations:

The only thing that comes to mind is to combine all lines (or those possible with same width and color) lines into single Stroke, something like (quick fix):

		for(int i = 0; i < data.GetCount(); i++) {
			Vector<Pointf>& p = data[i].point;
			sw.Move(x1 + p[0].x, y1 + p[0].y);
	
			cnt2 = p.GetCount();
			
			for(int j = 1; j < p.GetCount(); j++)  
				sw.Line(x1 + p[j].x, y1 + p[j].y);
	
	//		if(data[i].filled)  sw.Fill(data[i].color).EvenOdd(true);
		}
		sw.Stroke(data[0].penwidth, data[0].color);


Anyway, it appears to only improve speed by 10%...

Mirek
Re: Draw/Paint speed slow [message #39125 is a reply to message #39120] Sun, 17 February 2013 07:40 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Mirek,

Thank you for response.

I have i7 1.73 Gz processor.

In my test case all lines are same width and color.

When compiled "Release->optimal" and "Release->optimised for speed" It is working much faster. I get about 40 ms time for same result.

1. Any hint on animation. For incremental Draw/Paint.
2. For filling the colors like in enclosed image. Hints on how to achieve it.

index.php?t=getfile&id=4061&private=0
  • Attachment: fig1.png
    (Size: 46.33KB, Downloaded 668 times)


Warm Regards

Deepak
Re: Draw/Paint speed slow [message #39126 is a reply to message #39125] Sun, 17 February 2013 09:12 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
deep wrote on Sun, 17 February 2013 01:40

Mirek,

Thank you for response.

I have i7 1.73 Gz processor.

In my test case all lines are same width and color.

When compiled "Release->optimal" and "Release->optimised for speed" It is working much faster. I get about 40 ms time for same result.

1. Any hint on animation. For incremental Draw/Paint.



examples/AnimatedHello


Quote:


2. For filling the colors like in enclosed image. Hints on how to achieve it.



Not sure, but perhaps draw it twice with different winding rule?

Mirek
Re: Draw/Paint speed slow [message #39127 is a reply to message #39126] Sun, 17 February 2013 10:38 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Quote:

Not sure, but perhaps draw it twice with different winding rule?


What is 'Winding rule'?

When I use fill sw.Fill(Blue()) it fills the total shape to outer boundary.

This is a single closed curve intersecting to self multiple times. Is there any way to find bounding curve and fill color like mspaint does.



Warm Regards

Deepak
Re: Draw/Paint speed slow [message #39128 is a reply to message #39127] Sun, 17 February 2013 10:55 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Painter::EvenOdd, try with "true".
Re: Draw/Paint speed slow [message #39129 is a reply to message #39128] Sun, 17 February 2013 11:09 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
sw.Fill(Yellow()).EvenOdd(true);


Gives full fill with single color.


Warm Regards

Deepak
Re: Draw/Paint speed slow [message #39182 is a reply to message #39129] Sun, 24 February 2013 14:30 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sw.EvenOdd(true).Fill(Yellow());
Re: Draw/Paint speed slow [message #39183 is a reply to message #39182] Mon, 25 February 2013 07:20 Go to previous message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
Hi Mirek,

Thanks, It worked.
Sequence is important. First set EvenOdd and then Fill.

I checked with gradient Fill also.

Is there any method to specify even and odd colors?

In this sample image I drawn circle first with gradient and then Spirograph.

index.php?t=getfile&id=4069&private=0
  • Attachment: Image1.png
    (Size: 68.98KB, Downloaded 564 times)


Warm Regards

Deepak

[Updated on: Mon, 25 February 2013 07:22]

Report message to a moderator

Previous Topic: Crash in Painter
Next Topic: ScatterDraw/ScatterCtrl new features
Goto Forum:
  


Current Time: Thu Mar 28 14:24:32 CET 2024

Total time taken to generate the page: 0.01657 seconds