|
| 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 |
0 commit comments