MCPcopy
hub / github.com/KilledByAPixel/LittleJS / glDrawPointsTransform

Function glDrawPointsTransform

src/engineWebGL.js:604–618  ·  view source on GitHub ↗

Transform and add a polygon to the gl draw list * @param {Array } points - Array of Vector2 points * @param {number} rgba - Color of the polygon as a 32-bit integer * @param {number} x * @param {number} y * @param {number} sx * @param {number} sy * @param {number} angle * @pa

(points, rgba, x, y, sx, sy, angle, tristrip=true)

Source from the content-addressed store, hash-verified

602 * @param {boolean} [tristrip] - should tristrip algorithm be used
603 * @memberof WebGL */
604function glDrawPointsTransform(points, rgba, x, y, sx, sy, angle, tristrip=true)
605{
606 const pointsOut = [];
607 const sa = sin(-angle);
608 const ca = cos(-angle);
609 for (const p of points)
610 {
611 // transform the point
612 const px = p.x*sx;
613 const py = p.y*sy;
614 pointsOut.push(vec2(x + ca*px - sa*py, y + sa*px + ca*py));
615 }
616 const drawPoints = tristrip ? glPolyStrip(pointsOut) : pointsOut;
617 glDrawPoints(drawPoints, rgba);
618}
619
620/** Transform and add a polygon to the gl draw list
621 * @param {Array<Vector2>} points - Array of Vector2 points

Callers 2

drawPolyFunction · 0.85
glDrawOutlineTransformFunction · 0.85

Calls 3

vec2Function · 0.85
glPolyStripFunction · 0.85
glDrawPointsFunction · 0.85

Tested by

no test coverage detected