MCPcopy Create free account
hub / github.com/Snapchat/Valdi / updateMatrix

Method updateMatrix

snap_drawing/src/snap_drawing/cpp/Layers/Layer.cpp:347–378  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

345}
346
347void Layer::updateMatrix(Scalar width, Scalar height) {
348 _matrix.setIdentity();
349
350 auto scaledWidth = width;
351 auto scaledHeight = height;
352 auto translationX = _translation.width;
353 auto translationY = _translation.height;
354
355 // Compensate for the change of size so that it appears as if we are scaling from the center
356 if (_scaleX != 1.0f) {
357 scaledWidth *= _scaleX;
358
359 translationX += (width - scaledWidth) / 2.0f;
360 _matrix.setScaleX(_scaleX);
361 }
362
363 if (_scaleY != 1.0f) {
364 scaledHeight *= _scaleY;
365
366 translationY += (height - scaledHeight) / 2.0f;
367 _matrix.setScaleY(_scaleY);
368 }
369
370 _matrix.setTranslateX(_frame.left + translationX);
371 _matrix.setTranslateY(_frame.top + translationY);
372
373 if (_rotation != 0.0f) {
374 Scalar centerX = _matrix.getTranslateX() + scaledWidth / 2.0f;
375 Scalar centerY = _matrix.getTranslateY() + scaledHeight / 2.0f;
376 _matrix.postRotate(_rotation, centerX, centerY);
377 }
378}
379
380void Layer::setTouchAreaExtension(Scalar left, Scalar right, Scalar top, Scalar bottom) {
381 _touchAreaExtensionLeft = left;

Callers

nothing calls this directly

Calls 8

setIdentityMethod · 0.80
setTranslateXMethod · 0.80
setTranslateYMethod · 0.80
getTranslateXMethod · 0.80
getTranslateYMethod · 0.80
postRotateMethod · 0.80
setScaleXMethod · 0.45
setScaleYMethod · 0.45

Tested by

no test coverage detected