MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / clipImage

Function clipImage

Three.js/js/Three62dev.js:16166–16202  ·  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

16164 }
16165
16166 function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) {
16167
16168 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
16169
16170 var a, b, c, d, e, f, det, idet,
16171 width = image.width - 1,
16172 height = image.height - 1;
16173
16174 u0 *= width; v0 *= height;
16175 u1 *= width; v1 *= height;
16176 u2 *= width; v2 *= height;
16177
16178 x1 -= x0; y1 -= y0;
16179 x2 -= x0; y2 -= y0;
16180
16181 u1 -= u0; v1 -= v0;
16182 u2 -= u0; v2 -= v0;
16183
16184 det = u1 * v2 - u2 * v1;
16185
16186 idet = 1 / det;
16187
16188 a = ( v2 * x1 - v1 * x2 ) * idet;
16189 b = ( v2 * y1 - v1 * y2 ) * idet;
16190 c = ( u1 * x2 - u2 * x1 ) * idet;
16191 d = ( u1 * y2 - u2 * y1 ) * idet;
16192
16193 e = x0 - a * u0 - c * v0;
16194 f = y0 - b * u0 - d * v0;
16195
16196 _context.save();
16197 _context.transform( a, b, c, d, e, f );
16198 _context.clip();
16199 _context.drawImage( image, 0, 0 );
16200 _context.restore();
16201
16202 }
16203
16204 function getGradientTexture( color1, color2, color3, color4 ) {
16205

Callers 1

renderFace3Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected