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

Commit 85573b7

Browse files
author
Renan Borges
committed
Initial commit
0 parents  commit 85573b7

10 files changed

+1036
-0
lines changed

.gitignore

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Files and directories created by pub
2+
.dart_tool/
3+
.packages
4+
5+
# Omit commiting pubspec.lock for library packages:
6+
# https://dart.dev/guides/libraries/private-files#pubspeclock
7+
pubspec.lock
8+
9+
# Conventional directory for build outputs
10+
build/
11+
12+
# Directory created by dartdoc
13+
doc/api/

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## 1.0.0
2+
3+
- Initial version

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Renan Garcia Borges
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+265
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
# kandinsky-dart
2+
3+
Full ported version of [francisrstokes/kandinsky-js]
4+
5+
## Usage
6+
7+
A simple usage example:
8+
9+
```dart
10+
import 'package:kandinsky/kandinsky.dart' as kandinsky;
11+
12+
main() {
13+
var myDarkenHex = kandinsky.darkenHex(0.5, '#6699CC');
14+
}
15+
```
16+
17+
## API
18+
19+
### __rgb2hsl(rgbArray)__
20+
21+
> returns a hsl array
22+
23+
---
24+
```dart
25+
List<num> rgb2hsl(List<num> color)
26+
```
27+
---
28+
29+
### __hsl2rgb(hslArray)__
30+
31+
> returns an rgb array
32+
33+
---
34+
```dart
35+
List<num> hsl2rgb(List<num> color)
36+
```
37+
---
38+
39+
### __hex2rgb(hexString)__
40+
41+
> returns an rgb array
42+
43+
---
44+
```dart
45+
List<num> hex2rgb(String hex)
46+
```
47+
---
48+
49+
### __rgb2hex(rgbArray)__
50+
51+
> returns a hex string
52+
53+
---
54+
```dart
55+
String rgb2hex(List<num> rgb)
56+
```
57+
---
58+
59+
### __hex2hsl(hexString)__
60+
61+
> returns a hsl array
62+
63+
---
64+
```dart
65+
List<num> hex2hsl(String hex)
66+
```
67+
---
68+
69+
### __hsl2hex(hslArray)__
70+
71+
> returns a hex string
72+
73+
---
74+
```dart
75+
String hsl2hex(List<num> color)
76+
```
77+
---
78+
79+
### __darkenRgb(amount, rgbArray)__
80+
81+
> returns a darkened rgb array. `amount` is a value in the range `[0, 1]`
82+
83+
---
84+
```dart
85+
List<num> darkenRgb(num amount, List<num> rgb)
86+
```
87+
---
88+
89+
### __lightenRgb(amount, rgbArray)__
90+
91+
> returns a lightened rgb array. `amount` is a value in the range `[0, 1]`
92+
93+
---
94+
```dart
95+
List<num> lightenRgb(num amount, List<num> rgb)
96+
```
97+
---
98+
99+
### __darkenHsl(amount, hslArray)__
100+
101+
> returns a darkened hsl array. `amount` is a value in the range `[0, 1]`
102+
103+
---
104+
```dart
105+
List<num> darkenHsl(num amount, List<num> color)
106+
```
107+
---
108+
109+
### __lightenHsl(amount, hslArray)__
110+
111+
> returns a lightened hsl array. `amount` is a value in the range `[0, 1]`
112+
113+
---
114+
```dart
115+
List<num> lightenHsl(num amount, List<num> color)
116+
```
117+
---
118+
119+
### __lightenHex(amount, hexString)__
120+
121+
> returns a lightened hex string. `amount` is a value in the range `[0, 1]`
122+
123+
---
124+
```dart
125+
String lightenHex(num amount, String hex)
126+
```
127+
---
128+
129+
### __darkenHex(amount, hexString)__
130+
131+
> returns a darkened hex string. `amount` is a value in the range `[0, 1]`
132+
133+
---
134+
```dart
135+
String darkenHex(num amount, String hex)
136+
```
137+
---
138+
139+
### __lerp3(t, c1, c2)__
140+
141+
> returns a Vector3 colour somewhere between `c1` and `c2`. `t` is the "time" value in the range `[0, 1]`
142+
143+
---
144+
```dart
145+
List<num> lerp3(num t, List<num> color1, List<num> color2)
146+
```
147+
---
148+
149+
### __linearGradient(n, c1, c2)__
150+
151+
> returns an length `n` array of Vector3 colours. colours are evenly spaced between `c1` and `c2`.
152+
153+
---
154+
```dart
155+
List<List<num>> linearGradient(num n, List<num> color1, List<num> color2)
156+
```
157+
---
158+
159+
### __gradient(easeFn, n, c1, c2)__
160+
161+
> returns an length `n` array of Vector3 colours. colours are between `color1` and `color2`, and are spaced according to the easing function `easeFn`.
162+
163+
---
164+
```dart
165+
List<List<num>> gradient(Function ease, int n, List<num> color1, List<num> color2)
166+
```
167+
---
168+
169+
### __multiGradient(n, [col1, col3, ..., colN])__
170+
171+
> 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`
172+
173+
---
174+
```dart
175+
List<List<num>> multiGradient(num n, List<List<num>> colors)
176+
```
177+
---
178+
179+
180+
### __rLinearGradient(n, c1, c2)__
181+
182+
> returns a rounded, length `n` array of Vector3 colours. colours are evenly spaced between `color1` and `color2`.
183+
184+
---
185+
```dart
186+
List<List<num>> rLinearGradient(num n, List<num> color1, List<num> color2)
187+
```
188+
---
189+
190+
### __rGradient(easeFn, n, c1, c2)__
191+
192+
> returns a rounded, length `n` array of Vector3 colours. colours are between `color1` and `color2`, and are spaced according to the easing function `easeFn`.
193+
194+
---
195+
```dart
196+
List<List<num>> rGradient(Function ease, num n, List<num> color1, List<num> color2)
197+
```
198+
---
199+
200+
### __rMultiGradient(n, [col1, col3, ..., colN])__
201+
202+
> 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`
203+
204+
---
205+
```dart
206+
List<List<num>> rMultiGradient(num n, List<List<num>> colors)
207+
```
208+
---
209+
210+
### __complimentHex(n, hexString)__
211+
212+
> 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.
213+
214+
---
215+
```dart
216+
List<String> complimentHex(num n, String hex)
217+
```
218+
---
219+
220+
### __complimentHsl(n, hsl)__
221+
222+
> 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.
223+
224+
---
225+
```dart
226+
List<List<num>> complimentHsl(num n, List<num> color)
227+
```
228+
---
229+
230+
### __complimentRgb(n, rgb)__
231+
232+
> 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.
233+
234+
---
235+
```dart
236+
List<List<num>> complimentRgb(num n, List<num> color)
237+
```
238+
---
239+
240+
### __rgb2css(alpha, rgb)__
241+
242+
> returns an rgba css string like `rgba(255, 255, 255, 1)` from the rgb color and alpha value
243+
244+
---
245+
```dart
246+
String rgb2css(num alpha, List<num> color)
247+
```
248+
---
249+
250+
### __hsl2css(alpha, hsl)__
251+
252+
> returns an hsl css string like `hsl(222, 50%, 75%, 0.6)` from the hsl color and alpha value
253+
254+
---
255+
```dart
256+
String hsl2css(num alpha, List<num> hsl)
257+
```
258+
---
259+
260+
## Features and bugs
261+
262+
Please file feature requests and bugs at the [issue tracker][tracker].
263+
264+
[tracker]: https://github.com/renanborgez/kandinsky-dart/issues
265+
[francisrstokes/kandinsky-js]: https://github.com/francisrstokes/kandinsky-js

analysis_options.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Defines a default set of lint rules enforced for
2+
# projects at Google. For details and rationale,
3+
# see https://github.com/dart-lang/pedantic#enabled-lints.
4+
include: package:pedantic/analysis_options.yaml
5+
6+
# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
7+
# Uncomment to specify additional rules.
8+
# linter:
9+
# rules:
10+
# - camel_case_types
11+
12+
analyzer:
13+
# exclude:
14+
# - path/to/excluded/files/**

example/kandinsky_example.dart

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:kandinsky/kandinsky.dart';
2+
3+
void main() {
4+
var darkenHexColor = darkenHex(0.5, '#6699CC');
5+
print('my darken hex color: ${darkenHexColor}');
6+
7+
var lightenHexColor = lightenHex(0.5, '#06795C');
8+
print('my lighten hex color: ${lightenHexColor}');
9+
10+
var darkenRgbColor = darkenRgb(0.5, [180, 40, 20]);
11+
print('my darken rgb color: ${darkenRgbColor}');
12+
13+
var lightenRgbColor = lightenRgb(0.5, [155, 90, 60]);
14+
print('my lighten rgb color: ${lightenRgbColor}');
15+
}

lib/kandinsky.dart

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
library kandinsky_dart;
2+
3+
export 'src/kandinsky_base.dart';

0 commit comments

Comments
 (0)