react-color#HuePicker JavaScript Examples

The following examples show how to use react-color#HuePicker. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: App.js    From place with MIT License 5 votes vote down vote up
render() {
    const content = !this.state.connected ? (
        <div>Connecting... <span className="spinner-grow spinner-grow-sm" role="status" aria-hidden="true"></span></div>
    ) : (this.state.signedIn ? (
        <div>
          <div className="float-right">
            <button
              className="btn btn-outline-secondary"
              onClick={() => this.logOut()}>Log out</button>
          </div>
          <h4>Hello, <span className="font-weight-bold">{this.state.accountId}</span>!</h4>
          <div>
            PIXEL tokens: {this.state.balance.toFixed(6)}
          </div>
          <div>
            Your pixels: {this.state.numPixels}
          </div>
          <div className="color-picker">
            <HuePicker color={ this.state.pickerColor } width="100%" disableAlpha={true} onChange={(c) => this.hueColorChange(c)}/>
            <GithubPicker className="circle-picker" colors={this.state.gammaColors} color={ this.state.pickerColor } triangle='hide' width="100%" onChangeComplete={(c) => this.changeColor(c)}/>
            <GithubPicker className="circle-picker" colors={this.state.colors} color={ this.state.pickerColor } triangle='hide' width="100%" onChangeComplete={(c) => this.hueColorChange(c)}/>
          </div>
        </div>
    ) : (
        <div style={{marginBottom: "10px"}}>
          <button
              className="btn btn-primary"
              onClick={() => this.requestSignIn()}>Log in with NEAR Wallet</button>
        </div>
    ));
    return (
      <div className="px-5">
        <h1>NEAR Place</h1>
        {content}
        <div>
          <canvas ref={this.canvasRef}
                  width={800}
                  height={800}
                  className={this.state.boardLoaded ? "pixel-board" : "pixel-board c-animated-background"}>

          </canvas>
        </div>
      </div>
    );
  }
Example #2
Source File: Canvas.js    From Easy-Annotator with GNU General Public License v3.0 4 votes vote down vote up
render() {
    const {
      click,
      clickX,
      clickY,
      divPos,
      videoElem,
      mouseX,
      mouseY,
      scrollPos,
      edit,
      progress,
      roiColor,
    } = this.state;

    const { selected, listrois } = this.props;

    return (
      <div
        onMouseMove={this.handleMouseMove}
        onPointerDown={this.handlePointerDown}
        onPointerUp={this.handlePointerUp}
        id="canvas"
      >
        {edit && click && (
          <ResizableRect
            left={clickX - divPos.left + videoElem.offsetLeft}
            top={clickY + scrollPos - divPos.top + videoElem.offsetTop}
            height={mouseY - clickY}
            width={mouseX - clickX}
            rotatable={false}
            zoomable="nw,sw,ne,se"
            sx={{
              "&": {
                color: roiColor,
                border: 2,
                borderStyle: "solid",
              },
            }}
          />
        )}
        {listrois &&
          listrois.map((ROI, index) => {
            if (
              ROI.visible &&
              !ROI.disable &&
              Math.abs(ROI.timeFraction - progress) < 0.000001
            ) {
              return (
                <ResizableRect
                  key={index}
                  left={
                    videoElem.getBoundingClientRect().left +
                    videoElem.offsetWidth * ROI.left -
                    divPos.left +
                    videoElem.offsetLeft
                  }
                  top={
                    videoElem.getBoundingClientRect().top +
                    videoElem.offsetHeight * ROI.top +
                    scrollPos -
                    divPos.top +
                    videoElem.offsetTop
                  }
                  height={ROI.height * videoElem.offsetHeight}
                  width={ROI.width * videoElem.offsetWidth}
                  rotatable={true}
                  zoomable={selected === index ? "nw,sw,ne,se" : ""}
                  sx={{
                    "&": {
                      color: roiColor,
                      border: 2,
                      borderStyle: "solid",
                    },
                  }}
                >
                  <ROILabel
                    style={{ color: roiColor }}
                    label={ROI.label}
                    comment={ROI.comment}
                  />
                </ResizableRect>
              );
            }
          })}

        <SurgeryPlayer
          id="surgery-player"
          listrois={listrois}
          selected={selected}
          onProgressCallback={this.onProgressCallback}
          onDurationCallback={this.onDurationCallback}
          onTrackingCallback={this.props.onTrackingCallback}
        />
        {videoElem != null && (
          <div>
            <br />
            <Text>ROI Color Selector</Text>
            <HuePicker
              color={this.state.roiColor}
              onChange={this.handleChangeComplete}
            />
          </div>
        )}
      </div>
    );
  }