aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-01-28 13:45:22 +0100
committerwout <wout@impinc.co.uk>2014-01-28 13:45:22 +0100
commitf6404a51bde49e6e747174db12782106d9411ded (patch)
treec9149327b95ebb73d82305f3eea68440844da3ef
parente080f28b609630a9767dad9a8483e1bf800b8550 (diff)
downloadsvg.js-f6404a51bde49e6e747174db12782106d9411ded.tar.gz
svg.js-f6404a51bde49e6e747174db12782106d9411ded.zip
Updated README
-rw-r--r--README.md35
1 files changed, 34 insertions, 1 deletions
diff --git a/README.md b/README.md
index 484856e..515c2eb 100644
--- a/README.md
+++ b/README.md
@@ -960,12 +960,45 @@ Note: the `x` and `y` positions are tested against the relative position of the
Svg.js has a dedicated color module handling different types of colors. Accepted values are:
- hex string; three based (e.g. #f06) or six based (e.g. #ff0066)
+```javascript
+var color = new SVG.Color('#f06')
+```
- rgb string; e.g. rgb(255, 0, 102)
+```javascript
+var color = new SVG.Color('rgb(255, 0, 102)')
+```
- rgb object; e.g. { r: 255, g: 0, b: 102 }
+```javascript
+var color = new SVG.Color({ r: 255, g: 0, b: 102 })
+```
Note that when working with objects is important to provide all three values every time.
-Colors in svg.js have their own class `SVG.Color` and can therefore be easily extended.
+The `SVG.Color` instance has a few methods of its own.
+
+### toHex()
+Get hex value:
+
+```javascript
+color.toHex() //-> returns '#ff0066'
+```
+
+### toRgb()
+Get rgb string value:
+
+```javascript
+color.toRgb() //-> returns 'rgb(255,0,102)'
+```
+
+### brightness()
+Get the brightness of a color:
+
+```javascript
+color.brightness() //-> returns 0.344
+```
+
+This is the perceived brighness where `0` is black and `1` is white.
+
## Animating elements