LCDGFX LCD display driver
1.2.0
Lightweight graphics library for SSD1306, SSD1325, SSD1327, SSD1331, SSD1351, SH1106, SH1107, IL9163, ST7735, ST7789, ILI9341, PCD8544 displays over I2C/SPI
sprite.h
Go to the documentation of this file.
1
/*
2
MIT License
3
4
Copyright (c) 2018-2019, Alexey Dynda
5
6
Permission is hereby granted, free of charge, to any person obtaining a copy
7
of this software and associated documentation files (the "Software"), to deal
8
in the Software without restriction, including without limitation the rights
9
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
copies of the Software, and to permit persons to whom the Software is
11
furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in all
14
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 THE
22
SOFTWARE.
23
*/
28
#ifndef _NANO_SPRITE_H_
29
#define _NANO_SPRITE_H_
30
31
#include "
canvas/point.h
"
32
#include "
canvas/rect.h
"
33
#include "object.h"
34
#include "
lcd_hal/io.h
"
35
45
template
<
class
T>
class
NanoSprite
:
public
NanoObject
<T>
46
{
47
public
:
55
NanoSprite
(
const
NanoPoint
&pos,
const
NanoPoint
&size,
const
uint8_t *bitmap)
56
:
NanoObject
<T>(pos, size)
57
, m_bitmap(bitmap)
58
{
59
}
60
61
void
draw
()
override
62
{
63
this->
getTiler
().getCanvas().drawBitmap1(this->
getRect
().p1.x, this->getRect().
p1
.
y
, this->
getRect
().
width
(),
64
this->
getRect
().
height
(), this->
getBitmap
());
65
}
66
70
void
setBitmap
(
const
uint8_t *bitmap)
71
{
72
m_bitmap = bitmap;
73
}
74
79
const
uint8_t *
getBitmap
()
80
{
81
return
m_bitmap;
82
}
83
84
private
:
85
const
uint8_t *m_bitmap;
86
};
87
91
template
<
class
T>
class
NanoFixedSprite
:
public
NanoSprite
<T>
92
{
93
public
:
94
using
NanoSprite<T>::NanoSprite
;
95
};
96
101
#endif
NanoSprite::setBitmap
void setBitmap(const uint8_t *bitmap)
Replaces sprite bitmap with new one.
Definition:
sprite.h:70
_NanoPoint
Describes point.
Definition:
point.h:39
NanoSprite
This is template class for user sprites implementations.
Definition:
sprite.h:45
_NanoRect::height
lcdint_t height() const
returns height of NanoRect
Definition:
rect.h:69
point.h
Point class.
NanoObject::getRect
const NanoRect & getRect() const
Returns rectangle area, occupied by the NanoObject.
Definition:
object.h:232
io.h
SSD1306 HAL IO communication functions.
_NanoPoint::y
lcdint_t y
y position in pixels
Definition:
point.h:44
rect.h
Rectangle class.
NanoObject
This is base class for all NanoObjects.
Definition:
object.h:49
NanoEngineObject::getTiler
T & getTiler()
Returns reference to NanoEngine.
Definition:
tiler.h:148
_NanoRect::width
lcdint_t width() const
returns width of NanoRect
Definition:
rect.h:51
_NanoRect::p1
NanoPoint p1
top-left point of the rectangle area
Definition:
rect.h:45
NanoSprite::NanoSprite
NanoSprite(const NanoPoint &pos, const NanoPoint &size, const uint8_t *bitmap)
Creates sprite object of variable size.
Definition:
sprite.h:55
NanoSprite::getBitmap
const uint8_t * getBitmap()
Returns pointer to sprite bitmap data.
Definition:
sprite.h:79
NanoSprite::draw
void draw() override
Draws nano object Engine canvas.
Definition:
sprite.h:61
NanoFixedSprite
This is base class for user sprites implementation.
Definition:
sprite.h:91
src
v2
nano_engine
sprite.h
Generated by
1.8.13