MCPcopy Index your code
hub / github.com/bqplot/bqplot / point_selector

Function point_selector

js/src/BrushSelector.ts:32–63  ·  view source on GitHub ↗
(x, y)

Source from the content-addressed store, hash-verified

30// Instead of using mixins we use free functions for now
31
32function point_selector(x, y) {
33 return function (xar, yar) {
34 if (typeof yar === 'undefined') {
35 // the 'old' method for backwards compatibility
36 return sel_utils.point_in_rectangle(xar, x, y);
37 }
38
39 const len = Math.min(xar.length, yar.length);
40 const mask = new Uint8Array(len);
41 // for performance we keep the if statement out of the loop
42 if (x.length && y.length) {
43 for (let i = 0; i < len; i++) {
44 mask[i] =
45 x[0] <= xar[i] && xar[i] <= x[1] && y[0] <= yar[i] && yar[i] <= y[1]
46 ? 1
47 : 0;
48 }
49 return mask;
50 } else if (x.length) {
51 for (let i = 0; i < len; i++) {
52 mask[i] = x[0] <= xar[i] && xar[i] <= x[1] ? 1 : 0;
53 }
54 } else {
55 // (y.length)
56 for (let i = 0; i < len; i++) {
57 mask[i] = y[0] <= yar[i] && yar[i] <= y[1] ? 1 : 0;
58 }
59 }
60
61 return mask;
62 };
63}
64
65function rect_selector(x, y) {
66 return function (xy) {

Callers 2

update_mark_selectedFunction · 0.85
selector_changedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…