tbx  0.7.5
drawtransform.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010-2012 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 /*
25  * drawtransform.h
26  *
27  * Created on: 2 Nov 2010
28  * Author: alanb
29  */
30 
31 #ifndef TBX_DRAWTRANSFORM_H_
32 #define TBX_DRAWTRANSFORM_H_
33 
34 #include "fixed16.h"
35 
36 namespace tbx
37 {
60  {
61  public:
66  int e;
67  int f;
68 
73  DrawTransform() {a = d = 1; b = c = e = f = 0;}
74 
78  void translate_os(int x, int y) {e = x << 8;f = y << 8;}
82  void translate_os_x(int x) {e = x << 8;}
86  void translate_os_y(int y) {f = y << 8;}
87 
93  void scale(int scale) {a=d=scale;b=c=0;}
94 
100  void scale(const Fixed16 &scale) {a=d=scale;b=c=0;}
101 
105  void scale_os() {a=d=256;b=c=0;}
106  };
107 }
108 
109 #endif /* TBX_DRAWTRANSFORM_H_ */
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
Class to represent Drawing transforms.
Definition: drawtransform.h:59
Class to represent a fixed point number with 16bits before and after the point.
Definition: fixed16.h:39
Fixed16 b
Top middle of transform matrix.
Definition: drawtransform.h:63
Fixed16 a
Top left of transform matrix.
Definition: drawtransform.h:62
int e
Translation in x direction in 256th of an OS unit.
Definition: drawtransform.h:66
void translate_os_y(int y)
Set transform translation in os units.
Definition: drawtransform.h:86
Fixed16 c
Middle left of transform matrix.
Definition: drawtransform.h:64
void scale_os()
Set matrix scale so 1 user unit = 1 os unit.
Definition: drawtransform.h:105
void translate_os_x(int x)
Set transform translation in os units.
Definition: drawtransform.h:82
void translate_os(int x, int y)
Set transform translation in os units.
Definition: drawtransform.h:78
int f
Translation in y direction in 256th of an OS unit.
Definition: drawtransform.h:67
DrawTransform()
Create the identity draw transform.
Definition: drawtransform.h:73
Fixed16 d
Middle of transform matrix.
Definition: drawtransform.h:65
void scale(int scale)
Set matrix to scale without rotation.
Definition: drawtransform.h:93
void scale(const Fixed16 &scale)
Set matrix to scale without rotation.
Definition: drawtransform.h:100