littlejsengine 1.22.0 → 1.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -770,6 +770,9 @@ function glDrawUntextured(x, y, sizeX, sizeY, angle, rgba)
770
770
  glDraw(x, y, sizeX, sizeY, angle, 0, 0, 0, 0, 0, rgba);
771
771
  }
772
772
 
773
+ // the list and the vectors glDrawPointsTransform writes its points into
774
+ const glPointsOut = [], glPointsPool = [];
775
+
773
776
  /** Transform and add a polygon to the gl draw list
774
777
  * @param {Array<Vector2>} points - Array of Vector2 points
775
778
  * @param {number} rgba - Color of the polygon as a 32-bit integer
@@ -782,15 +785,21 @@ function glDrawUntextured(x, y, sizeX, sizeY, angle, rgba)
782
785
  * @memberof WebGL */
783
786
  function glDrawPointsTransform(points, rgba, x, y, sx, sy, angle, tristrip=true)
784
787
  {
785
- const pointsOut = [];
788
+ // written into vectors kept for this, a circle would make one for each of its sides at every draw; they are
789
+ // read into the batch before this returns
790
+ const pointsOut = glPointsOut, pool = glPointsPool, count = points.length;
791
+ pointsOut.length = count;
786
792
  const sa = sin(-angle);
787
793
  const ca = cos(-angle);
788
- for (const p of points)
794
+ for (let i = 0; i < count; ++i)
789
795
  {
790
796
  // transform the point
797
+ const p = points[i], out = pool[i] ||= vec2();
791
798
  const px = p.x*sx;
792
799
  const py = p.y*sy;
793
- pointsOut.push(vec2(x + ca*px - sa*py, y + sa*px + ca*py));
800
+ out.x = x + ca*px - sa*py;
801
+ out.y = y + sa*px + ca*py;
802
+ pointsOut[i] = out;
794
803
  }
795
804
  const drawPoints = tristrip ? glPolyStrip(pointsOut) : pointsOut;
796
805
  glDrawPoints(drawPoints, rgba);