void renderTriangleMesh(RenderState renderState, Int16List ixList, Float32List vxList, int color)

Source

void renderTriangleMesh(
    RenderState renderState,
    Int16List ixList, Float32List vxList, int color) {

  var matrix = renderState.globalMatrix;
  var alpha = renderState.globalAlpha;
  var ixListCount = ixList.length;
  var vxListCount = vxList.length >> 1;

  // check buffer sizes and flush if necessary

  var ixData = renderBufferIndex.data;
  var ixPosition = renderBufferIndex.position;
  if (ixPosition + ixListCount >= ixData.length) flush();

  var vxData = renderBufferVertex.data;
  var vxPosition = renderBufferVertex.position;
  if (vxPosition + vxListCount * 6 >= vxData.length) flush();

  var ixIndex = renderBufferIndex.position;
  var vxIndex = renderBufferVertex.position;
  var vxOffset = renderBufferVertex.count;

  // copy index list

  for (var i = 0; i < ixListCount; i++) {
    ixData[ixIndex + i] = vxOffset + ixList[i];
  }

  renderBufferIndex.position += ixListCount;
  renderBufferIndex.count += ixListCount;

  // copy vertex list

  var ma = matrix.a;
  var mb = matrix.b;
  var mc = matrix.c;
  var md = matrix.d;
  var mx = matrix.tx;
  var my = matrix.ty;

  var colorScale = 1 / 255.0;
  var colorA = colorScale * colorGetA(color) * alpha;
  var colorR = colorScale * colorGetR(color) * colorA;
  var colorG = colorScale * colorGetG(color) * colorA;
  var colorB = colorScale * colorGetB(color) * colorA;

  for (var i = 0, o = 0 ; i < vxListCount; i++, o += 2) {
    num x = vxList[o + 0];
    num y = vxList[o + 1];
    vxData[vxIndex + 0] = mx + ma * x + mc * y;
    vxData[vxIndex + 1] = my + mb * x + md * y;
    vxData[vxIndex + 2] = colorR;
    vxData[vxIndex + 3] = colorG;
    vxData[vxIndex + 4] = colorB;
    vxData[vxIndex + 5] = colorA;
    vxIndex += 6;
  }

  renderBufferVertex.position += vxListCount * 6;
  renderBufferVertex.count += vxListCount;
}