Draw colored line between two points * @param {Vector2} posA * @param {Vector2} posB * @param {number} [width] * @param {Color} [color=WHITE] * @param {Vector2} [pos=vec2()] - Offset to apply * @param {number} [angle] - Angle to rotate by * @param {boolean} [useWebGL=glEnable] *
(posA, posB, width=.1, color=WHITE, pos=vec2(), angle=0, useWebGL=glEnable, screenSpace=false, context)
| 582 | * @param {CanvasRenderingContext2D|OffscreenCanvasRenderingContext2D} [context] |
| 583 | * @memberof Draw */ |
| 584 | function drawLine(posA, posB, width=.1, color=WHITE, pos=vec2(), angle=0, useWebGL=glEnable, screenSpace=false, context) |
| 585 | { |
| 586 | const halfDelta = vec2((posB.x - posA.x)/2, (posB.y - posA.y)/2); |
| 587 | const size = vec2(width, halfDelta.length()*2); |
| 588 | pos = pos.add(posA.add(halfDelta)); |
| 589 | if (screenSpace) |
| 590 | halfDelta.y *= -1; // flip angle Y if screen space |
| 591 | angle += halfDelta.angle(); |
| 592 | drawRect(pos, size, color, angle, useWebGL, screenSpace, context); |
| 593 | } |
| 594 | |
| 595 | /** Draw colored regular polygon using passed in number of sides |
| 596 | * @param {Vector2} pos |
no test coverage detected