Skip to content

Commit

Permalink
Memoize convertColor to add speed.
Browse files Browse the repository at this point in the history
Also, refactor util/index.js to have color utilities in their own file
and other common utilities in util/common.js.

Named CSS colors are now taken from the npm color-name package instead
of including them ourselves.
  • Loading branch information
manthey committed Oct 17, 2018
1 parent 068882e commit bb7b190
Show file tree
Hide file tree
Showing 9 changed files with 1,758 additions and 1,841 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
### Features
- Feature selection API is now enabled automatically if any event handlers are bounds to the feature (#921)

### Improvements
- `convertColor` is memoized to speed up repeated calls (#936)
- All features have a `featureType` property (#931)

### Changes
- Removed the dependency on the vgl module for the `object` and `timestamp` classes (#918)
- CSS color names are obtained from an npm package rather than being defined in the util module (#936)

## Version 0.18.1

Expand Down
15 changes: 11 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"url": "https://github.com/OpenGeoscience/geojs"
},
"dependencies": {
"color-name": "^1.1.4",
"earcut": "^2.1.1",
"gl-mat3": "^1.0.0",
"gl-mat4": "^1.1.4",
Expand Down
3 changes: 3 additions & 0 deletions src/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ var feature = function (arg) {
* A uniform getter that always returns a function even for constant styles.
* This can also return all defined styles as functions in a single object.
*
* If the style `key` is a color, the returned function will also coerce
* the result to be a {@link geo.geoColorObject}.
*
* @function style_DOT_get
* @memberof geo.feature
* @instance
Expand Down
50 changes: 0 additions & 50 deletions src/typedef.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,56 +211,6 @@
* when significant movement first occurred.
*/

/**
* A color value. Although opacity can be specified, it is not always used.
* When a string is specified, any of the following forms can be used:
* - CSS color name
* - `#rrggbb` The color specified in hexadecmial with each channel on a
* scale between 0 and 255 (`ff`). Case insensitive.
* - `#rrggbbaa` The color and opacity specified in hexadecmial with each
* channel on a scale between 0 and 255 (`ff`). Case insensitive.
* - `#rgb` The color specified in hexadecmial with each channel on a scale
* between 0 and 15 (`f`). Case insensitive.
* - `#rgba` The color and opacity specified in hexadecmial with each channel
* on a scale between 0 and 15 (`f`). Case insensitive.
* - `rgb(R, G, B)`, `rgb(R, G, B, A)`, `rgba(R, G, B)`, `rgba(R, G, B, A)`
* The color with the values of each color channel specified as numeric
* values between 0 and 255 or as percent (between 0 and 100) if a percent
* `%` follows the number. The alpha (opacity) channel is optional and can
* either be a number between 0 and 1 or a percent. White space may appear
* before and after numbers, and between the number and a percent symbol.
* Commas are not required. A slash may be used as a separator before the
* alpha value instead of a comma. The numbers conform to the CSS number
* specification, and can be signed floating-point values, possibly with
* exponents.
* - `hsl(H, S, L)`, `hsl(H, S, L, A)`, `hsla(H, S, L)`, `hsla(H, S, L, A)`
* Hue, saturation, and lightness with optional alpha (opacity). Hue is a
* number between 0 and 360 and is interpretted as degrees unless an angle
* unit is specified. CSS units of `deg`, `grad`, `rad`, and `turn` are
* supported. Saturation and lightness are percentages between 0 and 100
* and *must* be followed by a percent `%` symbol. The alpha (opacity)
* channel is optional and is specified as with `rgba(R, G, B, A)`.
* - `transparent` Black with 0 opacity.
*
* See {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color_value} for
* more details on CSS color values.
*
* @typedef geo.geoColor
* @type {geo.geoColorObject|string}
*/

/**
* A color value represented as an object. Although opacity can be specified,
* it is not always used.
*
* @typedef {object} geo.geoColorObject
* @property {number} r The red intensity on a scale of [0-1].
* @property {number} g The green intensity on a scale of [0-1].
* @property {number} b The blue intensity on a scale of [0-1].
* @property {number} [a] The opacity on a scale of [0-1]. If unspecified and
* used, it should be treated as 1.
*/

/**
* Polygon as a flat array. An array of vertices. The polygon has no holes.
* The first and last point of may be the same.
Expand Down
Loading

0 comments on commit bb7b190

Please sign in to comment.