(x0, y0, color0, x1, y1, color1)
| 40 | let triangleColorsIndex = 0; |
| 41 | |
| 42 | function addLine(x0, y0, color0, x1, y1, color1) { |
| 43 | let normal = getNormal(x0, y0, x1, y1); |
| 44 | |
| 45 | // first triangle of line |
| 46 | trianglePositions[trianglePositionsIndex++] = x0; |
| 47 | trianglePositions[trianglePositionsIndex++] = y0; |
| 48 | triangleNormals[triangleNormalsIndex++] = normal.x * -1; |
| 49 | triangleNormals[triangleNormalsIndex++] = normal.y; |
| 50 | triangleColors[triangleColorsIndex++] = color0; |
| 51 | |
| 52 | trianglePositions[trianglePositionsIndex++] = x1; |
| 53 | trianglePositions[trianglePositionsIndex++] = y1; |
| 54 | triangleNormals[triangleNormalsIndex++] = normal.x * -1; |
| 55 | triangleNormals[triangleNormalsIndex++] = normal.y; |
| 56 | triangleColors[triangleColorsIndex++] = color1; |
| 57 | |
| 58 | trianglePositions[trianglePositionsIndex++] = x0; |
| 59 | trianglePositions[trianglePositionsIndex++] = y0; |
| 60 | triangleNormals[triangleNormalsIndex++] = normal.x; |
| 61 | triangleNormals[triangleNormalsIndex++] = normal.y * -1; |
| 62 | triangleColors[triangleColorsIndex++] = color0; |
| 63 | |
| 64 | // second triangle of line |
| 65 | trianglePositions[trianglePositionsIndex++] = x1; |
| 66 | trianglePositions[trianglePositionsIndex++] = y1; |
| 67 | triangleNormals[triangleNormalsIndex++] = normal.x; |
| 68 | triangleNormals[triangleNormalsIndex++] = normal.y * -1; |
| 69 | triangleColors[triangleColorsIndex++] = color1; |
| 70 | |
| 71 | trianglePositions[trianglePositionsIndex++] = x0; |
| 72 | trianglePositions[trianglePositionsIndex++] = y0; |
| 73 | triangleNormals[triangleNormalsIndex++] = normal.x; |
| 74 | triangleNormals[triangleNormalsIndex++] = normal.y * -1; |
| 75 | triangleColors[triangleColorsIndex++] = color0; |
| 76 | |
| 77 | trianglePositions[trianglePositionsIndex++] = x1; |
| 78 | trianglePositions[trianglePositionsIndex++] = y1; |
| 79 | triangleNormals[triangleNormalsIndex++] = normal.x * -1; |
| 80 | triangleNormals[triangleNormalsIndex++] = normal.y; |
| 81 | triangleColors[triangleColorsIndex++] = color1; |
| 82 | } |
| 83 | |
| 84 | function getDirection(x0, y0, x1, y1) { |
| 85 | let vectorX = x1 - x0; |
no test coverage detected