Commit 2ed1c1d5 authored by Blackbeard (alberto flores)'s avatar Blackbeard (alberto flores) 🚢

Fix iteration of shapesToimages

parent 3440921f
......@@ -38,7 +38,7 @@ KisVectorAnimatedBrush::KisVectorAnimatedBrush(const QString& filename)
: KisScalingSizeBrush(filename)
{
setBrushType(PIPE_MASK);
setSpacing(0.25);
setSpacing(1.0);
setHasColor(false);
}
......@@ -49,7 +49,12 @@ KisVectorAnimatedBrush::KisVectorAnimatedBrush(const KisVectorAnimatedBrush& rhs
{
}
/*
KisVectorAnimatedBrush::~KisVectorAnimatedBrush()
{
delete m_parasite;
}
*/
KisBrush* KisVectorAnimatedBrush::clone() const
{
return new KisVectorAnimatedBrush(*this);
......@@ -75,7 +80,7 @@ KisVectorBrushParasite KisVectorAnimatedBrush::m_parasite;
bool KisVectorAnimatedBrush::loadFromDevice(QIODevice *dev)
{
m_svg = dev->readAll();
qDebug() << "load";
m_parasite.parseSvg(m_svg);
m_parasite.setIndex(0);
setBrushTipImage(m_parasite.nextBrushTip());
......@@ -135,9 +140,11 @@ void KisVectorAnimatedBrush::toXML(QDomDocument& d, QDomElement& e) const
void KisVectorAnimatedBrush::prepareForSeqNo(const KisPaintInformation &info, int seqNo)
{
Q_UNUSED(info)
Q_UNUSED(seqNo)
m_parasite.nextIndex();
KisVectorAnimatedBrush::newbrushTip();
Q_UNUSED(seqNo)
if (m_parasite.canPaint()) {
m_parasite.nextIndex();
KisVectorAnimatedBrush::newbrushTip();
}
}
/*
......@@ -153,7 +160,8 @@ void KisVectorAnimatedBrush::notifyCachedDabPainted(const KisPaintInformation &i
void KisVectorAnimatedBrush::notifyStrokeStarted()
{
qDebug() << "started";
int number = m_parasite.numberStrokes();
qDebug() << "Stroke:" << number;
}
......@@ -171,9 +179,15 @@ void KisVectorAnimatedBrush::newbrushTip()
setWidth(brushTipImage().width());
setHeight(brushTipImage().height());
}
/*
QImage KisVectorAnimatedBrush::brushTipImage() const
{
QImage image = m_parasite.nextBrushTip();
return image;
}
*/
/*
KisFixedPaintDeviceSP KisVectorAnimatedBrush::paintDevice(const KoColorSpace *colorSpace,
......
......@@ -37,6 +37,8 @@ public:
/// Construct brush to load filename later as brush
KisVectorAnimatedBrush(const QString& filename);
KisVectorAnimatedBrush(const KisVectorAnimatedBrush& rhs);
// ~KisVectorAnimatedBrush() override;
KisBrush* clone() const override;
bool load() override;
......@@ -55,6 +57,7 @@ public:
// QImage brushTipImage() const override;
// Asks for the new image
/*
......@@ -68,9 +71,6 @@ public:
private:
QByteArray m_svg;
static KisVectorBrushParasite m_parasite;
/* struct Private;
Private * const m_d; */
};
#endif
......@@ -28,7 +28,8 @@
#include <QDebug>
KisVectorBrushParasite::KisVectorBrushParasite()
{
{
m_strokes = 0;
}
void KisVectorBrushParasite::parseSvg(QByteArray svg)
......@@ -98,16 +99,32 @@ QImage KisVectorBrushParasite::shapeToQImage(QList<KoShape *> shapes, int index)
QList<QImage> KisVectorBrushParasite::shapesToImages(QList<KoShape *> shapes)
{
QList<QImage> images;
QListIterator<KoShape*> iter(shapes);
int index = 0;
while(iter.hasNext())
// QListIterator<KoShape*> iter(shapes);
// int index = 0;
for(int i = 0; i<shapes.count(); i++)
{
images.append(KisVectorBrushParasite::shapeToQImage(shapes, index));
index++;
images.append(KisVectorBrushParasite::shapeToQImage(shapes, i));
}
return images;
}
int KisVectorBrushParasite::numberStrokes()
{
int strokes = m_strokes;
m_strokes++;
if (strokes > 2)
{
m_canPaint = true;
} else {
m_canPaint = false;
}
return strokes;
}
bool KisVectorBrushParasite::canPaint()
{
return m_canPaint;
}
QImage KisVectorBrushParasite::nextBrushTip()
......@@ -125,7 +142,7 @@ int KisVectorBrushParasite::maxIndex()
void KisVectorBrushParasite::nextIndex()
{
qDebug() << "index" << m_index;
// qDebug() << "index" << m_index;
if (m_index == m_maxIndex){
m_index = 0;
} else {
......
......@@ -46,6 +46,8 @@ public:
void nextIndex();
int maxIndex();
int numberStrokes();
bool canPaint();
private:
......@@ -54,7 +56,8 @@ private:
QImage m_brushTip;
int m_maxIndex;
int m_index;
int m_strokes;
bool m_canPaint;
};
......
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