[aseprite] 74/308: Include opacity and blend mode for each layer in JSON output
Tobias Hansen
thansen at moszumanska.debian.org
Tue Mar 8 02:44:54 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit e63dea61fd2f3ffedfd488c8b8d4caf7db83fdbf
Author: David Capello <davidcapello at gmail.com>
Date: Wed Dec 9 11:00:57 2015 -0300
Include opacity and blend mode for each layer in JSON output
---
src/app/document_exporter.cpp | 7 ++++++-
src/doc/CMakeLists.txt | 1 +
src/doc/blend_mode.cpp | 38 ++++++++++++++++++++++++++++++++++++++
src/doc/blend_mode.h | 4 ++++
4 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/src/app/document_exporter.cpp b/src/app/document_exporter.cpp
index d1544be..2c4ee61 100644
--- a/src/app/document_exporter.cpp
+++ b/src/app/document_exporter.cpp
@@ -729,7 +729,12 @@ void DocumentExporter::createDataFile(const Samples& samples, std::ostream& os,
firstLayer = false;
else
os << ",";
- os << "\n { \"name\": \"" << escape_for_json(layer->name()) << "\" }";
+ os << "\n { \"name\": \"" << escape_for_json(layer->name()) << "\"";
+ if (LayerImage* layerImg = dynamic_cast<LayerImage*>(layer)) {
+ os << ", \"opacity\": " << layerImg->opacity()
+ << ", \"blendMode\": \"" << blend_mode_to_string(layerImg->blendMode()) << "\"";
+ }
+ os << " }";
}
}
os << "\n ]";
diff --git a/src/doc/CMakeLists.txt b/src/doc/CMakeLists.txt
index 0d3bf8e..44e46cb 100644
--- a/src/doc/CMakeLists.txt
+++ b/src/doc/CMakeLists.txt
@@ -13,6 +13,7 @@ add_library(doc-lib
algorithm/shrink_bounds.cpp
anidir.cpp
blend_funcs.cpp
+ blend_mode.cpp
brush.cpp
cel.cpp
cel_data.cpp
diff --git a/src/doc/blend_mode.cpp b/src/doc/blend_mode.cpp
new file mode 100644
index 0000000..c35f735
--- /dev/null
+++ b/src/doc/blend_mode.cpp
@@ -0,0 +1,38 @@
+// Aseprite Document Library
+// Copyright (c) 2001-2015 David Capello
+//
+// This file is released under the terms of the MIT license.
+// Read LICENSE.txt for more information.
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "doc/blend_mode.h"
+
+namespace doc {
+
+std::string blend_mode_to_string(BlendMode blendMode)
+{
+ switch (blendMode) {
+ case BlendMode::NORMAL: return "normal";
+ case BlendMode::MULTIPLY: return "multiply";
+ case BlendMode::SCREEN: return "screen";
+ case BlendMode::OVERLAY: return "overlay";
+ case BlendMode::DARKEN: return "darken";
+ case BlendMode::LIGHTEN: return "lighten";
+ case BlendMode::COLOR_DODGE: return "color_dodge";
+ case BlendMode::COLOR_BURN: return "color_burn";
+ case BlendMode::HARD_LIGHT: return "hard_light";
+ case BlendMode::SOFT_LIGHT: return "soft_light";
+ case BlendMode::DIFFERENCE: return "difference";
+ case BlendMode::EXCLUSION: return "exclusion";
+ case BlendMode::HSL_HUE: return "hsl_hue";
+ case BlendMode::HSL_SATURATION: return "hsl_saturation";
+ case BlendMode::HSL_COLOR: return "hsl_color";
+ case BlendMode::HSL_LUMINOSITY: return "hsl_luminosity";
+ default: return "unknown";
+ }
+}
+
+} // namespace doc
diff --git a/src/doc/blend_mode.h b/src/doc/blend_mode.h
index 497bb0c..f26e04c 100644
--- a/src/doc/blend_mode.h
+++ b/src/doc/blend_mode.h
@@ -8,6 +8,8 @@
#define DOC_BLEND_MODE_H_INCLUDED
#pragma once
+#include <string>
+
namespace doc {
enum class BlendMode {
@@ -38,6 +40,8 @@ namespace doc {
HSL_LUMINOSITY = 15
};
+ std::string blend_mode_to_string(BlendMode blendMode);
+
} // namespace doc
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list