DynamicColor
DynamicColor copied to clipboard
Add methods to make images using a DynamicGradient
Hi Guillaume,
I'm not a big fan of the gradient image API because it introduces inconsistent APIs between iOS, tvOS, watchOS and macOS platforms. Moreover, your tests fail on travis.
DynamicColor is about the color manipulation, not visualisation. Either we create a sub-project with a DynamicGradientView that match the NSGradient macOS counterpart, or we create a new project.
However the isOpaque property is a great idea. You can pull those updates to start. I would just update the gradient one with something like that:
var isOpaque: Bool {
return colors.reduce(true) { $0.0 && $0.1.isOpaque }
}
Hi Yannick,
Tests work on Xcode, it's weird that they fail on travis ... One problem I had on Xcode is that ".png" were compress during compilation, to avoid that I changed their extension using ".ref", but I don't know if it works on travis.
I understand your point on APIs inconsistent between iOs and the other platforms, but I don't well know macOs counterpart, so I think I will not find the time to make it, sorry.
At the beginning of my pool request, I have a need: make a color using UIColor.init(patternImage: UIImage) to be able to put gardient in some backgrounds of my UIViews. Do we consider that colors with pattern are not real colors and haven't got their place in DynamicColor ?
I will make another request for isOpaque property.
Thanks for your time.
Codecov Report
Merging #38 into master will decrease coverage by
4.82%. The diff coverage is77.57%.
@@ Coverage Diff @@
## master #38 +/- ##
==========================================
- Coverage 100% 95.17% -4.83%
==========================================
Files 13 14 +1
Lines 390 497 +107
==========================================
+ Hits 390 473 +83
- Misses 0 24 +24
| Flag | Coverage Δ | |
|---|---|---|
| #ios | 95.17% <77.57%> (-4.83%) |
:arrow_down: |
| #osx | 75.65% <0%> (-20.76%) |
:arrow_down: |
| Impacted Files | Coverage Δ | |
|---|---|---|
| Sources/DynamicColor.swift | 100% <100%> (ø) |
:arrow_up: |
| Sources/CGFloat.swift | 62.5% <62.5%> (ø) |
|
| Sources/DynamicGradient.swift | 84.09% <78.35%> (-15.91%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update baac8bd...db4006c. Read the comment docs.
Travis uses Xcode to execute the test suite, so it should work in the same way. I should investigate that when I'll have time.
I think I'll create a sub-project with a DynamicGradientView with the same API as NSGradient and we will use your code.