diff --git a/docs/reference/json-map-format.rst b/docs/reference/json-map-format.rst index 88b51f9a2c..30248d99b6 100644 --- a/docs/reference/json-map-format.rst +++ b/docs/reference/json-map-format.rst @@ -96,6 +96,7 @@ Layer imagewidth, int, "Width of the image used by this layer. ``imagelayer`` only. (since 1.11.1)" layers, array, "Array of :ref:`layers `. ``group`` only." locked, bool, "Whether layer is locked in the editor (default: false). (since 1.8.2)" + mode, string, "The :ref:`blend mode ` to use when rendering the layer. (since 1.12)" name, string, "Name assigned to this layer" objects, array, "Array of :ref:`objects `. ``objectgroup`` only." offsetx, double, "Horizontal layer offset in pixels (default: 0)" @@ -168,6 +169,30 @@ Object Layer Example "y":0 } + +.. _json-blend-mode: + +Blend Mode +~~~~~~~~~~ + +The following values are supported for the ``mode`` property on +:ref:`json-layer`: + +- ``normal`` (default) +- ``add`` +- ``multiply`` +- ``screen`` +- ``overlay`` +- ``darken`` +- ``lighten`` +- ``color-dodge`` +- ``color-burn`` +- ``hard-light`` +- ``soft-light`` +- ``difference`` +- ``exclusion`` + + .. _json-chunk: Chunk @@ -738,6 +763,12 @@ A point on a polygon or a polyline, relative to the position of the object. Changelog --------- +Tiled 1.12 +~~~~~~~~~~ + +* Added ``mode`` property to :ref:`json-layer` to specify the blend mode to use + when rendering the layer. + Tiled 1.11.1 ~~~~~~~~~~~~ diff --git a/docs/reference/tmx-changelog.rst b/docs/reference/tmx-changelog.rst index bf6d88699a..066eb11309 100644 --- a/docs/reference/tmx-changelog.rst +++ b/docs/reference/tmx-changelog.rst @@ -4,6 +4,11 @@ TMX Changelog Below are described the changes/additions that were made to the :doc:`tmx-map-format` for recent versions of Tiled. +Tiled 1.12 +---------- + +- Added ``mode`` attribute on :ref:`tmx-layer` to specific its blend mode. + Tiled 1.10 ---------- diff --git a/docs/reference/tmx-map-format.rst b/docs/reference/tmx-map-format.rst index 1df38f5e57..f6b6269080 100644 --- a/docs/reference/tmx-map-format.rst +++ b/docs/reference/tmx-map-format.rst @@ -428,6 +428,10 @@ tiles. (since 0.14) - **parallaxx:** Horizontal :ref:`parallax factor ` for this layer. Defaults to 1. (since 1.5) - **parallaxy:** Vertical :ref:`parallax factor ` for this layer. Defaults to 1. (since 1.5) +- **mode:** The blend mode to use when rendering the layer. Valid values are + ``normal``, ``add``, ``multiply``, ``screen``, ``overlay``, ``darken``, ``lighten``, + ``color-dodge``, ``color-burn``, ``hard-light``, ``soft-light``, + ``difference`` and ``exclusion`` (since 1.12, defaults to ``normal``). Can contain at most one: :ref:`tmx-properties`, :ref:`tmx-data` diff --git a/docs/scripting-doc/index.d.ts b/docs/scripting-doc/index.d.ts index 251240f799..45e49208f0 100644 --- a/docs/scripting-doc/index.d.ts +++ b/docs/scripting-doc/index.d.ts @@ -2750,31 +2750,31 @@ declare class Tile extends TiledObject { * @since 1.12 */ declare enum BlendMode { - /** SVG equivalant: [src-over](https://www.w3.org/TR/SVGCompositing/#comp-op-src-over) */ + /** SVG equivalent: [src-over](https://www.w3.org/TR/SVGCompositing/#comp-op-src-over) */ Normal, - /** SVG equivalant: [plus](https://www.w3.org/TR/SVGCompositing/#comp-op-plus) */ + /** SVG equivalent: [plus](https://www.w3.org/TR/SVGCompositing/#comp-op-plus) */ Add, - /** SVG equivalant: [multiply](https://www.w3.org/TR/SVGCompositing/#comp-op-multiply) */ + /** SVG equivalent: [multiply](https://www.w3.org/TR/SVGCompositing/#comp-op-multiply) */ Multiply, - /** SVG equivalant: [screen](https://www.w3.org/TR/SVGCompositing/#comp-op-screen) */ + /** SVG equivalent: [screen](https://www.w3.org/TR/SVGCompositing/#comp-op-screen) */ Screen, - /** SVG equivalant: [overlay](https://www.w3.org/TR/SVGCompositing/#comp-op-overlay) */ + /** SVG equivalent: [overlay](https://www.w3.org/TR/SVGCompositing/#comp-op-overlay) */ Overlay, - /** SVG equivalant: [darken](https://www.w3.org/TR/SVGCompositing/#comp-op-darken) */ + /** SVG equivalent: [darken](https://www.w3.org/TR/SVGCompositing/#comp-op-darken) */ Darken, - /** SVG equivalant: [lighten](https://www.w3.org/TR/SVGCompositing/#comp-op-lighten) */ + /** SVG equivalent: [lighten](https://www.w3.org/TR/SVGCompositing/#comp-op-lighten) */ Lighten, - /** SVG equivalant: [color-dodge](https://www.w3.org/TR/SVGCompositing/#comp-op-color-dodge) */ + /** SVG equivalent: [color-dodge](https://www.w3.org/TR/SVGCompositing/#comp-op-color-dodge) */ ColorDodge, - /** SVG equivalant: [color-burn](https://www.w3.org/TR/SVGCompositing/#comp-op-color-burn) */ + /** SVG equivalent: [color-burn](https://www.w3.org/TR/SVGCompositing/#comp-op-color-burn) */ ColorBurn, - /** SVG equivalant: [hard-light](https://www.w3.org/TR/SVGCompositing/#comp-op-hard-light) */ + /** SVG equivalent: [hard-light](https://www.w3.org/TR/SVGCompositing/#comp-op-hard-light) */ HardLight, - /** SVG equivalant: [soft-light](https://www.w3.org/TR/SVGCompositing/#comp-op-soft-light) */ + /** SVG equivalent: [soft-light](https://www.w3.org/TR/SVGCompositing/#comp-op-soft-light) */ SoftLight, - /** SVG equivalant: [difference](https://www.w3.org/TR/SVGCompositing/#comp-op-difference) */ + /** SVG equivalent: [difference](https://www.w3.org/TR/SVGCompositing/#comp-op-difference) */ Difference, - /** SVG equivalant: [exclusion](https://www.w3.org/TR/SVGCompositing/#comp-op-exclusion) */ + /** SVG equivalent: [exclusion](https://www.w3.org/TR/SVGCompositing/#comp-op-exclusion) */ Exclusion } diff --git a/src/libtiled/layer.cpp b/src/libtiled/layer.cpp index 2108bd1132..8019ca1eb8 100644 --- a/src/libtiled/layer.cpp +++ b/src/libtiled/layer.cpp @@ -178,11 +178,6 @@ QPointF Layer::effectiveParallaxFactor() const return factor; } -QPainter::CompositionMode Layer::compositionMode() const -{ - return static_cast(mBlendMode); -} - /** * Returns whether this layer can be merged down onto the layer below. */ diff --git a/src/libtiled/layer.h b/src/libtiled/layer.h index 90412438eb..f2737bf9c3 100644 --- a/src/libtiled/layer.h +++ b/src/libtiled/layer.h @@ -323,6 +323,11 @@ inline void Layer::setBlendMode(BlendMode mode) mBlendMode = mode; } +inline QPainter::CompositionMode Layer::compositionMode() const +{ + return static_cast(mBlendMode); +} + /** * An iterator for iterating over the layers of a map, in the order in which diff --git a/src/tiled/changelayer.h b/src/tiled/changelayer.h index 92ddcb7d2f..dec86839b8 100644 --- a/src/tiled/changelayer.h +++ b/src/tiled/changelayer.h @@ -27,7 +27,6 @@ #include #include #include -#include namespace Tiled { diff --git a/src/tiled/propertieswidget.cpp b/src/tiled/propertieswidget.cpp index 6c5f059473..0474975fc1 100644 --- a/src/tiled/propertieswidget.cpp +++ b/src/tiled/propertieswidget.cpp @@ -197,7 +197,7 @@ template<> EnumData enumData() template<> EnumData enumData() { - const QStringList names { + return {{ QCoreApplication::translate("BlendMode", "Normal"), QCoreApplication::translate("BlendMode", "Add"), QCoreApplication::translate("BlendMode", "Multiply"), @@ -211,24 +211,7 @@ template<> EnumData enumData() QCoreApplication::translate("BlendMode", "Soft Light"), QCoreApplication::translate("BlendMode", "Difference"), QCoreApplication::translate("BlendMode", "Exclusion"), - }; - static const QList values { - static_cast(BlendMode::Normal), - static_cast(BlendMode::Add), - static_cast(BlendMode::Multiply), - static_cast(BlendMode::Screen), - static_cast(BlendMode::Overlay), - static_cast(BlendMode::Darken), - static_cast(BlendMode::Lighten), - static_cast(BlendMode::ColorDodge), - static_cast(BlendMode::ColorBurn), - static_cast(BlendMode::HardLight), - static_cast(BlendMode::SoftLight), - static_cast(BlendMode::Difference), - static_cast(BlendMode::Exclusion), - }; - - return { names, values }; + }}; }