Skip to content

Commit

Permalink
Some final blend mode tweaks
Browse files Browse the repository at this point in the history
* Corrected spelling in JS API docs
* Updated TMX and JSON format docs
* Small code cleanups
  • Loading branch information
bjorn committed Jan 20, 2025
1 parent a084eef commit 3f6df22
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 38 deletions.
31 changes: 31 additions & 0 deletions docs/reference/json-map-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 <json-layer>`. ``group`` only."
locked, bool, "Whether layer is locked in the editor (default: false). (since 1.8.2)"
mode, string, "The :ref:`blend mode <json-blend-mode>` to use when rendering the layer. (since 1.12)"
name, string, "Name assigned to this layer"
objects, array, "Array of :ref:`objects <json-object>`. ``objectgroup`` only."
offsetx, double, "Horizontal layer offset in pixels (default: 0)"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
~~~~~~~~~~~~

Expand Down
5 changes: 5 additions & 0 deletions docs/reference/tmx-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
----------

Expand Down
4 changes: 4 additions & 0 deletions docs/reference/tmx-map-format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ tiles.
(since 0.14)
- **parallaxx:** Horizontal :ref:`parallax factor <parallax-factor>` for this layer. Defaults to 1. (since 1.5)
- **parallaxy:** Vertical :ref:`parallax factor <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`

Expand Down
26 changes: 13 additions & 13 deletions docs/scripting-doc/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
5 changes: 0 additions & 5 deletions src/libtiled/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,6 @@ QPointF Layer::effectiveParallaxFactor() const
return factor;
}

QPainter::CompositionMode Layer::compositionMode() const
{
return static_cast<QPainter::CompositionMode>(mBlendMode);
}

/**
* Returns whether this layer can be merged down onto the layer below.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/libtiled/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,11 @@ inline void Layer::setBlendMode(BlendMode mode)
mBlendMode = mode;
}

inline QPainter::CompositionMode Layer::compositionMode() const
{
return static_cast<QPainter::CompositionMode>(mBlendMode);
}


/**
* An iterator for iterating over the layers of a map, in the order in which
Expand Down
1 change: 0 additions & 1 deletion src/tiled/changelayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <QPointF>
#include <QSize>
#include <QColor>
#include <QPainter>

namespace Tiled {

Expand Down
21 changes: 2 additions & 19 deletions src/tiled/propertieswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ template<> EnumData enumData<WangSet::Type>()

template<> EnumData enumData<BlendMode>()
{
const QStringList names {
return {{
QCoreApplication::translate("BlendMode", "Normal"),
QCoreApplication::translate("BlendMode", "Add"),
QCoreApplication::translate("BlendMode", "Multiply"),
Expand All @@ -211,24 +211,7 @@ template<> EnumData enumData<BlendMode>()
QCoreApplication::translate("BlendMode", "Soft Light"),
QCoreApplication::translate("BlendMode", "Difference"),
QCoreApplication::translate("BlendMode", "Exclusion"),
};
static const QList<int> values {
static_cast<int>(BlendMode::Normal),
static_cast<int>(BlendMode::Add),
static_cast<int>(BlendMode::Multiply),
static_cast<int>(BlendMode::Screen),
static_cast<int>(BlendMode::Overlay),
static_cast<int>(BlendMode::Darken),
static_cast<int>(BlendMode::Lighten),
static_cast<int>(BlendMode::ColorDodge),
static_cast<int>(BlendMode::ColorBurn),
static_cast<int>(BlendMode::HardLight),
static_cast<int>(BlendMode::SoftLight),
static_cast<int>(BlendMode::Difference),
static_cast<int>(BlendMode::Exclusion),
};

return { names, values };
}};
}


Expand Down

0 comments on commit 3f6df22

Please sign in to comment.