thorvg icon indicating copy to clipboard operation
thorvg copied to clipboard

lottie: gradient slot issue

Open theashraf opened this issue 1 year ago • 3 comments

gradient-fill.json

The provided Lottie file contains the following slots:

"slots": {
  "gradient_fill": {
    "p": {
      "a": 0,
      "k": [0, 0.1, 0.1, 0.2, 1, 1, 0.1, 0.2, 0.1, 1]
    }
  }
}

I expected the gradient to render as shown in this image: Expected gradient

but, for some reason, it’s not being rendered correctly, as shown here: Incorrect gradient

theashraf avatar Oct 01 '24 04:10 theashraf

CleanShot 2024-10-01 at 13 58 06@2x

By replacing original gradient array, it renders what we expect. Something happens in overriding makes colorStops different.

I'll look into this. Thanks for reporting.

tinyjin avatar Oct 01 '24 04:10 tinyjin

@theashraf I have a question regarding to overriden colorStop value.

Let's say original gradient has 2 colorStops in one sid before overriding. Is new colorStop from slot same length as well?

Or any possible situation that different length of gradient will come and be overriden?

tinyjin avatar Oct 01 '24 11:10 tinyjin

https://github.com/lottie/lottie-spec/issues/105

mgrudzinska avatar Oct 15 '24 12:10 mgrudzinska

@tinyjin @mgrudzinska Even our sample don't have value count, shouldn't our Lottie Extension sample suggest like this?

image

image

hermet avatar Oct 22 '24 08:10 hermet

yes, slotsample.json and test case lottie slot should be updated

mgrudzinska avatar Oct 22 '24 08:10 mgrudzinska

agree, the "p" value would suggest how many colors stops will be changed

tinyjin avatar Oct 22 '24 08:10 tinyjin

@theashraf Please review the form change carefully, leave any feedback. This may break dotlottie player compatibility. Otherwise, the fix will be in the next release (v0.15.4).

slot data to override:

{
    "gradient_fill": {
        "p": {
            "p": 2,      // 2 color stop count
            "k": {
                "k": [
                    0,
                    0.1,
                    0.1,
                    0.2,
                    1,
                    1,
                    0.1,
                    0.2,
                    0,
                    0,
                    1,
                    1
                ]
            }
        }
    }
}

slot data target:

"g": {
    "p": 9,   //9 color stop count
    "k": {
        "a": 0,
        "k": [
            0,
            0.514,
            0.373,
            0.984,
            0.141,
            0.478,
            0.412,
            0.984,
            0.283,
            0.443,
            0.451,
            0.984,
            0.379,
            0.408,
            0.49,
            0.984,
            0.475,
            0.373,
            0.529,
            0.984,
            0.606,
            0.278,
            0.647,
            0.925,
            0.737,
            0.184,
            0.765,
            0.867,
            0.868,
            0.092,
            0.882,
            0.808,
            1,
            0,
            1,
            0.749
        ]
    },
    "sid": "gradient_fill"
}

hermet avatar Nov 01 '24 15:11 hermet

@hermet I need to review this with lottie-web, let me come back to you soon. I wonder if animated gradient slots is also supported ?

theashraf avatar Nov 01 '24 15:11 theashraf

@theashraf yes, it should.

hermet avatar Nov 01 '24 15:11 hermet