Pencil2D Animation
Download Community News Docs Contribute
  • Overview
  • Articles
  • Code
  •  
  • Class List
  • Class Index
  • Class Hierarchy
  • Class Members
  • File List
Loading...
Searching...
No Matches
  • core_lib
  • src
  • graphics
  • bitmap
tile.cpp
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2012-2020 Matthew Chiawen Chang
5
6This program is free software; you can redistribute it and/or
7modify it under the terms of the GNU General Public License
8as published by the Free Software Foundation; version 2 of the License.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15*/
16
17#include "tile.h"
18
19#include <QPainter>
20
21Tile::Tile(const QPoint& pos, QSize size):
22 mTilePixmap(size),
23 mPosF(pos),
24 mPos(pos),
25 mBounds(pos, size),
26 mSize(size)
27{
28 clear(); //Default tiles are transparent
29}
30
31Tile::~Tile()
32{
33}
34
35void Tile::load(const QImage& image, const QPoint& topLeft)
36{
37 QPainter painter(&mTilePixmap);
38
39 painter.translate(-mPos);
40 painter.drawImage(topLeft, image);
41 painter.end();
42}
43
44void Tile::clear()
45{
46 mTilePixmap.fill(Qt::transparent);
47}
Tile::load
void load(const QImage &image, const QPoint &topLeft)
Loads the input image into the tile.
Definition: tile.cpp:35
QImage
QPainter
QPainter::drawImage
void drawImage(const QRectF &target, const QImage &image, const QRectF &source, Qt::ImageConversionFlags flags)
QPainter::end
bool end()
QPainter::translate
void translate(const QPointF &offset)
QPixmap::fill
void fill(const QColor &color)
QPoint
QSize
Qt::transparent
transparent
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39