473,414 Members | 1,928 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,414 software developers and data experts.

System.Drawing.Drawing2D examples

Hi,

I'm looking for examples of the different brush and fill styles that can
be made using System.Drawing.Drawing2D. I haven't actually used this
class before, so any example code accompanying visual style examples
would be an ideal thing to help me learn.

Does anyone know of a website that has such examples?

Cheers,

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Jan 16 '07 #1
2 14372
Hi Dylan,

Here's an example:

using System;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

public class TestForm : Form
{
public TestForm()
{
DoubleBuffered = true;
ResizeRedraw = true;
BackColor = Color.White;
}

protected override void OnPaint(PaintEventArgs e)
{
int height = ClientRectangle.Height / 3;
int width = ClientRectangle.Width;
int y = 0;

Rectangle hatchArea = new Rectangle(0, y, width, height);
y += height;
Rectangle gradientArea = new Rectangle(0, y, width, height);
y += height;
Rectangle pathArea = new Rectangle(0, y, width, height);

using (HatchBrush hatchBrush = new HatchBrush(
HatchStyle.Cross, Color.Red, Color.Blue))
{
e.Graphics.FillRectangle(hatchBrush, hatchArea);
}

using (LinearGradientBrush gradientBrush = new LinearGradientBrush(
gradientArea, Color.Green, Color.White,
LinearGradientMode.ForwardDiagonal))
{
e.Graphics.FillRectangle(gradientBrush, gradientArea);
}

using (GraphicsPath path = new GraphicsPath())
{
path.AddBezier(0, y, width, y, width, y + height, 0, y + height);

using (PathGradientBrush pathBrush = new PathGradientBrush(path))
{
pathBrush.CenterColor = Color.HotPink;
pathBrush.CenterPoint = new PointF(width / 4, y + height / 2);
pathBrush.SurroundColors = new Color[] {
Color.Yellow,
Color.Lavender,
Color.Ivory,
Color.Indigo
};

e.Graphics.FillRectangle(pathBrush, pathArea);
}
}
}
}
--
Dave Sexton
http://davesexton.com/blog

"Dylan Parry" <us****@dylanparry.comwrote in message
news:51*************@mid.individual.net...
Hi,

I'm looking for examples of the different brush and fill styles that can
be made using System.Drawing.Drawing2D. I haven't actually used this
class before, so any example code accompanying visual style examples
would be an ideal thing to help me learn.

Does anyone know of a website that has such examples?

Cheers,

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.

Jan 16 '07 #2
Dave Sexton wrote:
Here's an example:
[...]

Cheers for that. The mere fact that I understood what was going on has
improved my mood by miles :)

--
Dylan Parry
http://electricfreedom.org | http://webpageworkshop.co.uk

Programming, n: A pastime similar to banging one's head
against a wall, but with fewer opportunities for reward.
Jan 16 '07 #3

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

Similar topics

0
by: Roland Moschel | last post by:
Hi ! I have an 2-Dimensional System.Array of byte with Image-Data. How can I create an System.Drawing.Image with this Data ? All the Examples I found are working with MemoryStream(byte), but...
2
by: Richard | last post by:
I each time get errors when I use an .bmp or ,.gif file as source but whenever I use a .jpg file it works perfect. Why is that? and how to fix it? I almost have no knowledge about the...
3
by: Eduardo Rosa | last post by:
Hi, Can I use GraphicsPath class in ASP.Net page? There's other way to do this? thanks a lot
10
by: tshad | last post by:
I have a problem setting the background color of textbox on the fly. I tried using: applicantID.backcolor = "F6F6F6" and applicantID.backcolor = "#F6F6F6"
3
by: Qwert | last post by:
Hello, I want to draw from one System.Drawing.Bitmap to another. All I can find is how to draw to a Graphics object. System.Drawing, System.Drawing.Drawing2D or System.Drawing.Imaging have no...
0
by: PJ6 | last post by:
I want to use GraphicsPath to represent several 2D functions over discreet domains. Only, two questions I'm having trouble answering - 1. If I want to add one function to another, is there an...
3
by: Eduard Witteveen | last post by:
Hello list, I have code the draw MyDrawingObject information on a System.Drawing.Graphics object. The code is more/less the following: I now want to rotate / mirror the object i draw. I've...
5
by: Jerry J | last post by:
I want to use the System.Drawing.Image class. According to the help file, this is an abstract base class. Because it is supposedly abstract, I created another class that inherits from it. However,...
12
by: Petra Rohmer | last post by:
Hello, I want to ake following 0,0 (900mm,900mm) -------------------------------------- |....................................| |....................................|...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.