Exemple #1
0
  setCommandCursor( painter:SkyBrush, command:Command ) {
    const cursor = command.getCursor()

    if ( cursor === null ) {
      this.cursor.setBlankCursor()
    } else if ( typeof cursor === 'string' ) {
      this.cursor.setClass( cursor )
    } else {
      cursor.call( command, this, painter )
    }

    return this
  }
Exemple #2
0
  hideInner():this {
    if ( ! this.isReallyHidden ) {
      this.isReallyHidden = true
      this.cursor.hide()
    }

    return this
  }
Exemple #3
0
  showInner():this {
    if ( this.isReallyHidden ) {
      this.isReallyHidden = false

      this.cursor.show()
    }

    return this
  }
Exemple #4
0
  renderShape( render:RenderFunction ):void {
    if ( render !== null ) {
      const zoomSize = this.getZoomSize()
      this.shape = render

      if ( ! this.isHidden ) {
        // draws a cross hair
        if ( zoomSize <= BRUSH_CURSOR_MINIMUM_SIZE ) {
          this.setCrosshair()

        } else {
          const canvas = this.canvas
          const ctx = canvas.getContext( '2d' ) as CanvasRenderingContext2D
          const canvasSize  = zoomSize + BRUSH_CURSOR_PADDING

          canvas.width = canvas.height = canvasSize

          ctx.beginPath()
          ctx.lineCap   = 'round'
          ctx.lineWidth = 1

          this.shape( ctx, canvas, zoomSize )

          const middle = canvas.width/2

          // draw a dot in the centre
          ctx.beginPath()

          ctx.strokeStyle = '#fff'
          ctx.globalAlpha = 0.9
          ctx.strokeRect( middle-0.75, middle-0.75, 1.5, 1.5 )

          ctx.strokeStyle = '#000'
          ctx.globalAlpha = 0.6
          ctx.strokeRect( middle-0.5 , middle-0.5 , 1  , 1   )

          this.cursor.setCursorURL( canvas.toDataURL(), canvas.width )
        }
      }
    }
  }
Exemple #5
0
  setClass( klass:string ) {
    this.cursor.setClass( klass )
    this.shape = null

    return this
  }
Exemple #6
0
  onMove( ev:MouseEvent ):this {
    this.cursor.update( ev )

    return this
  }
Exemple #7
0
  setCrosshair():this {
    this.cursor.setCursorURL( CROSSHAIR_CURSOR_DATA_URL, CROSSHAIR_CURSOR_SIZE )
    this.shape = null

    return this
  }