MCPcopy Index your code
hub / github.com/stemkoski/stemkoski.github.com / clipImage

Function clipImage

Three.js/js/Three60.js:16120–16156  ·  view source on GitHub ↗
( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image )

Source from the content-addressed store, hash-verified

16118 }
16119
16120 function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) {
16121
16122 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
16123
16124 var a, b, c, d, e, f, det, idet,
16125 width = image.width - 1,
16126 height = image.height - 1;
16127
16128 u0 *= width; v0 *= height;
16129 u1 *= width; v1 *= height;
16130 u2 *= width; v2 *= height;
16131
16132 x1 -= x0; y1 -= y0;
16133 x2 -= x0; y2 -= y0;
16134
16135 u1 -= u0; v1 -= v0;
16136 u2 -= u0; v2 -= v0;
16137
16138 det = u1 * v2 - u2 * v1;
16139
16140 idet = 1 / det;
16141
16142 a = ( v2 * x1 - v1 * x2 ) * idet;
16143 b = ( v2 * y1 - v1 * y2 ) * idet;
16144 c = ( u1 * x2 - u2 * x1 ) * idet;
16145 d = ( u1 * y2 - u2 * y1 ) * idet;
16146
16147 e = x0 - a * u0 - c * v0;
16148 f = y0 - b * u0 - d * v0;
16149
16150 _context.save();
16151 _context.transform( a, b, c, d, e, f );
16152 _context.clip();
16153 _context.drawImage( image, 0, 0 );
16154 _context.restore();
16155
16156 }
16157
16158 function getGradientTexture( color1, color2, color3, color4 ) {
16159

Callers 1

renderFace3Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected