Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 0348ca49 authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Sketch of class to change images. Not Working

parent 374c5eab
/*
* Copyright (c) 2012 Dmitry Kazakov <dimula73@gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef __KIS_ANIMATED_BRUSHES_H
#define __KIS_ANIMATED_BRUSHES_H
template<class BrushType>
class KisAnimatedBrushes
{
public:
KisAnimatedBrushes() {
}
/* save the state of the brush here and change the brush here */
/* TODO: Fix a lot of things */
KisAnimatedBrushes(const KisBrushesPipe &rhs) {
qDeleteAll(m_brushes);
m_brushes.clear();
Q_FOREACH (BrushType * brush, rhs.m_brushes) {
BrushType *clonedBrush = dynamic_cast<BrushType*>(brush->clone());
KIS_ASSERT_RECOVER(clonedBrush) {continue;}
m_brushes.append(clonedBrush);
}
}
virtual ~KisBrushesPipe() {
qDeleteAll(m_brushes);
}
virtual void clear() {
qDeleteAll(m_brushes);
m_brushes.clear();
}
BrushType* firstBrush() const {
return m_brushes.first();
}
BrushType* lastBrush() const {
return m_brushes.last();
}
BrushType* currentBrush(const KisPaintInformation& info) {
return !m_brushes.isEmpty() ? m_brushes.at(chooseNextBrush(info)) : 0;
}
int brushIndex(const KisPaintInformation& info) {
return chooseNextBrush(info);
}
protected:
void addBrush(BrushType *brush) {
m_brushes.append(brush);
}
/**
* Returns the index of the brush that corresponds to the current
* values of \p info. This method is called *before* the dab is
* actually painted.
*
* The method is const, so no internal counters of the brush should
* change during its execution
*/
virtual int chooseNextBrush(const KisPaintInformation& info) = 0;
/**
* Updates internal counters of the brush *after* a dab has been
* painted on the canvas. Some incremental switching of the brushes
* may me implemented in this method.
*
* If \p seqNo is equal or greater than zero, then incremental iteration is
* overridden by this seqNo value
*/
virtual void updateBrushIndexes(const KisPaintInformation& info, int seqNo) = 0;
protected:
QVector<BrushType*> m_brushes;
};
#endif /* __KIS_ANIMATED_BRUSHES_H */
......@@ -37,7 +37,17 @@ KisVectorAnimatedBrush::KisVectorAnimatedBrush(const QString& filename)
setBrushType(INVALID);
setSpacing(0.25);
setHasColor(false);
m_imageNumber = 0;
m_numberOfImages = 0;
m_isInitialized = false;
if (m_isInitialized) {
if (m_imageNumber == m_numberOfImages) {
m_imageNumber = 0;
} else {
m_imageNumber ++;
}
}
}
KisVectorAnimatedBrush::KisVectorAnimatedBrush(const KisVectorAnimatedBrush& rhs)
......@@ -91,15 +101,42 @@ bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
for (i = list.constBegin(); i != list.constEnd(); ++i)
qDebug() << "figura" << *i;
// qDebug() << list.at(*i) ;
*/
for (int i = 0; i != list.size(); ++i) {
qDebug() << "figura" << i;
qDebug() << list.at(i);
}
*/
// m_imageNumber = 0;
qDebug() << "Numero:" << m_imageNumber;
QList<KoShape*> single;
single.append(list.at(m_imageNumber));
qDebug() << "lista" << list.count();
qDebug() << "figura" << m_imageNumber << list.at(m_imageNumber);
/*
if (m_imageNumber == list.size()) {
m_imageNumber = 0;
}
else {
m_imageNumber ++;
}
*/
m_numberOfImages = list.size();
m_isInitialized = true;
qDebug() << "numberImages" << m_numberOfImages << "initialized" << m_isInitialized << "numero" << m_imageNumber ;
KoShapePainter painter;
painter.setShapes(list);
painter.setShapes(single);
QImage theImage(1000, 1000, QImage::Format_ARGB32); //fix size
{
QPainter p(&theImage);
p.fillRect(0, 0, theImage.width(), theImage.height(), Qt::white);
}
painter.paint(theImage);
......@@ -111,7 +148,7 @@ bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
// ------------------------------------------- old ------------------------
QSvgRenderer renderer(m_svg);
/* QSvgRenderer renderer(m_svg);
QRect box = renderer.viewBox();
if (box.isEmpty()) return false;
......@@ -121,12 +158,15 @@ bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
p.fillRect(0, 0, image_.width(), image_.height(), Qt::white);
renderer.render(&p);
}
*/
// ------------------------------------------- old ------------------------
QVector<QRgb> table;
for (int i = 0; i < 256; ++i) table.push_back(qRgb(i, i, i));
image_ = image_.convertToFormat(QImage::Format_Indexed8, table);
theImage = theImage.convertToFormat(QImage::Format_Indexed8, table);
setBrushTipImage(image_);
setBrushTipImage(theImage);
// Blackbeard TODO!!
// KoCanvasControllerWidgetViewport_p.cpp
// KoSvgSymbolCollectionResource.cpp
......
......@@ -38,6 +38,9 @@ public:
void toXML(QDomDocument& d, QDomElement& e) const override;
private:
QByteArray m_svg;
int m_imageNumber;
int m_numberOfImages;
bool m_isInitialized;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment