mousebird-consulting-inc / WhirlyGlobe

WhirlyGlobe Development
Other
830 stars 255 forks source link

Filled vector becomes white for some colours #1530

Closed serhii-londar closed 2 years ago

serhii-londar commented 2 years ago

Hi, I've faced the issue with setting fill colour for vectors with the alpha component. For some colours it becomes white. I'm using WhirlyGlobe 2.6.7 . The code for adding vectors is following:

- (NSArray *)addFilledVector:(MaplyVectorObject *)vecObj
                       viewC:(MaplyBaseViewController *)baseViewC {

    [vecObj subdivideToGlobe:0.0001];

    NSDictionary *dict = @{
        kMaplyColor: [UIColor colorWithRed:0.929412 green:0.305882 blue:0.317647 alpha:0.1],
        kMaplyFilled: @YES,
        kMaplyEnable: @YES,
        kMaplyFade: @0,
        kMaplyDrawPriority: @(kMaplyVectorDrawPriorityDefault + 1),
        kMaplyVecCentered: @YES,
        kMaplyWideVecEdgeFalloff: @(1.0),
        kMaplyWideVecJoinType: kMaplyWideVecMiterJoin,
        kMaplyWideVecCoordType: kMaplyWideVecCoordTypeScreen,
        // More than 10 degrees need a bevel join
        kMaplyWideVecMiterLimit: @(1.01),
        kMaplyVecWidth: @(5)
    };

    MaplyComponentObject *obj1 = [baseViewC addVectors:@[vecObj] desc:dict mode:MaplyThreadCurrent];
    return @[obj1];
}

When I set kMaplyColor: [UIColor colorWithRed:1 green:0 blue:0 alpha:0.1], it works fine and result is the following(pay attention to circle): Simulator Screen Shot - iPad Air (4th generation) - 2022-04-01 at 16 18 20

But, when I set kMaplyColor: [UIColor colorWithRed:0.929412 green:0.305882 blue:0.317647 alpha:0.1], it fill vector with white color(pay attention to circle): Simulator Screen Shot - iPad Air (4th generation) - 2022-04-01 at 16 18 36

Can you help me with that issue?

mousebird commented 2 years ago

You'll want to multiply the alpha through the rest of the color.

serhii-londar commented 2 years ago

You'll want to multiply the alpha through the rest of the color.

@mousebird Sorry, but I didn't get it.

mousebird commented 2 years ago

Multiply the rest of your color values by 0.1

serhii-londar commented 2 years ago

Ok, will try. Thank you!