Skip to content

Commit

Permalink
improving README
Browse files Browse the repository at this point in the history
  • Loading branch information
Reed Es committed Nov 20, 2021
1 parent 0477a0b commit f0e6bc0
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ _SwiftNiceScale_ is part of the [OpenAlloc](https://github.com/openalloc) family

## NiceScale

<img src="https://github.com/openalloc/SwiftNiceScale/blob/main/Images/naive_nice.png" width="1049" height="319"/>
<img src="https://github.com/openalloc/SwiftNiceScale/blob/main/Images/naive_nice.png" width="525" height="160"/>

```swift
let ns = NiceScale(105...543, desiredTicks: 5)
Expand Down Expand Up @@ -49,41 +49,45 @@ The initialization values are also available as properties:

Computed properties are lazy, meaning that they are only calculated when first needed.

The basic set of properties...

- `var range: NiceScale<T>.ValueRange` - The calculated ‘nice’ range, which should include the ‘raw’ range used to initialize this object.

- `var extent: T` - The distance between bounds of the range.

- `var hasNegativeRange: Bool` - If true, the range includes negative values.
- `var ticks: Int` - The number of ticks in the range. This may differ from the `desiredTicks` used to initialize the object.

- `var hasPositiveRange: Bool` - If true, the range includes positive values.
- `var tickInterval: T` - The distance between ticks in the range.

- `var negativeExtent: T` - If there’s a negative portion of range, the distance between its lower bound and 0. A non-negative value.
- `var tickValues: [T]` - The values for the ticks in the range.

- `var negativeExtentUnit: T?` - The negativeExtent, expressed as unit value in the range 0…1.
- `var tickFractionDigits: Int` - Number of fractional digits to show in tick label values.

- `var negativeRange: NiceScale<T>.ValueRange` - The portion of the range that is negative. 0…0 if none.
More specialized properties dealing with positive and negative portions of scale...

- `var positiveExtent: T` - If there’s a positive portion of range, the distance between its upper bound and 0. A non-negative value.
- `var hasNegativeRange: Bool` - If true, the range includes negative values.

- `var positiveExtentUnit: T?` - The positiveExtent, expressed as unit value in the range 0…1.
- `var hasPositiveRange: Bool` - If true, the range includes positive values.

- `var positiveRange: NiceScale<T>.ValueRange` - The portion of the range that is positive. 0…0 if none.
- `var negativeRange: NiceScale<T>.ValueRange` - The portion of the range that is negative. `0…0` if none.

- `var range: NiceScale<T>.ValueRange` - The calculated ‘nice’ range, which should include the ‘raw’ range used to initialize this object.
- `var positiveRange: NiceScale<T>.ValueRange` - The portion of the range that is positive. `0…0` if none.

- `var tickFractionDigits: Int` - Number of fractional digits to show in tick label values.
- `var negativeExtent: T` - If there’s a negative portion of range, the distance between its lower bound and 0. A non-negative value.

- `var tickInterval: T` - The distance between ticks in the range.
- `var positiveExtent: T` - If there’s a positive portion of range, the distance between its upper bound and 0. A non-negative value.

- `var tickValues: [T]` - The values for the ticks in the range.
- `var negativeExtentUnit: T?` - The negativeExtent, expressed as unit value in the range `0…1`.

- `var ticks: Int` - The number of ticks in the range. This may differ from the desiredTicks used to initialize the object.
- `var positiveExtentUnit: T?` - The positiveExtent, expressed as unit value in the range `0…1`.

#### Instance Methods

- `func scaleToUnit(T) -> T` - Scale value to 0…1 in the range.
- `func scaleToUnit(T) -> T` - Scale value to `0…1` in the range.

- `func scaleToUnitNegative(T) -> T` - Scale value to 0…1 in the negative portion of range, if any.
- `func scaleToUnitNegative(T) -> T` - Scale value to `0…1` in the negative portion of range, if any.

- `func scaleToUnitPositive(T) -> T` - Scale value to 0…1 in the positive portion of range, if any.
- `func scaleToUnitPositive(T) -> T` - Scale value to `0…1` in the positive portion of range, if any.

## See Also

Expand Down

0 comments on commit f0e6bc0

Please sign in to comment.