carson-katri / carson-katri/swift-css

Gradient stop percentage

Open
#1 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
15
Forks
4
PR merge metrics
No merged PRs in 30d

Description

A gradients stops can have a percentage to specify where the color starts.

For example, these are the same:
```css
linear-gradient(red, orange, yellow, green, blue);
linear-gradient(red 0%, orange 25%, yellow 50%, green 75%, blue 100%);
```
Currently the gradient cases on Color only receive [Color] as stops.

I think there should be a Color case that looks something like:

```swift
case linearGradient(_ direction: LinearGradient.Direction, _ stops: [(Color, Int)])
```
or:
```swift
case linearGradient(_ direction: LinearGradient.Direction, _ stops: [ColorStop])

// ...

public struct ColorStop: CustomStringConvertible {
let color: Color
let positions: [Int]

public var description: String {
color.description + positions.map { String($0) + "%" } .joined(separator: " ")
}

public static func color(_ color: Color, at percentages: Int...) -> ColorStop {
return ColorStop(color: color, positions: percentages)
}
}
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.