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

Function clipImage

Three.js/js/Three66.js:17000–17036  ·  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

16998 }
16999
17000 function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) {
17001
17002 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
17003
17004 var a, b, c, d, e, f, det, idet,
17005 width = image.width - 1,
17006 height = image.height - 1;
17007
17008 u0 *= width; v0 *= height;
17009 u1 *= width; v1 *= height;
17010 u2 *= width; v2 *= height;
17011
17012 x1 -= x0; y1 -= y0;
17013 x2 -= x0; y2 -= y0;
17014
17015 u1 -= u0; v1 -= v0;
17016 u2 -= u0; v2 -= v0;
17017
17018 det = u1 * v2 - u2 * v1;
17019
17020 idet = 1 / det;
17021
17022 a = ( v2 * x1 - v1 * x2 ) * idet;
17023 b = ( v2 * y1 - v1 * y2 ) * idet;
17024 c = ( u1 * x2 - u2 * x1 ) * idet;
17025 d = ( u1 * y2 - u2 * y1 ) * idet;
17026
17027 e = x0 - a * u0 - c * v0;
17028 f = y0 - b * u0 - d * v0;
17029
17030 _context.save();
17031 _context.transform( a, b, c, d, e, f );
17032 _context.clip();
17033 _context.drawImage( image, 0, 0 );
17034 _context.restore();
17035
17036 }
17037
17038 function getGradientTexture( color1, color2, color3, color4 ) {
17039

Callers 1

renderFace3Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected