Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Renan Borges committed Dec 21, 2020
0 parents commit 85573b7
Show file tree
Hide file tree
Showing 10 changed files with 1,036 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Files and directories created by pub
.dart_tool/
.packages

# Omit commiting pubspec.lock for library packages:
# https://dart.dev/guides/libraries/private-files#pubspeclock
pubspec.lock

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 1.0.0

- Initial version
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Renan Garcia Borges

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
265 changes: 265 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
# kandinsky-dart

Full ported version of [francisrstokes/kandinsky-js]

## Usage

A simple usage example:

```dart
import 'package:kandinsky/kandinsky.dart' as kandinsky;
main() {
var myDarkenHex = kandinsky.darkenHex(0.5, '#6699CC');
}
```

## API

### __rgb2hsl(rgbArray)__

> returns a hsl array
---
```dart
List<num> rgb2hsl(List<num> color)
```
---

### __hsl2rgb(hslArray)__

> returns an rgb array
---
```dart
List<num> hsl2rgb(List<num> color)
```
---

### __hex2rgb(hexString)__

> returns an rgb array
---
```dart
List<num> hex2rgb(String hex)
```
---

### __rgb2hex(rgbArray)__

> returns a hex string
---
```dart
String rgb2hex(List<num> rgb)
```
---

### __hex2hsl(hexString)__

> returns a hsl array
---
```dart
List<num> hex2hsl(String hex)
```
---

### __hsl2hex(hslArray)__

> returns a hex string
---
```dart
String hsl2hex(List<num> color)
```
---

### __darkenRgb(amount, rgbArray)__

> returns a darkened rgb array. `amount` is a value in the range `[0, 1]`
---
```dart
List<num> darkenRgb(num amount, List<num> rgb)
```
---

### __lightenRgb(amount, rgbArray)__

> returns a lightened rgb array. `amount` is a value in the range `[0, 1]`
---
```dart
List<num> lightenRgb(num amount, List<num> rgb)
```
---

### __darkenHsl(amount, hslArray)__

> returns a darkened hsl array. `amount` is a value in the range `[0, 1]`
---
```dart
List<num> darkenHsl(num amount, List<num> color)
```
---

### __lightenHsl(amount, hslArray)__

> returns a lightened hsl array. `amount` is a value in the range `[0, 1]`
---
```dart
List<num> lightenHsl(num amount, List<num> color)
```
---

### __lightenHex(amount, hexString)__

> returns a lightened hex string. `amount` is a value in the range `[0, 1]`
---
```dart
String lightenHex(num amount, String hex)
```
---

### __darkenHex(amount, hexString)__

> returns a darkened hex string. `amount` is a value in the range `[0, 1]`
---
```dart
String darkenHex(num amount, String hex)
```
---

### __lerp3(t, c1, c2)__

> returns a Vector3 colour somewhere between `c1` and `c2`. `t` is the "time" value in the range `[0, 1]`
---
```dart
List<num> lerp3(num t, List<num> color1, List<num> color2)
```
---

### __linearGradient(n, c1, c2)__

> returns an length `n` array of Vector3 colours. colours are evenly spaced between `c1` and `c2`.
---
```dart
List<List<num>> linearGradient(num n, List<num> color1, List<num> color2)
```
---

### __gradient(easeFn, n, c1, c2)__

> returns an length `n` array of Vector3 colours. colours are between `color1` and `color2`, and are spaced according to the easing function `easeFn`.
---
```dart
List<List<num>> gradient(Function ease, int n, List<num> color1, List<num> color2)
```
---

### __multiGradient(n, [col1, col3, ..., colN])__

> returns a length `n` array of Vector3 colours. colours are the ones formed from the `linearGradient(n/(numColours-1), col1, col2)` for all colours `col1, col2, ..., colN`
---
```dart
List<List<num>> multiGradient(num n, List<List<num>> colors)
```
---


### __rLinearGradient(n, c1, c2)__

> returns a rounded, length `n` array of Vector3 colours. colours are evenly spaced between `color1` and `color2`.
---
```dart
List<List<num>> rLinearGradient(num n, List<num> color1, List<num> color2)
```
---

### __rGradient(easeFn, n, c1, c2)__

> returns a rounded, length `n` array of Vector3 colours. colours are between `color1` and `color2`, and are spaced according to the easing function `easeFn`.
---
```dart
List<List<num>> rGradient(Function ease, num n, List<num> color1, List<num> color2)
```
---

### __rMultiGradient(n, [col1, col3, ..., colN])__

> returns a rounded, length `n` array of Vector3 colours. colours are the ones formed from the `linearGradient(n/(numColours-1), col1, col2)` for all colours `col1, col2, ..., colN`
---
```dart
List<List<num>> rMultiGradient(num n, List<List<num>> colors)
```
---

### __complimentHex(n, hexString)__

> returns an length `n` array of hex strings. The 0th color is the same as the input `hexString`, while the others are colours corresponding to an eve turn around the colour wheel. If `n` is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.
---
```dart
List<String> complimentHex(num n, String hex)
```
---

### __complimentHsl(n, hsl)__

> returns an length `n` array of hsl Vector3. The 0th color is the same as the input `hsl`, while the others are colours corresponding to an eve turn around the colour wheel. If `n` is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.
---
```dart
List<List<num>> complimentHsl(num n, List<num> color)
```
---

### __complimentRgb(n, rgb)__

> returns an length `n` array of rgb Vector3. The 0th color is the same as the input `rgb`, while the others are colours corresponding to an eve turn around the colour wheel. If `n` is 3 for example, the two other colours would represent a 1/3 and 2/3 rotation of the colour wheel.
---
```dart
List<List<num>> complimentRgb(num n, List<num> color)
```
---

### __rgb2css(alpha, rgb)__

> returns an rgba css string like `rgba(255, 255, 255, 1)` from the rgb color and alpha value
---
```dart
String rgb2css(num alpha, List<num> color)
```
---

### __hsl2css(alpha, hsl)__

> returns an hsl css string like `hsl(222, 50%, 75%, 0.6)` from the hsl color and alpha value
---
```dart
String hsl2css(num alpha, List<num> hsl)
```
---

## Features and bugs

Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/renanborgez/kandinsky-dart/issues
[francisrstokes/kandinsky-js]: https://github.com/francisrstokes/kandinsky-js
14 changes: 14 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
# linter:
# rules:
# - camel_case_types

analyzer:
# exclude:
# - path/to/excluded/files/**
15 changes: 15 additions & 0 deletions example/kandinsky_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'package:kandinsky/kandinsky.dart';

void main() {
var darkenHexColor = darkenHex(0.5, '#6699CC');
print('my darken hex color: ${darkenHexColor}');

var lightenHexColor = lightenHex(0.5, '#06795C');
print('my lighten hex color: ${lightenHexColor}');

var darkenRgbColor = darkenRgb(0.5, [180, 40, 20]);
print('my darken rgb color: ${darkenRgbColor}');

var lightenRgbColor = lightenRgb(0.5, [155, 90, 60]);
print('my lighten rgb color: ${lightenRgbColor}');
}
3 changes: 3 additions & 0 deletions lib/kandinsky.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
library kandinsky_dart;

export 'src/kandinsky_base.dart';
Loading

0 comments on commit 85573b7

Please sign in to comment.