Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Fixing issue where UIColor with alpha < 1 was being rendered incorrectly #266

Merged
merged 10 commits into from
Apr 21, 2020

Conversation

nishant-karajgikar
Copy link
Contributor

@nishant-karajgikar nishant-karajgikar commented Apr 9, 2020

<changelog> Fixed an issue where properties such as MGLFillStyleLayer.fillColor and MGLLineStyleLayer.lineColor misinterpreted non-opaque UIColors.</changelog>

Fixes #125

This issue was being caused due to an incorrect assumption that the R, G, B color components needed to be multiplied with the alpha value. The changes fix this by using the newly exposed mgl_colorForPremultipliedValue category method on UIColor.

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix! A suggestion for the iOS and macOS changelogs:

  • Fixed an issue where properties such as MGLFillStyleLayer.fillColor and MGLLineStyleLayer.lineColor misinterpreted non-opaque UIColors.

platform/ios/src/UIColor+MGLAdditions.mm Show resolved Hide resolved
@knov knov added this to the release-water milestone Apr 10, 2020
@nishant-karajgikar nishant-karajgikar self-assigned this Apr 13, 2020
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the comments below, please rebase onto master and remove the mbgl submodule bump, which I don’t think is necessary here.

platform/darwin/test/MGLExpressionTests.mm Show resolved Hide resolved
platform/darwin/test/MGLExpressionTests.mm Show resolved Hide resolved
@nishant-karajgikar
Copy link
Contributor Author

please rebase onto master and remove the mbgl submodule bump

Will do, it's weird that there's a change in the mbgl submodule. I didn't make any changes to that.


NSArray *jsonExpression = @[@"rgba", @255.0, @239.0, @213.0, @0.5];
NSExpression *papayawhipExpression = [NSExpression expressionWithMGLJSONObject:jsonExpression];
MGLColor *papayaWhipColor = [papayawhipExpression expressionValueWithObject:nil context:nil];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, papayawhipExpression is a constant value expression, so this is equivalent to getting its constantValue.

platform/darwin/test/MGLExpressionTests.mm Outdated Show resolved Hide resolved
platform/darwin/test/MGLExpressionTests.mm Outdated Show resolved Hide resolved
Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a changelog nitpick that we can fold into the prerelease PR if it’s more convenient.

platform/ios/CHANGELOG.md Outdated Show resolved Hide resolved
platform/macos/CHANGELOG.md Outdated Show resolved Hide resolved
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UIColor with alpha < 1 is rendered incorrectly
4 participants