ChartsOrg / ChartsOrg/Charts

PROPOSAL: Add new Gradient type

Open
#3,428 16 comments 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
28k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

## Motivation

There are many feature requests involving gradients, in addition to the currently existing gradient related features. PRs have been submitted with multiple implementations and concepts as to how to describe a gradient. In an effort to standardize our gradient support, we would like to introduce a new `Gradient` data type.

credit: @larryonoff

## Impletmentation

In a pure Swift implementation, this would be:
```
struct LinearGradient: NSObject
{
let start: CGPoint
let end: CGPoint
let positions: [CGFloat]
let colors: [UIColor]
}
```

However, as we are still currently supporting objc, this is required:
```
final class LinearGradient: NSObject, NSCopying
{
let start: CGPoint
let end: CGPoint
let positions: [CGFloat]
let colors: [UIColor]
}
```

To simplify creation of gradients, we should introduce convenience initializers for standard gradient positions and default colour options.

It may make sense to introduce additional gradient types (radial, etc), however further discussion should be had as to whether it is necessary. If we are going to do so, we should do it the Swift way, by defining a `Gradient` protocol instead of subclassing to make the eventual transition away from objective-c easier.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.