From 7bd740f2575441ab63c56f6da8259108753133f4 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Sun, 28 Jul 2019 13:12:32 +0900 Subject: [PATCH] Added docs for rgba/hsla --- README.md | 17 ++++++++++------- desktop/sources/scripts/library.js | 22 ++++++++++------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 2f4746b..e87607b 100644 --- a/README.md +++ b/README.md @@ -62,13 +62,16 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i - `(gradient line ~colors 'black'])` Defines a gradient color. - `(guide shape color)` Draws a shape on the guide layer. - `(clear ~rect)` Clears a rect. +- `(rgba r g b ~a)` Defines a color r, g, b values are from 0 to 255, a from 0 to 1 +- `(hsla h s l ~a)` Defines a color h from 0 to 360, s and l from 0 to 100, a from 0 to 1 - `(frame)` Returns a rect of the frame. - `(center)` Returns a position of the center of the frame. - `(resize w h ~fit)` Resizes the canvas to target w and h, returns the rect. - `(rescale w h)` Rescales the canvas to target ratio of w and h, returns the rect. - `(crop rect)` Crop canvas to rect. - `(clone a b)` -- `(drag ~rect)` +- `(drag ~rect)` Drag a part of the canvas. +- `(view a b)` View a part of the canvas. - `(theme variable ~el)` - `(pixels rect fn ~q)` - `(saturation pixel q)` Change the saturation of pixels. @@ -88,13 +91,13 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i - `(min)` - `(max)` - `(ceil)` -- `(floor)` round down to the nearest integer. +- `(floor)` Round down to the nearest integer. - `(sin)` - `(cos)` -- `(log)` caclulates on the base of e. -- `(pow a b)` calculates a^b. -- `(sqrt)` calculate the square root. -- `(sq a)` calculate the square. +- `(log)` Caclulates on the base of e. +- `(pow a b)` Calculates a^b. +- `(sqrt)` Calculate the square root. +- `(sq a)` Calculate the square. - `(PI)` - `(TWO_PI)` - `(random ...args)` @@ -132,7 +135,7 @@ Ronin helpers are keywords that facilitates adding coordinates from the canvas i - `(js)` Javascript interop. - `(on event f)` Triggers on event. - `(test name a b)` -- `(benchmark fn)` logs time taken to execute a function. +- `(benchmark fn)` Logs time taken to execute a function. diff --git a/desktop/sources/scripts/library.js b/desktop/sources/scripts/library.js index 04d2f3b..12487b1 100644 --- a/desktop/sources/scripts/library.js +++ b/desktop/sources/scripts/library.js @@ -117,16 +117,14 @@ function Library (ronin) { // colors - this.rgba = (r, g, b, a) => { // defines a color r, g, b values are from 0 to 255, a from 0 to 1 - return "rgba("+r+","+g+","+b+","+a+")"; + this.rgba = (r, g, b, a = 1) => { // Defines a color r, g, b values are from 0 to 255, a from 0 to 1 + return `rgba(${r},${g},${b},${a})` } - - this.hsla = (h, s, l, a) => { // defines a color h from 0 to 360, s and l from 0 to 100, a from 0 to 1 - return "hsla("+h+","+s+"%,"+l+"%,"+a+")"; + this.hsla = (h, s, l, a = 1) => { // Defines a color h from 0 to 360, s and l from 0 to 100, a from 0 to 1 + return `hsla(${h},${s}%,${l}%,${a})` } - // Frame this.frame = () => { // Returns a rect of the frame. @@ -274,21 +272,21 @@ function Library (ronin) { this.ceil = Math.ceil - this.floor = Math.floor // round down to the nearest integer. + this.floor = Math.floor // Round down to the nearest integer. this.sin = Math.sin this.cos = Math.cos - this.log = Math.log // caclulates on the base of e. + this.log = Math.log // Caclulates on the base of e. - this.pow = (a, b) => { // calculates a^b. + this.pow = (a, b) => { // Calculates a^b. return Math.pow(a, b) } - this.sqrt = Math.sqrt // calculate the square root. + this.sqrt = Math.sqrt // Calculate the square root. - this.sq = (a) => { // calculate the square. + this.sq = (a) => { // Calculate the square. return a * a } @@ -524,7 +522,7 @@ function Library (ronin) { return a === b } - this.benchmark = async (fn) => { // logs time taken to execute a function. + this.benchmark = async (fn) => { // Logs time taken to execute a function. const start = Date.now() const result = await fn() console.log(`time taken: ${Date.now() - start}ms`)