Canvas, drawing a line segment
问题 My trigonometry is more than weak, and therefore I do not know how to draw a line segment shorter than full lines start point and end point. http://jsfiddle.net/psycketom/TUyJb/ What I have tried, is, subtract from start point a fraction of target point, but it results in a wrong line. /* * this is an excerpt from fiddle, that shows * the actual calculation functions I have implemented */ var target = { x : width / 2 + 60, y : 20 }; var start = { x : width / 2, y : height }; var current = { x