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

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 3254

"John Baro" <jo***@NOSPAMmesware.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(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));

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

Pen p1 = new Pen(b1,2);

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

}

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
how about something like :

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));

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

Pen p1 = new Pen(b1,2);

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

}

"John Baro" <jo***@NOSPAMmesware.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(PaintEventArgs e)
{
base.OnPaint (e);
Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Black, Color.Red);
Pen p = new Pen(b,10);
e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));
Brush b1 = new LinearGradientBrush(new Point(100,100),new
Point(200,200), Color.Red, Color.Black);
Pen p1 = new Pen(b1,10);
e.Graphics.DrawLine(p1,new Point(100,100),new Point(200,200));
}

"John Baro" <jo***@NOSPAMmesware.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***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
how about something like :

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));

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

Pen p1 = new Pen(b1,2);

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

}

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:eL****************@TK2MSFTNGP11.phx.gbl...
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
how about something like :

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));

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

Pen p1 = new Pen(b1,2);

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

}

"John Baro" <jo***@NOSPAMmesware.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(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(50,40),new Point(50,50),
Color.Gray, Color.Red);

Pen p = new Pen(b,10);

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

Brush b1 = new LinearGradientBrush(new Point(50,50),new Point(50,60),
Color.Red, Color.Gray);

Pen p1 = new Pen(b1,10);

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

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

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
how about something like :

protected override void OnPaint(PaintEventArgs e)

{

base.OnPaint (e);

Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100),
Color.Gray, Color.Red);

Pen p = new Pen(b,2);

e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));

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

Pen p1 = new Pen(b1,2);

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

}

"John Baro" <jo***@NOSPAMmesware.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 :
LinearGradientBrush (Rectangle rect, Color color1, Color color2, float
angle, bool isAngleScaleable)
"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:eL****************@TK2MSFTNGP11.phx.gbl...
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
> how about something like :
>
> protected override void OnPaint(PaintEventArgs e)
>
> {
>
> base.OnPaint (e);
>
> Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100), > Color.Gray, Color.Red);
>
> Pen p = new Pen(b,2);
>
> e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));
>
> Brush b1 = new LinearGradientBrush(new Point(100,100),new

Point(200,200),
> Color.Red, Color.Gray);
>
> Pen p1 = new Pen(b1,2);
>
> e.Graphics.DrawLine(p1,new Point(100,100),new Point(200,200));
>
> }
>
>
>
> "John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
use the method :
LinearGradientBrush (Rectangle rect, Color color1, Color color2, float
angle, bool isAngleScaleable)
"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
news:eL****************@TK2MSFTNGP11.phx.gbl...
trick it ... use rectangle for the line ...

"John Baro" <jo***@NOSPAMmesware.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****@arrabeta.com> wrote in message
> news:%2******************@TK2MSFTNGP11.phx.gbl...
> > how about something like :
> >
> > protected override void OnPaint(PaintEventArgs e)
> >
> > {
> >
> > base.OnPaint (e);
> >
> > Brush b = new LinearGradientBrush(new Point(10,10),new Point(100,100), > > Color.Gray, Color.Red);
> >
> > Pen p = new Pen(b,2);
> >
> > e.Graphics.DrawLine(p,new Point(10,10),new Point(100,100));
> >
> > Brush b1 = new LinearGradientBrush(new Point(100,100),new
Point(200,200),
> > Color.Red, Color.Gray);
> >
> > Pen p1 = new Pen(b1,2);
> >
> > e.Graphics.DrawLine(p1,new Point(100,100),new Point(200,200));
> >
> > }
> >
> >
> >
> > "John Baro" <jo***@NOSPAMmesware.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
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...
2
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...
1
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...
2
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)...
9
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...
10
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
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...
3
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...
2
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.