Skip to content

Commit 5354c34

Browse files
committed
Add lassoLineWidth and remove OES_standard_derivatives GL extension
1 parent b25ecd0 commit 5354c34

4 files changed

Lines changed: 25 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v0.18.2
44

55
- Add two events: `init` and `destroy`
6+
- Add `lassoLineWidth` to allow adjusting the lasso line width
67
- Fix an issue with normalizing RGBA values
78

89
## v0.18.1

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ can be read and written via [`scatterplot.get()`](#scatterplot.get) and [`scatte
383383
| pointConnectionMaxIntPointsPerSegment | int | `100` | | `true` | `false` |
384384
| pointConnectionTolerance | float | `0.002` | | `true` | `false` |
385385
| lassoColor | quadruple | rgba(0, 0.667, 1, 1) | hex, rgb, rgba | `true` | `false` |
386+
| lassoLineWidth | float | 2 | >= 1 | `true` | `false` |
386387
| lassoMinDelay | int | 15 | >= 0 | `true` | `false` |
387388
| lassoMinDist | int | 4 | >= 0 | `true` | `false` |
388389
| lassoClearEvent | string | `'lassoEnd'` | `'lassoEnd'` or `'deselect'` | `true` | `false` |

src/constants.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ export const COLOR_HOVER_IDX = 2;
1414
export const COLOR_BG_IDX = 3;
1515
export const COLOR_NUM_STATES = 4;
1616
export const FLOAT_BYTES = Float32Array.BYTES_PER_ELEMENT;
17-
export const GL_EXTENSIONS = [
18-
'OES_standard_derivatives',
19-
'OES_texture_float',
20-
'OES_element_index_uint',
21-
];
17+
export const GL_EXTENSIONS = ['OES_texture_float', 'OES_element_index_uint'];
2218

2319
export const MOUSE_MODE_PANZOOM = 'panZoom';
2420
export const MOUSE_MODE_LASSO = 'lasso';
@@ -46,6 +42,8 @@ export const DEFAULT_EASING = cubicInOut;
4642
export const LASSO_CLEAR_ON_DESELECT = 'deselect';
4743
export const LASSO_CLEAR_ON_END = 'lassoEnd';
4844
export const LASSO_CLEAR_EVENTS = [LASSO_CLEAR_ON_DESELECT, LASSO_CLEAR_ON_END];
45+
export const DEFAULT_LASSO_COLOR = [0, 0.666666667, 1, 1];
46+
export const DEFAULT_LASSO_LINE_WIDTH = 2;
4947
export const DEFAULT_LASSO_INITIATOR = false;
5048
export const DEFAULT_LASSO_INITIATOR_BACKGROUND = 'rgba(255, 255, 255, 0.1)';
5149
export const DEFAULT_LASSO_MIN_DELAY = 10;
@@ -121,7 +119,6 @@ export const DEFAULT_VIEW = new Float32Array([
121119

122120
// Default misc
123121
export const DEFAULT_BACKGROUND_IMAGE = null;
124-
export const DEFAULT_LASSO_COLOR = [0, 0.666666667, 1, 1];
125122
export const DEFAULT_SHOW_RETICLE = false;
126123
export const DEFAULT_RETICLE_COLOR = [1, 1, 1, 0.5];
127124
export const DEFAULT_DESELECT_ON_DBL_CLICK = true;

src/index.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import {
4242
DEFAULT_EASING,
4343
DEFAULT_HEIGHT,
4444
DEFAULT_LASSO_COLOR,
45+
DEFAULT_LASSO_LINE_WIDTH,
4546
DEFAULT_LASSO_MIN_DELAY,
4647
DEFAULT_LASSO_MIN_DIST,
4748
DEFAULT_LASSO_CLEAR_EVENT,
@@ -204,6 +205,7 @@ const createScatterplot = (initialProperties = {}) => {
204205
deselectOnDblClick = DEFAULT_DESELECT_ON_DBL_CLICK,
205206
deselectOnEscape = DEFAULT_DESELECT_ON_ESCAPE,
206207
lassoColor = DEFAULT_LASSO_COLOR,
208+
lassoLineWidth = DEFAULT_LASSO_LINE_WIDTH,
207209
lassoMinDelay = DEFAULT_LASSO_MIN_DELAY,
208210
lassoMinDist = DEFAULT_LASSO_MIN_DIST,
209211
lassoClearEvent = DEFAULT_LASSO_CLEAR_EVENT,
@@ -2034,6 +2036,14 @@ const createScatterplot = (initialProperties = {}) => {
20342036
lasso.setStyle({ color: lassoColor });
20352037
};
20362038

2039+
const setLassoLineWidth = (newLassoLineWidth) => {
2040+
if (Number.isNaN(+newLassoLineWidth) || +newLassoLineWidth < 1) return;
2041+
2042+
lassoLineWidth = +newLassoLineWidth;
2043+
2044+
lasso.setStyle({ width: lassoLineWidth });
2045+
};
2046+
20372047
const setLassoMinDelay = (newLassoMinDelay) => {
20382048
if (!+newLassoMinDelay) return;
20392049

@@ -2290,6 +2300,7 @@ const createScatterplot = (initialProperties = {}) => {
22902300
if (property === 'deselectOnEscape') return deselectOnEscape;
22912301
if (property === 'height') return height;
22922302
if (property === 'lassoColor') return lassoColor;
2303+
if (property === 'lassoLineWidth') return lassoLineWidth;
22932304
if (property === 'lassoMinDelay') return lassoMinDelay;
22942305
if (property === 'lassoMinDist') return lassoMinDist;
22952306
if (property === 'lassoClearEvent') return lassoClearEvent;
@@ -2494,6 +2505,10 @@ const createScatterplot = (initialProperties = {}) => {
24942505
setLassoColor(properties.lassoColor);
24952506
}
24962507

2508+
if (properties.lassoLineWidth !== undefined) {
2509+
setLassoLineWidth(properties.lassoLineWidth);
2510+
}
2511+
24972512
if (properties.lassoMinDelay !== undefined) {
24982513
setLassoMinDelay(properties.lassoMinDelay);
24992514
}
@@ -2708,7 +2723,11 @@ const createScatterplot = (initialProperties = {}) => {
27082723
initCamera();
27092724
updateScales();
27102725

2711-
lasso = createLine(regl, { color: lassoColor, width: 3, is2d: true });
2726+
lasso = createLine(regl, {
2727+
color: lassoColor,
2728+
width: lassoLineWidth,
2729+
is2d: true,
2730+
});
27122731
pointConnections = createLine(regl, {
27132732
color: pointConnectionColor,
27142733
colorHover: pointConnectionColorHover,

0 commit comments

Comments
 (0)