473,387 Members | 3,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Graphics 2D path question

Hi,

I am creating a control. The control needs to be non-rectangular.

I am creating a graphics path and then adding two overlapping ellipses
to it using the addEllipse method.

I then set this.region ('this' being the control) to a new region,
passing my graphicspath object into the region constructor. This clips
the control to be non-rectangular.

The problem is that, when I add the second ellipse to the path, the
area where the two ellipses overlap is 'negated' or 'toggled'. That
is, I have a huge hole in the middle of my region!

I basically am asking how I create a path that is the UNION of the two
ellipses.
This has been driving me nuts, so thanks in advance!

Damien Sawyer
Nov 16 '05 #1
4 2529
When you create the GraphicsPath use the parameterized constructor and selet
the Winding fill-mode.

--
Bob Powell [MVP]
Visual C#, System.Drawing

The Image Transition Library wraps up and LED style instrumentation is
available in the June of Well Formed for C# or VB programmers
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml


"Damien Sawyer" <da**********@yahoo.com.au> wrote in message
news:d8**************************@posting.google.c om...
Hi,

I am creating a control. The control needs to be non-rectangular.

I am creating a graphics path and then adding two overlapping ellipses
to it using the addEllipse method.

I then set this.region ('this' being the control) to a new region,
passing my graphicspath object into the region constructor. This clips
the control to be non-rectangular.

The problem is that, when I add the second ellipse to the path, the
area where the two ellipses overlap is 'negated' or 'toggled'. That
is, I have a huge hole in the middle of my region!

I basically am asking how I create a path that is the UNION of the two
ellipses.
This has been driving me nuts, so thanks in advance!

Damien Sawyer

Nov 16 '05 #2
Hi Demien,

If fill mode doesn't wwork for you why don't you just use Region class'
Interesect method. Create two elliptical regions and intersect them or
something in this line.

--

Stoitcho Goutsev (100) [C# MVP]
"Damien Sawyer" <da**********@yahoo.com.au> wrote in message
news:d8**************************@posting.google.c om...
Hi,

I am creating a control. The control needs to be non-rectangular.

I am creating a graphics path and then adding two overlapping ellipses
to it using the addEllipse method.

I then set this.region ('this' being the control) to a new region,
passing my graphicspath object into the region constructor. This clips
the control to be non-rectangular.

The problem is that, when I add the second ellipse to the path, the
area where the two ellipses overlap is 'negated' or 'toggled'. That
is, I have a huge hole in the middle of my region!

I basically am asking how I create a path that is the UNION of the two
ellipses.
This has been driving me nuts, so thanks in advance!

Damien Sawyer

Nov 16 '05 #3
Thanks for that guys!

I used the fillmode.winding enum in the constructor and it worked
perfectly. The suggestion of unioning regions is an excellent one as
well. I'll have a look into that for future things.
Once again, thanks!! :-)

DS
Nov 16 '05 #4
Hi Damien,

I suggested using regions because they are more apporpriate for that
purpose.
The idea is that a region defines an area. That's why operations sucha as
union and intersection are defined for them. The path, how the name
sauggests, is an outline. Even though paths can be filled hit tested in
other words can be a repalcement of regions they cannot be combined in the
same way as regions.

However, I have heard that .NET implemtation of regions is bad. It has
memory leaks and so on. So be carefull. Hopefully in the next version it
will be fixed.

--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Damien Sawyer" <da**********@yahoo.com.au> wrote in message
news:d8**************************@posting.google.c om...
Thanks for that guys!

I used the fillmode.winding enum in the constructor and it worked
perfectly. The suggestion of unioning regions is an excellent one as
well. I'll have a look into that for future things.
Once again, thanks!! :-)

DS

Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: BlackHawke | last post by:
My name is Nick Soutter, I own a small game development company (www.aepoxgames.net) making our first game (www.andromedaonline.net) in java. I am writing because we are having a very...
8
by: Nathan Sokalski | last post by:
I am trying to write code to rotate a graphic that I have. Here is the code I am currently using: Dim frogbitmap As New Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif"))) Dim...
5
by: iainfogg | last post by:
I had an ASP.NET 2.0 site which works fine on my PC. I have just copied it to a server, and set it up to run in a virtual folder. The web pages work fine, but the graphics won't load - if I try to...
2
by: Mark Ingram | last post by:
Hi, I would like to know which is the faster method to call, FillRectangle or FillPath. I have a path which is essentially a square, except for rounded corners, so I can end up with 2 almost...
1
by: IvoShalev | last post by:
Hi there, I just want to give some sudgestions on how to draw some plain things only using the header file <graphics.hand of course the standart files <stdio.h<conio.h<stdlib.h>. First of All...
6
by: Blasting Cap | last post by:
I have to change the front page for a sales system I work on, and want to use some thumbnails of wallpaper that is on a sister site. The wallpapers are jpegs, and are 640, 800, 1024 & 1280 in...
2
by: wstsoi | last post by:
hi I have to read images from spreadsheet, is it possible to do with php?
5
by: Andy | last post by:
Hi, I am using the following code to render a text string in a new bitmap file. The code works, but the text looks, well, crappy, even though I told it to use ClearType hints. Any idea how to...
10
by: eddie tan | last post by:
Hi, I have a picturebox with graphics drawn from different objects. In one object I used Pen P1; P1 = new Pen(Color.Blue, 3); Graphics g = null; g = Graphics.FromImage(image.Image);...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.