TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
jeya pandi
NA
62
18.9k
how to draw a line with arrow with varying stroke width valu
Aug 23 2017 6:54 AM
Hi ,
I have drawn arrow when i try to increase arrow stroke width , it looks wierd.Two lines are overlapping and thickness applies from center. Is there any other way to apply strokewidth outwards.
I have referred below link to draw an arrow, How do I draw an arrowhead (in Android)?
public class Arrow: View { float x0 = 300, y0 = 1000, x1 = 600, y1 = 200;
internal static int DENSITY = -1;
public Arrow(Context con):base(con)
{
DENSITY = (int)con.Resources.DisplayMetrics.Density; } protected override void OnDraw(Canvas canvas) { Paint paint = new Paint(); paint.StrokeWidth = 10 * Arrow.DENSITY; float angle, anglerad, radius, lineangle; radius = 45; angle = 45; //calculate line angles anglerad = (float)(Math.Pi * angle / 180.0f); lineangle = (float)(Math.Atan2(y1 - y0, x1 - x0)); Path mArrow = new Android.Graphics.Path(); mArrow.MoveTo(x1, y1); var a1 = (float)(x1 - radius * Math.Cos(lineangle - (anglerad / 2.0))); var a2 = (float)(y1 - radius * Math.Sin(lineangle - (anglerad / 2.0))); mArrow.LineTo(a1, a2); mArrow.MoveTo(a1, a2); mArrow.MoveTo(x1, y1); var a3 = (float)(x1 - radius * Math.Cos(lineangle + (anglerad / 2.0))); var a4 = (float)(y1 - radius * Math.Sin(lineangle + (anglerad / 2.0))); mArrow.LineTo(a3, a4); paint.AntiAlias = true; paint.SetStyle(Android.Graphics.Paint.Style.Stroke); canvas.DrawPath(mArrow, paint); canvas.DrawLine(x0, y0, x1, y1, paint); base.OnDraw(canvas); } }
Any one please share your suggestions.Thanks in advance.
Reply
Answers (
1
)
How would I go about implementing this in my code/program?
How deploy system vb 2015 with sql database server .