Canvas tutorial 02 | How to draw round angle polygon in the flutter?

This Article is posted by niebin312 at 1/3/2019 7:37:18 PM

Canvas tutorial 01. There is some basic knowledge for you to learn. = 0.0; } *markup--em markup--pre-em](///the x coordinate whether or not is between two point we give. ***markup--strong markup--pre-strong](static **bool *markup--em markup--pre-em](_betweenPoint*(x, Point p1, Point p2) { **markup--strong markup--pre-strong](if **(p1.x > p2.x) { **markup--strong markup--pre-strong](return **x > p2.x && x p1.x && x p2.y) { **markup--strong markup--pre-strong](return **Point(p2.x, p2.y + r); } **markup--strong markup--pre-strong](else if **(p1.y p2.x) { **markup--strong markup--pre-strong](return **Point(p2.x + r, p2.y); } **markup--strong markup--pre-strong](else if **(p1.x Canvas tutorial 01. If you don’t know how to use, you should watch it before continuing. In our `**markup--strong markup--p-strong](void **paint(Canvas canvas, Size size)` function we will draw our shape. ps, double distance, Canvas canvas, paint) { **markup--strong markup--pre-strong](var **path = Path(); ps.add(ps[0]); ps.add(ps[1]); **markup--strong markup--pre-strong](var **p0 = LineInterCircle.*markup--em markup--pre-em](intersectionPoint*(ps[1], ps[0], distance); path.moveTo(p0.x, p0.y); **markup--strong markup--pre-strong](for **(int i = 0; i 1.0 && size.height > 1.0) { print(">1.9"); _sizeUtil.logicSize = size; } } _resizePoint(List list) { List l = List(); **markup--strong markup--pre-strong](for **(**markup--strong markup--pre-strong](var **p **markup--strong markup--pre-strong](in **list) { l.add(Point(_sizeUtil.getAxisX(p.x), _sizeUtil.getAxisY(p.y))); } **markup--strong markup--pre-strong](return **l; } list1 = [ Point(250.0, 0.0), Point(425.0, 75.0), Point(500.0, 250.0), Point(425.0, 425.0), Point(250.0, 500.0), Point(75.0, 426.0), Point(0.0, 250.0), Point(75.0, 75.0), ]; paint.color = RED_DARK1; _drawWithPoint(canvas, paint, list1); 1.0 && size.height > 1.0) { print(">1.9"); _sizeUtil.logicSize = size; } **markup--strong markup--pre-strong](var **paint = Paint() ..style = PaintingStyle.fill ..color = BLUE_NORMAL ..isAntiAlias = **markup--strong markup--pre-strong](true**; List list1 = [ Point(250.0, 0.0), Point(425.0, 75.0), Point(500.0, 250.0), Point(425.0, 425.0), Point(250.0, 500.0), Point(75.0, 426.0), Point(0.0, 250.0), Point(75.0, 75.0), ]; paint.color = RED_DARK1; _drawWithPoint(canvas, paint, list1); List list2 = [ Point(250.0, 53.0), Point(392.0, 108.0), Point(449.0, 250.0), Point(392.0, 390.0), Point(250.0, 448.0), Point(110.0, 390.0), Point(54.0, 250.0), Point(110.0, 108.0), ]; paint.color = RED_DARK2; _drawWithPoint(canvas, paint, list2, hasShadow: **markup--strong markup--pre-strong](true**); List list3 = [ Point(250.0, 100.0), Point(358.0, 143.0), Point(400.0, 250.0), Point(355.0, 355.0), Point(250.0, 400.0), Point(144.0, 357.0), Point(100.0, 250.0), Point(144.0, 144.0), ]; paint.color = RED_DARK3; _drawWithPoint(canvas, paint, list3, hasShadow: **markup--strong markup--pre-strong](true**); List list4 = [ Point(250.0, 150.0), Point(320.0, 180.0), Point(348.0, 250.0), Point(320.0, 320.0), Point(250.0, 348.0), Point(180.0, 320.0), Point(150.0, 250.0), Point(180.0, 180.0), ]; paint.color = RED_DARK4; _drawWithPoint(canvas, paint, list4, hasShadow: **markup--strong markup--pre-strong](true**); List list5 = [ Point(250.0, 202.0), Point(286.0, 217.0), Point(300.0, 250.0), Point(284.0, 284.0), Point(250.0, 300.0), Point(214.0, 282.0), Point(202.0, 250.0), Point(216.0, 216.0), ]; paint.color = RED_DARK5; _drawWithPoint(canvas, paint, list5, hasShadow: **markup--strong markup--pre-strong](true**); List listYellow = [ Point(110.0, 104.0), Point(250.0, 153.0), Point(358.0, 143.0), Point(450.0, 252.0), Point(369.0, 349.0), Point(250.0, 504.0), Point(140.0, 353.0), Point(100.0, 250.0), ]; paint.color = *markup--em markup--pre-em](YELLOW_NORMAL.withOpacity(0.5); _drawWithPoint(canvas, paint, listYellow); canvas.save(); canvas.restore*(); }

Tags:



0 Comments
Login to comment.
Recent Comments

Be the first to Comment. You can ask a Query or Share your toughts or Just say thanks.




© 2018 - Fluttercentral | Email to me - Seven.srikanth@gmail.com