mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-22 06:41:08 +00:00
Fix IntertwineAsLines to use algo_line_perfect() again when snap to grid is enabled or kSquareAspect modifier is pressed
This commit is contained in:
parent
232c551f1a
commit
d6e00d8764
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -29,6 +29,7 @@ gfx::Rect Intertwine::getStrokeBounds(ToolLoop* loop, const Stroke& stroke)
|
||||
return stroke.bounds();
|
||||
}
|
||||
|
||||
// static
|
||||
void Intertwine::doPointshapePoint(int x, int y, ToolLoop* loop)
|
||||
{
|
||||
Symmetry* symmetry = loop->getSymmetry();
|
||||
@ -52,24 +53,33 @@ void Intertwine::doPointshapePoint(int x, int y, ToolLoop* loop)
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void Intertwine::doPointshapeHline(int x1, int y, int x2, ToolLoop* loop)
|
||||
{
|
||||
algo_line_perfect(x1, y, x2, y, loop, (AlgoPixel)doPointshapePoint);
|
||||
}
|
||||
|
||||
// static
|
||||
void Intertwine::doPointshapeLine(int x1, int y1, int x2, int y2, ToolLoop* loop)
|
||||
{
|
||||
doc::AlgoLineWithAlgoPixel algo = getLineAlgo(loop);
|
||||
algo(x1, y1, x2, y2, (void*)loop, (AlgoPixel)doPointshapePoint);
|
||||
}
|
||||
|
||||
// static
|
||||
doc::AlgoLineWithAlgoPixel Intertwine::getLineAlgo(ToolLoop* loop)
|
||||
{
|
||||
if (// When "Snap Angle" in being used or...
|
||||
(int(loop->getModifiers()) & int(ToolLoopModifiers::kSquareAspect)) ||
|
||||
// "Snap to Grid" is enabled
|
||||
(loop->getController()->canSnapToGrid() && loop->getSnapToGrid())) {
|
||||
// We prefer the perfect pixel lines that matches grid tiles
|
||||
algo_line_perfect(x1, y1, x2, y2, loop, (AlgoPixel)doPointshapePoint);
|
||||
return algo_line_perfect;
|
||||
}
|
||||
else {
|
||||
// In other case we use the regular algorithm that is useful to
|
||||
// draw continuous lines/strokes.
|
||||
algo_line_continuous(x1, y1, x2, y2, loop, (AlgoPixel)doPointshapePoint);
|
||||
return algo_line_continuous;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -8,6 +9,7 @@
|
||||
#define APP_TOOLS_INTERTWINE_H_INCLUDED
|
||||
#pragma once
|
||||
|
||||
#include "doc/algo.h"
|
||||
#include "gfx/point.h"
|
||||
#include "gfx/rect.h"
|
||||
|
||||
@ -37,6 +39,8 @@ namespace app {
|
||||
static void doPointshapePoint(int x, int y, ToolLoop* loop);
|
||||
static void doPointshapeHline(int x1, int y, int x2, ToolLoop* loop);
|
||||
static void doPointshapeLine(int x1, int y1, int x2, int y2, ToolLoop* loop);
|
||||
|
||||
static doc::AlgoLineWithAlgoPixel getLineAlgo(ToolLoop* loop);
|
||||
};
|
||||
|
||||
} // namespace tools
|
||||
|
@ -102,8 +102,9 @@ public:
|
||||
}
|
||||
}
|
||||
else {
|
||||
doc::AlgoLineWithAlgoPixel lineAlgo = getLineAlgo(loop);
|
||||
for (int c=0; c+1<stroke.size(); ++c) {
|
||||
algo_line_continuous(
|
||||
lineAlgo(
|
||||
stroke[c].x,
|
||||
stroke[c].y,
|
||||
stroke[c+1].x,
|
||||
|
@ -1,5 +1,5 @@
|
||||
// Aseprite Document Library
|
||||
// Copyright (C) 2018 Igara Studio S.A.
|
||||
// Copyright (C) 2018-2019 Igara Studio S.A.
|
||||
// Copyright (c) 2001-2018 David Capello
|
||||
//
|
||||
// This file is released under the terms of the MIT license.
|
||||
@ -18,6 +18,7 @@ namespace doc {
|
||||
|
||||
typedef void (*AlgoPixel)(int x, int y, void *data);
|
||||
typedef void (*AlgoLine)(int x1, int y1, int x2, int y2, void *data);
|
||||
typedef void (*AlgoLineWithAlgoPixel)(int x1, int y1, int x2, int y2, void *data, AlgoPixel proc);
|
||||
|
||||
// Useful to create lines with more predictable behavior and perfect
|
||||
// pixel block of lines where we'll have a number of lines/rows that
|
||||
|
Loading…
x
Reference in New Issue
Block a user