Drag from an existing node to add a new node or link. Click to select/deselect nodes/links. Hit the DELETE key to remove the selected node or link. Drag to pan. Scroll to zoom.
Built with D3.js.
| import React, { useReducer, Reducer, createContext, ReactNode, Dispatch } from "react"; | |
| type Action = <A>(dispatch: Dispatch<A>) => Function; | |
| export default function <S, A extends Action>( | |
| reducer: Reducer<S, A>, | |
| actions: Record<string, A>, | |
| initialState: S | |
| ) { | |
| const Context = createContext<S>({} as S); |
Drag from an existing node to add a new node or link. Click to select/deselect nodes/links. Hit the DELETE key to remove the selected node or link. Drag to pan. Scroll to zoom.
Built with D3.js.
| license: mit | |
| height: 500 | |
| border: no |
| import React, { PureComponent } from "react"; | |
| import { StyleSheet } from "react-native"; | |
| import ReglView from "./ReglView"; | |
| import mat4 from "gl-mat4"; | |
| import bunny from "bunny"; | |
| export default class Bunny extends PureComponent { | |
| drawCommand = regl => { | |
| return regl({ | |
| vert: ` |
| node_modules | |
| dist |
| function shuffle(arr) { | |
| for (let i = arr.length - 1; i >= 0; i--) { | |
| let j = Math.floor(Math.random() * (i + 1)); | |
| j = Math.max(Math.min(j, i), 0); | |
| const tmp = arr[i]; | |
| arr[i] = arr[j]; | |
| arr[j] = tmp; | |
| } | |
| return arr; | |
| } |
| export default class HeapSet { | |
| constructor (values) { | |
| this._values = values; | |
| this._list = new Array(values.length * 3); | |
| this._idToIndex = {}; | |
| const list = this._list; | |
| for (let i = 0, prev = -1; i < values.length; i++) { |
| function isLeft (x0, y0, x1, y1, x2, y2) { | |
| return ((x1 - x0) * (y2 - y0) - (x2 - x0) * (y1 - y0)); | |
| } | |
| export default function pointInPoygon (x, y, V) { | |
| let wn = 0; // winding number | |
| for (let i = 0; i < V.length - 1; i++) { // edge from V[i] to V[i+1] | |
| const vi = V[i], vj = V[i + 1]; | |
| if (vi.y <= y) { // start y <= P.y | |
| if (vj.y > y) { // an upward crossing |