MCPcopy
hub / github.com/processing/p5.js / _copyHelper

Method _copyHelper

src/image/p5.Image.js:918–970  ·  view source on GitHub ↗
(
    dstImage,
    srcImage,
    sx,
    sy,
    sw,
    sh,
    dx,
    dy,
    dw,
    dh
  )

Source from the content-addressed store, hash-verified

916 }
917
918 _copyHelper(
919 dstImage,
920 srcImage,
921 sx,
922 sy,
923 sw,
924 sh,
925 dx,
926 dy,
927 dw,
928 dh
929 ){
930 const s = srcImage.canvas.width / srcImage.width;
931 // adjust coord system for 3D when renderer
932 // ie top-left = -width/2, -height/2
933 let sxMod = 0;
934 let syMod = 0;
935 if (srcImage._renderer && srcImage._renderer.isP3D) {
936 sxMod = srcImage.width / 2;
937 syMod = srcImage.height / 2;
938 }
939 if (dstImage._renderer && dstImage._renderer.isP3D) {
940 dstImage.push();
941 dstImage.resetMatrix();
942 dstImage.noLights();
943 dstImage.blendMode(dstImage.BLEND);
944 dstImage.imageMode(dstImage.CORNER);
945 dstImage._renderer.image(
946 srcImage,
947 sx + sxMod,
948 sy + syMod,
949 sw,
950 sh,
951 dx,
952 dy,
953 dw,
954 dh
955 );
956 dstImage.pop();
957 } else {
958 dstImage.drawingContext.drawImage(
959 srcImage.canvas,
960 s * (sx + sxMod),
961 s * (sy + syMod),
962 s * sw,
963 s * sh,
964 dx,
965 dy,
966 dw,
967 dh
968 );
969 }
970 }
971
972 /**
973 * Masks part of the image with another.

Callers 2

copyMethod · 0.95
pixelsFunction · 0.80

Calls 5

imageMethod · 0.80
pushMethod · 0.45
resetMatrixMethod · 0.45
blendModeMethod · 0.45
popMethod · 0.45

Tested by

no test coverage detected