PC Review


Reply
Thread Tools Rate Thread

How can I make the arrow smoother it's a little bit jagged now

 
 
Tony Johansson
Guest
Posts: n/a
 
      14th Apr 2011
Here is the code that draw the x axes and the y axes with arrow on each
line.
I just wonder if it's possible to make the arrow less jagged ?

private void pnlDiagram_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;

//Move origo down to the left corner
g.TranslateTransform(pnlDiagram.Width * 1/10, pnlDiagram.Height *
9/10);

marginal = (float)Math.Min(0.1 * pnlDiagram.Width, 0.1 *
pnlDiagram.Height);
Pen pen = new Pen(Color.Blue, 1);

//Create Y axes
Point yaxelStart = new Point(0, 0);
Point yaxelEnd = new Point(0, -pnlDiagram.Height +
(int)(2*marginal));
g.DrawLine(pen, yaxelStart, yaxelEnd);

//Create arrow on Y axes
PointF[] arrowY = new PointF[3];
arrowY[0] = new PointF(-6, -pnlDiagram.Height + (int)(2 *
marginal));
arrowY[1] = new PointF(6, -pnlDiagram.Height + (int)(2 *
marginal));
arrowY[2] = new PointF(0, -pnlDiagram.Height + (int)(2 *
marginal) - 20);
g.FillPolygon(Brushes.Blue, arrowY);
g.DrawPolygon(Pens.Blue, arrowY);

//Create X axes
Point xaxelStart = new Point(0, 0);
Point xaxelEnd = new Point(pnlDiagram.Width - (int)(2 * marginal),
0);
g.DrawLine(pen, xaxelStart, xaxelEnd);

//Create arrow on X axes
PointF[] arrowX = new PointF[3];
arrowX[0] = new PointF(pnlDiagram.Width - (int)(2 * marginal), -6);
arrowX[1] = new PointF(pnlDiagram.Width - (int)(2 * marginal), 6);
arrowX[2] = new PointF(pnlDiagram.Width - (int)(2 * marginal) + 20,
0);
g.FillPolygon(Brushes.Blue, arrowX);
g.DrawPolygon(Pens.Blue, arrowX);
}

//Tony


 
Reply With Quote
 
 
 
 
Tony Johansson
Guest
Posts: n/a
 
      15th Apr 2011

"Peter Duniho" <(E-Mail Removed)> skrev i meddelandet
news:wNCdndEasp-(E-Mail Removed)...
> On 4/14/11 2:08 PM, Tony Johansson wrote:
>> Here is the code that draw the x axes and the y axes with arrow on each
>> line.
>> I just wonder if it's possible to make the arrow less jagged ?

>
> Depends on what you mean. But if it's anti-aliasing you're looking for,
> setting the SmoothingMode property to one of the anti-aliased values will
> do that.
>
> Pete


I added this row as you can see below
g.SmoothingMode = SmoothingMode.AntiAlias;
but I didn't see any change it's still a little bit jagged.
So why didn't this SmoothingMode have any effect when the arrow was drawn?

private void pnlDiagram_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;

//Move origo down to the left corner
g.TranslateTransform(pnlDiagram.Width * 1/10, pnlDiagram.Height *
9/10);

marginal = (float)Math.Min(0.1 * pnlDiagram.Width, 0.1 *
pnlDiagram.Height);
Pen pen = new Pen(Color.Blue, 1);

//Create Y axes
Point yaxelStart = new Point(0, 0);
Point yaxelEnd = new Point(0, -pnlDiagram.Height +
(int)(2*marginal));
g.DrawLine(pen, yaxelStart, yaxelEnd);

//Create arrow on Y axes
PointF[] arrowY = new PointF[3];
arrowY[0] = new PointF(-6, -pnlDiagram.Height + (int)(2 *
marginal));
arrowY[1] = new PointF(6, -pnlDiagram.Height + (int)(2 *
marginal));
arrowY[2] = new PointF(0, -pnlDiagram.Height + (int)(2 *
marginal) - 20);
g.FillPolygon(Brushes.Blue, arrowY);
g.DrawPolygon(Pens.Blue, arrowY);
g.SmoothingMode = SmoothingMode.AntiAlias;

//Create x axes
Point xaxelStart = new Point(0, 0);
Point xaxelEnd = new Point(pnlDiagram.Width - (int)(2 * marginal),
0);
g.DrawLine(pen, xaxelStart, xaxelEnd);

//Create arrow on X axes
PointF[] arrowX = new PointF[3];
arrowX[0] = new PointF(pnlDiagram.Width - (int)(2 * marginal), -6);
arrowX[1] = new PointF(pnlDiagram.Width - (int)(2 * marginal), 6);
arrowX[2] = new PointF(pnlDiagram.Width - (int)(2 * marginal) + 20,
0);
g.FillPolygon(Brushes.Blue, arrowX);
g.DrawPolygon(Pens.Blue, arrowX);
g.SmoothingMode = SmoothingMode.AntiAlias;
}

//Tony



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I make a jagged edge on a picture? cjohnson Microsoft Powerpoint 2 17th Apr 2008 09:22 AM
How do you make smoother dissolves? =?Utf-8?B?ZGhvdXNl?= Microsoft Powerpoint 7 21st May 2005 02:57 AM
How can I make mouse scrolling smoother? Beemer Windows XP Performance 0 23rd Jun 2004 07:17 AM
Datagrid and Arrow keys, how to make the arrow move around? Joe Microsoft Dot NET Framework Forms 2 9th Jan 2004 04:50 PM
Is there a way to make the tab key act as the down arrow key... mark Microsoft Word Document Management 0 3rd Sep 2003 10:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:05 PM.