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
bitmapbucket.h
1/*
2
3Pencil2D - Traditional Animation Software
4Copyright (C) 2005-2007 Patrick Corrieri & Pascal Naidon
5Copyright (C) 2012-2020 Matthew Chiawen Chang
6
7This program is free software; you can redistribute it and/or
8modify it under the terms of the GNU General Public License
9as published by the Free Software Foundation; version 2 of the License.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16*/
17#ifndef BITMAPBUCKET_H
18#define BITMAPBUCKET_H
19
20#include "bitmapimage.h"
21#include "basetool.h"
22
23#include <functional>
24
25class Layer;
26class Editor;
27
28enum class BucketState
29{
30 WillFillTarget, // Before applying to target image
31 DidFillTarget, // After calling floodfill and applied to target
32};
33
34class BitmapBucket
35{
36public:
37 explicit BitmapBucket();
38 explicit BitmapBucket(Editor* editor, QColor color, QRect maxFillRegion, QPointF fillPoint, Properties properties);
39
46 void paint(const QPointF& updatedPoint, std::function<void(BucketState, int, int)> progress);
47
48private:
49
50
60 bool allowFill(const QPoint& checkPoint, const QRgb& checkColor) const;
61 bool allowContinuousFill(const QPoint& checkPoint, const QRgb& checkColor) const;
62
64 bool canUseDragToFill(const QPoint& fillPoint, const QColor& bucketColor, const BitmapImage& referenceImage);
65
66 BitmapImage flattenBitmapLayersToImage();
67
68 Editor* mEditor = nullptr;
69 Layer* mTargetFillToLayer = nullptr;
70
71 QHash<QRgb, bool> *mPixelCache;
72
73 BitmapImage mReferenceImage;
74 QRgb mBucketColor = 0;
75 QRgb mStartReferenceColor = 0;
76
77 QRect mMaxFillRegion;
78
79 int mTolerance = 0;
80
81 int mTargetFillToLayerIndex = -1;
82 bool mFilledOnce = false;
83 bool mUseDragToFill = false;
84
85 Properties mProperties;
86};
87
88#endif // BITMAPBUCKET_H
BitmapBucket
Definition: bitmapbucket.h:35
BitmapBucket::canUseDragToFill
bool canUseDragToFill(const QPoint &fillPoint, const QColor &bucketColor, const BitmapImage &referenceImage)
Determines whether fill to drag feature can be used.
Definition: bitmapbucket.cpp:68
BitmapBucket::allowFill
bool allowFill(const QPoint &checkPoint, const QRgb &checkColor) const
Based on the various factors dependant on which tool properties are set, the result will:
Definition: bitmapbucket.cpp:85
BitmapBucket::paint
void paint(const QPointF &updatedPoint, std::function< void(BucketState, int, int)> progress)
Will paint at the given point, given that it makes sense.
Definition: bitmapbucket.cpp:114
BitmapImage
Definition: bitmapimage.h:28
Editor
Definition: editor.h:71
Layer
Definition: layer.h:33
Properties
Definition: basetool.h:39
QColor
QHash
QPoint
QPointF
QRect
Generated on Thu May 8 2025 04:47:53 for Pencil2D by doxygen 1.9.6 based on revision 4513250b1d5b1a3676ec0e67b06b7a885ceaae39