mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-20 18:40:57 +00:00
Add support to pick tiles with eyedropper
This commit is contained in:
parent
d0c95cf46f
commit
d0ab7d720c
@ -1,5 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2019 Igara Studio S.A.
|
||||
// Copyright (C) 2019-2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -126,24 +126,41 @@ void ColorPicker::pickColor(const Site& site,
|
||||
|
||||
// Pick from the composed image
|
||||
case FromComposition: {
|
||||
m_color = app::Color::fromImage(
|
||||
sprite->pixelFormat(),
|
||||
render::get_sprite_pixel(sprite, pos.x, pos.y,
|
||||
site.frame(), proj,
|
||||
Preferences::instance().experimental.newBlend()));
|
||||
|
||||
doc::CelList cels;
|
||||
sprite->pickCels(pos.x, pos.y, site.frame(), kOpacityThreshold,
|
||||
sprite->allVisibleLayers(), cels);
|
||||
if (!cels.empty())
|
||||
m_layer = cels.front()->layer();
|
||||
|
||||
if (site.tilemapMode() == TilemapMode::Tiles) {
|
||||
if (!cels.empty()) {
|
||||
gfx::Point tilePos = site.grid().canvasToTile(gfx::Point(pos));
|
||||
m_color = app::Color::fromIndex(
|
||||
doc::get_pixel(cels.front()->image(), tilePos.x, tilePos.y));
|
||||
}
|
||||
}
|
||||
else if (site.tilemapMode() == TilemapMode::Pixels) {
|
||||
m_color = app::Color::fromImage(
|
||||
sprite->pixelFormat(),
|
||||
render::get_sprite_pixel(sprite, pos.x, pos.y,
|
||||
site.frame(), proj,
|
||||
Preferences::instance().experimental.newBlend()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Pick from the current layer
|
||||
case FromActiveLayer: {
|
||||
const Cel* cel = site.cel();
|
||||
if (cel) {
|
||||
if (!cel)
|
||||
return;
|
||||
|
||||
if (site.tilemapMode() == TilemapMode::Tiles) {
|
||||
gfx::Point tilePos = site.grid().canvasToTile(gfx::Point(pos));
|
||||
m_color = app::Color::fromIndex(
|
||||
doc::get_pixel(cel->image(), tilePos.x, tilePos.y));
|
||||
}
|
||||
else if (site.tilemapMode() == TilemapMode::Pixels) {
|
||||
doc::color_t imageColor;
|
||||
if (!get_cel_pixel(cel, pos.x, pos.y,
|
||||
site.frame(), imageColor))
|
||||
|
@ -1,4 +1,5 @@
|
||||
// Aseprite
|
||||
// Copyright (C) 2020 Igara Studio S.A.
|
||||
// Copyright (C) 2001-2018 David Capello
|
||||
//
|
||||
// This program is distributed under the terms of
|
||||
@ -8,22 +9,18 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "app/app.h"
|
||||
#include "app/color.h"
|
||||
#include "app/color_picker.h"
|
||||
#include "app/commands/cmd_eyedropper.h"
|
||||
#include "app/commands/commands.h"
|
||||
#include "app/commands/params.h"
|
||||
#include "app/modules/editors.h"
|
||||
#include "app/context.h"
|
||||
#include "app/pref/preferences.h"
|
||||
#include "app/site.h"
|
||||
#include "app/tools/tool.h"
|
||||
#include "app/tools/tool_box.h"
|
||||
#include "app/ui/color_bar.h"
|
||||
#include "app/ui/editor/editor.h"
|
||||
#include "app/ui_context.h"
|
||||
#include "doc/image.h"
|
||||
#include "doc/sprite.h"
|
||||
#include "ui/manager.h"
|
||||
#include "ui/system.h"
|
||||
|
||||
@ -65,6 +62,11 @@ void EyedropperCommand::pickSample(const Site& site,
|
||||
|
||||
app::Color picked = picker.color();
|
||||
|
||||
if (site.tilemapMode() == TilemapMode::Tiles) {
|
||||
color = app::Color::fromIndex(picked.getIndex());
|
||||
return;
|
||||
}
|
||||
|
||||
switch (channel) {
|
||||
case app::gen::EyedropperChannel::COLOR_ALPHA:
|
||||
color = picked;
|
||||
|
Loading…
x
Reference in New Issue
Block a user