Pencil2D  ff90c0872e88be3bf81c548cd60f01983012ec49
Pencil2D is an animation software for both bitmap and vector graphics. It is free, multi-platform, and open source.
 All Classes Functions
camera.cpp
1 /*
2 
3 Pencil - Traditional Animation Software
4 Copyright (C) 2012-2017 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #include "camera.h"
18 
19 Camera::Camera()
20 {
21 }
22 
23 Camera::Camera(QPointF translation, float rotation, float scaling)
24 {
25  //view = viewMatrix;
26  mTranslate = translation;
27  mRotate = rotation;
28  mScale = scaling;
29  updateViewTransform();
30 }
31 
32 Camera::~Camera()
33 {
34 }
35 
36 void Camera::setViewTransform(QPointF translation, float rotation, float scaling)
37 {
38  mTranslate = translation;
39  mRotate = rotation;
40  mScale = scaling;
41  updateViewTransform();
42 }
43 
44 void Camera::updateViewTransform()
45 {
46  QTransform t;
47  t.translate(mTranslate.x(), mTranslate.y());
48 
49  QTransform r;
50  r.rotate(mRotate);
51 
52  QTransform s;
53  s.scale(mScale, mScale);
54 
55  view = t * s * r;
56 }
57