MCPcopy Index your code
hub / github.com/benfry/processing4 / transform

Method transform

core/src/processing/opengl/PShapeOpenGL.java:1371–1444  ·  view source on GitHub ↗
(int type, float... args)

Source from the content-addressed store, hash-verified

1369
1370
1371 protected void transform(int type, float... args) {
1372 int dimensions = is3D ? 3 : 2;
1373 boolean invertible = true;
1374 checkMatrix(dimensions);
1375 if (transform == null) {
1376 if (dimensions == 2) {
1377 transform = new PMatrix2D();
1378 transformInv = new PMatrix2D();
1379 } else {
1380 transform = new PMatrix3D();
1381 transformInv = new PMatrix3D();
1382 }
1383 } else {
1384 transform.reset();
1385 transformInv.reset();
1386 }
1387
1388 int ncoords = args.length;
1389 if (type == ROTATE) {
1390 ncoords = args.length == 1 ? 2 : 3;
1391 } else if (type == MATRIX) {
1392 ncoords = args.length == 6 ? 2 : 3;
1393 }
1394
1395 switch (type) {
1396 case TRANSLATE:
1397 if (ncoords == 3) {
1398 transform.translate(args[0], args[1], args[2]);
1399 PGraphicsOpenGL.invTranslate((PMatrix3D)transformInv, args[0], args[1], args[2]);
1400 } else {
1401 transform.translate(args[0], args[1]);
1402 PGraphicsOpenGL.invTranslate((PMatrix2D)transformInv, args[0], args[1]);
1403 }
1404 break;
1405 case ROTATE:
1406 if (ncoords == 3) {
1407 transform.rotate(args[0], args[1], args[2], args[3]);
1408 PGraphicsOpenGL.invRotate((PMatrix3D)transformInv, args[0], args[1], args[2], args[3]);
1409 } else {
1410 transform.rotate(args[0]);
1411 PGraphicsOpenGL.invRotate((PMatrix2D)transformInv, -args[0]);
1412 }
1413 break;
1414 case SCALE:
1415 if (ncoords == 3) {
1416 transform.scale(args[0], args[1], args[2]);
1417 PGraphicsOpenGL.invScale((PMatrix3D)transformInv, args[0], args[1], args[2]);
1418 } else {
1419 transform.scale(args[0], args[1]);
1420 PGraphicsOpenGL.invScale((PMatrix2D)transformInv, args[0], args[1]);
1421 }
1422 break;
1423 case MATRIX:
1424 if (ncoords == 3) {
1425 transform.set(args[ 0], args[ 1], args[ 2], args[ 3],
1426 args[ 4], args[ 5], args[ 6], args[ 7],
1427 args[ 8], args[ 9], args[10], args[11],
1428 args[12], args[13], args[14], args[15]);

Callers 9

translateMethod · 0.95
rotateMethod · 0.95
scaleMethod · 0.95
applyMatrixMethod · 0.95
LinearGradientMethod · 0.80
RadialGradientMethod · 0.80
formatMethod · 0.80
createContextMethod · 0.80
applyMatrixMethod · 0.80

Calls 14

checkMatrixMethod · 0.95
invTranslateMethod · 0.95
invRotateMethod · 0.95
invScaleMethod · 0.95
showWarningMethod · 0.95
applyMatrixImplMethod · 0.95
resetMethod · 0.65
translateMethod · 0.65
rotateMethod · 0.65
scaleMethod · 0.65
setMethod · 0.65
invertMethod · 0.65

Tested by

no test coverage detected