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

Function clipImage

Three.js/js/Three59dev.js:15940–15976  ·  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

15938 }
15939
15940 function clipImage( x0, y0, x1, y1, x2, y2, u0, v0, u1, v1, u2, v2, image ) {
15941
15942 // http://extremelysatisfactorytotalitarianism.com/blog/?p=2120
15943
15944 var a, b, c, d, e, f, det, idet,
15945 width = image.width - 1,
15946 height = image.height - 1;
15947
15948 u0 *= width; v0 *= height;
15949 u1 *= width; v1 *= height;
15950 u2 *= width; v2 *= height;
15951
15952 x1 -= x0; y1 -= y0;
15953 x2 -= x0; y2 -= y0;
15954
15955 u1 -= u0; v1 -= v0;
15956 u2 -= u0; v2 -= v0;
15957
15958 det = u1 * v2 - u2 * v1;
15959
15960 idet = 1 / det;
15961
15962 a = ( v2 * x1 - v1 * x2 ) * idet;
15963 b = ( v2 * y1 - v1 * y2 ) * idet;
15964 c = ( u1 * x2 - u2 * x1 ) * idet;
15965 d = ( u1 * y2 - u2 * y1 ) * idet;
15966
15967 e = x0 - a * u0 - c * v0;
15968 f = y0 - b * u0 - d * v0;
15969
15970 _context.save();
15971 _context.transform( a, b, c, d, e, f );
15972 _context.clip();
15973 _context.drawImage( image, 0, 0 );
15974 _context.restore();
15975
15976 }
15977
15978 function getGradientTexture( color1, color2, color3, color4 ) {
15979

Callers 2

renderFace3Function · 0.70
renderFace4Function · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected