Skip to content

Commit

Permalink
- wrap code by lsc instead of wrapping manually so lsc generated
Browse files Browse the repository at this point in the history
   functions can also be wrapped.
 - add `ldcolor` and deprecate `ldColor`.
  • Loading branch information
zbryikt committed Mar 26, 2021
1 parent 0a95a97 commit 0268418
Show file tree
Hide file tree
Showing 10 changed files with 1,297 additions and 24 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## v0.0.3

- wrap code by lsc instead of wrapping manually so lsc generated functions can also be wrapped.
- add `ldcolor` and deprecate `ldColor`.


## v0.0.2

- upgrade livescript version
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ldColor
# ldcolor

lightweight JS color library, adopted from d3-color.

Expand All @@ -8,22 +8,22 @@ lightweight JS color library, adopted from d3-color.
construct a color object from some input, such as "#f00", "rgba(0,255,128,1)":

```
color = new ldColor(some-color-object-or-string);
color = new ldcolor(some-color-object-or-string);
```

the result color will be in either RGBA or HSLA. Or, convert to the target format directly:

```
ldColor.hex(0xff9922);
ldColor.hcl("#f92");
color = new ldColor("hsl(50%,50%,50%)");
ldcolor.hex(0xff9922);
ldcolor.hcl("#f92");
color = new ldcolor("hsl(50%,50%,50%)");
rgb = color.rgb();
```


## Spec

ldColor is an object with following fields:
ldcolor is an object with following fields:

* color space specific fields:
* RGB
Expand All @@ -48,11 +48,11 @@ ldColor is an object with following fields:
* Application Defined
TBD.

ldColor.js wont't write into offset, hex and mean fields.
ldcolor.js wont't write into offset, hex and mean fields.

## API

ldColor provides following API:
ldcolor provides following API:

- `same(color1, color2)` - check if `color1` equals to `color2`.
- `rgb(color)` - convert `color` to RGB space ( range: 0 ~ 255 ).
Expand All @@ -68,15 +68,15 @@ ldColor provides following API:
- `light(color, strength)` - make `color` lighter
- `darker(color, strength)` - maerk `color` darker

These API are also available as a member function in a `ldColor` object:
These API are also available as a member function in a `ldcolor` object:

(new ldColor('#fff')).darker!
(new ldcolor('#fff')).darker!


## Boundary Condition

- there is no RGB information in `transparent` string, thus it will return `rgba(NaN,NaN,NaN,0)`.
- colors with NaN or semi-transparent colors can't be converted to hex code. Thus, in order to use them safely, use `ldColor.web` instead of `ldColor.hex` to convert colors if transparency is needed.
- colors with NaN or semi-transparent colors can't be converted to hex code. Thus, in order to use them safely, use `ldcolor.web` instead of `ldcolor.hex` to convert colors if transparency is needed.

## LICENSE

Expand Down
20 changes: 10 additions & 10 deletions build
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#!/usr/bin/env bash

set -euo pipefail
rm -rf dist
mkdir -p dist
rm dist/*.js
echo "Transpiling ldColor.ls to ldColor.named.js..."
npx lsc -cpb --no-header src/ldColor.ls > dist/ldColor.named.js
echo "Transpiling ldcolor.ls to ldcolor.named.js..."
npx lsc -cp --no-header src/ldcolor.ls > dist/ldcolor.named.js

echo "Transpiling ldColor.ls without name list..."
cat src/ldColor.ls | grep -v "named = " | lsc -cbsp > dist/ldColor.js
echo "Uglify ldColor.named.js...."
npx uglifyjs dist/ldColor.named.js > dist/ldColor.named.min.js
echo "Uglify ldColor.js...."
npx uglifyjs dist/ldColor.js > dist/ldColor.min.js
echo "Transpiling ldcolor.ls without name list..."
cat src/ldcolor.ls | grep -v "named = " | lsc -csp --no-header > dist/ldcolor.js
echo "Uglify ldcolor.named.js...."
npx uglifyjs dist/ldcolor.named.js > dist/ldcolor.named.min.js
echo "Uglify ldcolor.js...."
npx uglifyjs dist/ldcolor.js > dist/ldcolor.min.js
Loading

0 comments on commit 0268418

Please sign in to comment.