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

Function clipImage

Three.js/js/Three62.js:16208–16244  ·  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

16206 }
16207
16208 function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) {
16209
16210 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
16211
16212 var a, b, c, d, e, f, det, idet,
16213 width = image.width - 1,
16214 height = image.height - 1;
16215
16216 u0 *= width; v0 *= height;
16217 u1 *= width; v1 *= height;
16218 u2 *= width; v2 *= height;
16219
16220 x1 -= x0; y1 -= y0;
16221 x2 -= x0; y2 -= y0;
16222
16223 u1 -= u0; v1 -= v0;
16224 u2 -= u0; v2 -= v0;
16225
16226 det = u1 * v2 - u2 * v1;
16227
16228 idet = 1 / det;
16229
16230 a = ( v2 * x1 - v1 * x2 ) * idet;
16231 b = ( v2 * y1 - v1 * y2 ) * idet;
16232 c = ( u1 * x2 - u2 * x1 ) * idet;
16233 d = ( u1 * y2 - u2 * y1 ) * idet;
16234
16235 e = x0 - a * u0 - c * v0;
16236 f = y0 - b * u0 - d * v0;
16237
16238 _context.save();
16239 _context.transform( a, b, c, d, e, f );
16240 _context.clip();
16241 _context.drawImage( image, 0, 0 );
16242 _context.restore();
16243
16244 }
16245
16246 function getGradientTexture( color1, color2, color3, color4 ) {
16247

Callers 1

renderFace3Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected