473,836 Members | 1,421 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Drawing shaded lines and shapes

I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any other
color).

I can get the line by using a GraphicsPath object but cannot work out the
shading part.

Is this also possible for say a circle with an outside line width of 10px to
be shaded from red to gray from the inside out around the circumference of
the circle.

TIA
JB
Nov 15 '05 #1
9 3289

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any other
color).

I can get the line by using a GraphicsPath object but cannot work out the
shading part.

Is this also possible for say a circle with an outside line width of 10px to be shaded from red to gray from the inside out around the circumference of
the circle.

TIA
JB

Nov 15 '05 #2
how about something like :

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;

Brush b1 = new LinearGradientB rush(new Point(100,100), new Point(200,200),
Color.Red, Color.Gray);

Pen p1 = new Pen(b1,2);

e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;

}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any other
color).

I can get the line by using a GraphicsPath object but cannot work out the
shading part.

Is this also possible for say a circle with an outside line width of 10px to be shaded from red to gray from the inside out around the circumference of
the circle.

TIA
JB

Nov 15 '05 #3
Thanks for the reply Malek

I forgot to mention that it has to be shaded blue red blue along the axis of
the line.
i.e. if the line was flat then red along the top to blue in the middle and
back to red again at the bottom but again on a 45 angle.

Cheers
JB

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
how about something like :

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;

Brush b1 = new LinearGradientB rush(new Point(100,100), new Point(200,200),
Color.Red, Color.Gray);

Pen p1 = new Pen(b1,2);

e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;

}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any other color).

I can get the line by using a GraphicsPath object but cannot work out the shading part.

Is this also possible for say a circle with an outside line width of 10px
to
be shaded from red to gray from the inside out around the circumference

of the circle.

TIA
JB


Nov 15 '05 #4
something went wrong on my earlier answer, so here it is :

I guess something like this would do what you are looking for (this is for
lines, but you can do the same with aother shapes.)

protected override void OnPaint(PaintEv entArgs e)
{
base.OnPaint (e);
Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Black, Color.Red);
Pen p = new Pen(b,10);
e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;
Brush b1 = new LinearGradientB rush(new Point(100,100), new
Point(200,200), Color.Red, Color.Black);
Pen p1 = new Pen(b1,10);
e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;
}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any other
color).

I can get the line by using a GraphicsPath object but cannot work out the
shading part.

Is this also possible for say a circle with an outside line width of 10px to be shaded from red to gray from the inside out around the circumference of
the circle.

TIA
JB

Nov 15 '05 #5
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:J3******** *********@news-server.bigpond. net.au...
Thanks for the reply Malek

I forgot to mention that it has to be shaded blue red blue along the axis of the line.
i.e. if the line was flat then red along the top to blue in the middle and
back to red again at the bottom but again on a 45 angle.

Cheers
JB

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
how about something like :

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;

Brush b1 = new LinearGradientB rush(new Point(100,100), new Point(200,200),
Color.Red, Color.Gray);

Pen p1 = new Pen(b1,2);

e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;

}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
I wish to draw a line say 10px wide at a 45 degree angle (or any other
angle) and have it shaded say from gray to red to gray again (or any
other color).

I can get the line by using a GraphicsPath object but cannot work out the shading part.

Is this also possible for say a circle with an outside line width of 10px
to
be shaded from red to gray from the inside out around the

circumference of the circle.

TIA
JB



Nov 15 '05 #6
I was going to but cannot see a way of rotating the rectangle.
JB
"Malek" <ke****@arrabet a.com> wrote in message
news:eL******** ********@TK2MSF TNGP11.phx.gbl. ..
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:J3******** *********@news-server.bigpond. net.au...
Thanks for the reply Malek

I forgot to mention that it has to be shaded blue red blue along the axis
of
the line.
i.e. if the line was flat then red along the top to blue in the middle and back to red again at the bottom but again on a 45 angle.

Cheers
JB

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
how about something like :

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;

Brush b1 = new LinearGradientB rush(new Point(100,100), new Point(200,200), Color.Red, Color.Gray);

Pen p1 = new Pen(b1,2);

e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;

}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
> I wish to draw a line say 10px wide at a 45 degree angle (or any other > angle) and have it shaded say from gray to red to gray again (or any

other
> color).
>
> I can get the line by using a GraphicsPath object but cannot work

out the
> shading part.
>
> Is this also possible for say a circle with an outside line width of

10px
to
> be shaded from red to gray from the inside out around the

circumference
of
> the circle.
>
> TIA
> JB
>
>



Nov 15 '05 #7
here is going from border to middle to border of the line ... (perpendicular
to the line)

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(50,40),ne w Point(50,50),
Color.Gray, Color.Red);

Pen p = new Pen(b,10);

e.Graphics.Draw Line(p,new Point(0,45),new Point(100,45));

Brush b1 = new LinearGradientB rush(new Point(50,50),ne w Point(50,60),
Color.Red, Color.Gray);

Pen p1 = new Pen(b1,10);

e.Graphics.Draw Line(p1,new Point(0,55),new Point(100,55));

}
"Malek" <ke****@arrabet a.com> wrote in message
news:eL******** ********@TK2MSF TNGP11.phx.gbl. ..
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:J3******** *********@news-server.bigpond. net.au...
Thanks for the reply Malek

I forgot to mention that it has to be shaded blue red blue along the axis
of
the line.
i.e. if the line was flat then red along the top to blue in the middle and back to red again at the bottom but again on a 45 angle.

Cheers
JB

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
how about something like :

protected override void OnPaint(PaintEv entArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;

Brush b1 = new LinearGradientB rush(new Point(100,100), new Point(200,200), Color.Red, Color.Gray);

Pen p1 = new Pen(b1,2);

e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;

}

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:3z******** **********@news-server.bigpond. net.au...
> I wish to draw a line say 10px wide at a 45 degree angle (or any other > angle) and have it shaded say from gray to red to gray again (or any

other
> color).
>
> I can get the line by using a GraphicsPath object but cannot work

out the
> shading part.
>
> Is this also possible for say a circle with an outside line width of

10px
to
> be shaded from red to gray from the inside out around the

circumference
of
> the circle.
>
> TIA
> JB
>
>



Nov 15 '05 #8
use the method :
LinearGradientB rush (Rectangle rect, Color color1, Color color2, float
angle, bool isAngleScaleabl e)
"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:_m******** *********@news-server.bigpond. net.au...
I was going to but cannot see a way of rotating the rectangle.
JB
"Malek" <ke****@arrabet a.com> wrote in message
news:eL******** ********@TK2MSF TNGP11.phx.gbl. ..
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:J3******** *********@news-server.bigpond. net.au...
Thanks for the reply Malek

I forgot to mention that it has to be shaded blue red blue along the axis
of
the line.
i.e. if the line was flat then red along the top to blue in the middle

and back to red again at the bottom but again on a 45 angle.

Cheers
JB

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
> how about something like :
>
> protected override void OnPaint(PaintEv entArgs e)
>
> {
>
> base.OnPaint (e);
>
> Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100), > Color.Gray, Color.Red);
>
> Pen p = new Pen(b,2);
>
> e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;
>
> Brush b1 = new LinearGradientB rush(new Point(100,100), new

Point(200,200),
> Color.Red, Color.Gray);
>
> Pen p1 = new Pen(b1,2);
>
> e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;
>
> }
>
>
>
> "John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
> news:3z******** **********@news-server.bigpond. net.au...
> > I wish to draw a line say 10px wide at a 45 degree angle (or any other > > angle) and have it shaded say from gray to red to gray again (or any other
> > color).
> >
> > I can get the line by using a GraphicsPath object but cannot work out the
> > shading part.
> >
> > Is this also possible for say a circle with an outside line width of 10px
> to
> > be shaded from red to gray from the inside out around the

circumference
of
> > the circle.
> >
> > TIA
> > JB
> >
> >
>
>



Nov 15 '05 #9
Thanks Malek

"Malek" <ke****@arrabet a.com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
use the method :
LinearGradientB rush (Rectangle rect, Color color1, Color color2, float
angle, bool isAngleScaleabl e)
"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:_m******** *********@news-server.bigpond. net.au...
I was going to but cannot see a way of rotating the rectangle.
JB
"Malek" <ke****@arrabet a.com> wrote in message
news:eL******** ********@TK2MSF TNGP11.phx.gbl. ..
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
news:J3******** *********@news-server.bigpond. net.au...
> Thanks for the reply Malek
>
> I forgot to mention that it has to be shaded blue red blue along the axis
of
> the line.
> i.e. if the line was flat then red along the top to blue in the
middle
and
> back to red again at the bottom but again on a 45 angle.
>
> Cheers
> JB
>
> "Malek" <ke****@arrabet a.com> wrote in message
> news:%2******** **********@TK2M SFTNGP11.phx.gb l...
> > how about something like :
> >
> > protected override void OnPaint(PaintEv entArgs e)
> >
> > {
> >
> > base.OnPaint (e);
> >
> > Brush b = new LinearGradientB rush(new Point(10,10),ne w Point(100,100), > > Color.Gray, Color.Red);
> >
> > Pen p = new Pen(b,2);
> >
> > e.Graphics.Draw Line(p,new Point(10,10),ne w Point(100,100)) ;
> >
> > Brush b1 = new LinearGradientB rush(new Point(100,100), new
Point(200,200),
> > Color.Red, Color.Gray);
> >
> > Pen p1 = new Pen(b1,2);
> >
> > e.Graphics.Draw Line(p1,new Point(100,100), new Point(200,200)) ;
> >
> > }
> >
> >
> >
> > "John Baro" <jo***@NOSPAMme sware.com.au> wrote in message
> > news:3z******** **********@news-server.bigpond. net.au...
> > > I wish to draw a line say 10px wide at a 45 degree angle (or any

other
> > > angle) and have it shaded say from gray to red to gray again (or any > other
> > > color).
> > >
> > > I can get the line by using a GraphicsPath object but cannot
work out
> the
> > > shading part.
> > >
> > > Is this also possible for say a circle with an outside line

width of > 10px
> > to
> > > be shaded from red to gray from the inside out around the
circumference
> of
> > > the circle.
> > >
> > > TIA
> > > JB
> > >
> > >
> >
> >
>
>



Nov 15 '05 #10

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

Similar topics

8
22447
by: john | last post by:
Hi I am a C++ newbie, I am looking to draw single lines and simple boxes in a C++ console window. Is there a draw command with x and y coordinates that can be used with my Dev C++ compiler. For simplicity sake, I would be prepared to draw using characters such as _ or * if proper line drawing is really complicated. Thanks in advance. Walt
2
5377
by: Mike Edwards | last post by:
I need to use javascript's graphics API to draw the letters of the alphabet. If necessary, I can map out all 26 letters myself and use drawline() to draw them, but I am hoping someone out there might have a better suggestion. The user will click a spot on the canvas, and the script will draw one of the letters at that spot. thanks, mike
1
2522
by: Andreas Schubert | last post by:
Hello newsgroup, I am pretty new to .NET and need some advise on how to approach to the following: I have to create an application with a drawing surface, where some predefined shapes (picture boxes with icons in it) can be dropped and moved around. This should work like some MS Visio on a very basic level. The shapes should be dragged from a list.
2
2621
by: Dursun | last post by:
Collegues, is it possible to do the foloowing: Let end user draw specific shapes (a circle that has a number within it and a connector that points to a specific area on the background image) using Windows Forms and controls. To be more specific, I want to design a VB.Net Windows form where end user will mark damages on an airplane picture (which might be background picture of the form) using a marker object that has a circle (with a...
9
3193
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I want to be able to draw lines in a picturebox based upon certain data points I have received. I dragged a picturebox from the toolbar onto my form, but after having gone through the help files, looking online and trying a variety of things, I...
10
2190
by: Tina | last post by:
I need to find drawing software for my websites. I'm guessing that Adobe Photoshop is an overkill. What's best for creating bitmaps usable for websites? Thanks, T
10
3447
by: James Stroud | last post by:
Hello All, I'm looking for a program to do line-drawings in 3d, with output to postscript or svg or pdf, etc. I would like to describe a scene with certain 1-3d elements oriented in 3d space with dashed or colored lines and filled or transparent surfaces (or maybe semitransparent). I would then like to set the camera and have the scene depicted as a line drawing (not ray-traced solid body, etc).
3
2897
by: Christie | last post by:
I am writing my app using Visual Studio 2005 (VB.NET). I want to draw images (nothing complex, just lines and shapes) using a mouse. How do one go about achieving this with VB.NET?? If someone could just give me a starting point that would be great. Thanks Christie
2
3229
by: mattc66 via AccessMonster.com | last post by:
Does anyone know of some simple line drawing add-on apps. I just need to be able to do some simple line drawing with dims. 4 walls and a door and allow the user to type the dims for the walls. All simple. Thanks MAtt -- Matt Campbell mattc (at) saunatec com
0
9668
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10546
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10588
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7790
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6978
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5823
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.