Skip to content

Commit

Permalink
Implement multi layer onion skinning [WIP]
Browse files Browse the repository at this point in the history
  • Loading branch information
MrStevns committed Aug 21, 2024
1 parent 09ef787 commit 6ff03f0
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions core_lib/src/canvaspainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,26 +202,31 @@ void CanvasPainter::paint(const QRect& blitRect)

void CanvasPainter::paintOnionSkin(QPainter& painter, const QRect& blitRect)
{
Layer* layer = mObject->getLayer(mCurrentLayerIndex);

mOnionSkinSubPainter.paint(painter, layer, mOnionSkinPainterOptions, mFrameNumber, [&] (OnionSkinPaintState state, int onionFrameNumber) {
if (state == OnionSkinPaintState::PREV) {
switch (layer->type())
{
case Layer::BITMAP: { paintBitmapOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizePrevFrames); break; }
case Layer::VECTOR: { paintVectorOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizePrevFrames); break; }
default: break;
for (int i = 0; i < mObject->getLayerCount(); i++) {
Layer* layer = mObject->getLayer(i);
if (layer == nullptr) { continue; }

if (!layer->visible()) { continue; }

mOnionSkinSubPainter.paint(painter, layer, mOnionSkinPainterOptions, mFrameNumber, [&] (OnionSkinPaintState state, int onionFrameNumber) {
if (state == OnionSkinPaintState::PREV) {
switch (layer->type())
{
case Layer::BITMAP: { paintBitmapOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizePrevFrames); break; }
case Layer::VECTOR: { paintVectorOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizePrevFrames); break; }
default: break;
}
}
}
if (state == OnionSkinPaintState::NEXT) {
switch (layer->type())
{
case Layer::BITMAP: { paintBitmapOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizeNextFrames); break; }
case Layer::VECTOR: { paintVectorOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizeNextFrames); break; }
default: break;
if (state == OnionSkinPaintState::NEXT) {
switch (layer->type())
{
case Layer::BITMAP: { paintBitmapOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizeNextFrames); break; }
case Layer::VECTOR: { paintVectorOnionSkinFrame(painter, blitRect, layer, onionFrameNumber, mOnionSkinPainterOptions.colorizeNextFrames); break; }
default: break;
}
}
}
});
});
}
}

void CanvasPainter::paintBitmapOnionSkinFrame(QPainter& painter, const QRect& blitRect, Layer* layer, int nFrame, bool colorize)
Expand Down

0 comments on commit 6ff03f0

Please sign in to comment.