Allow using text color -> preview color algo outside.

This commit is contained in:
John Preston 2022-12-15 19:10:04 +04:00
parent 8649a55727
commit 770b5d0e59
2 changed files with 8 additions and 3 deletions

View file

@ -89,6 +89,11 @@ void PaintScaledImage(
} // namespace
QColor PreviewColorFromTextColor(QColor color) {
color.setAlpha((color.alpha() + 1) / 8);
return color;
}
Preview::Preview(QPainterPath path, float64 scale)
: _data(ScaledPath{ std::move(path), scale }) {
}
@ -131,9 +136,7 @@ void Preview::paintPath(
const Context &context,
const ScaledPath &path) {
auto hq = PainterHighQualityEnabler(p);
auto copy = context.textColor.value();
copy.setAlpha((copy.alpha() + 1) / 8);
p.setBrush(copy);
p.setBrush(PreviewColorFromTextColor(context.textColor));
p.setPen(Qt::NoPen);
const auto scale = path.scale;
const auto required = (scale != 1.) || context.scaled;

View file

@ -25,6 +25,8 @@ namespace Ui::CustomEmoji {
using Context = Ui::Text::CustomEmoji::Context;
[[nodiscard]] QColor PreviewColorFromTextColor(QColor color);
class Preview final {
public:
Preview() = default;