How to use the konva.Util function in konva

To help you get started, we’ve selected a few konva examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github konvajs / konva / konva-node / index.js View on Github external
};
// mock document
Konva.document = {
  createElement: function() {},
  documentElement: {
    addEventListener: function() {}
  }
};

// make some global injections
global.requestAnimationFrame = cb => {
  setImmediate(cb);
};

// create canvas in Node env
Konva.Util.createCanvasElement = () => {
  const node = new canvas.Canvas();
  node.style = {};
  return node;
};

// create canvas in Node env
Konva.Util.createImageElement = () => {
  const node = new canvas.Image();
  node.style = {};
  return node;
};

// _checkVisibility use dom element, in node we can skip it
Konva.Stage.prototype._checkVisibility = () => {};

module.exports = Konva;
github feedthejim / effective-barnacle / front / src / components / Food.js View on Github external
//     this.lightSize * this.paintWidth / this.width,
    //     0, Math.PI * 2,
    //   );
    //   gameMap.ctx.fill();

    //   gameMap.ctx.globalAlpha = 1;
    //   gameMap.ctx.beginPath();
    //   gameMap.ctx.arc(this.paintX, this.paintY, this.paintWidth / 2, 0, Math.PI * 2);
    //   gameMap.ctx.fill();
    // }

    return (
github konvajs / konva / konva-node / index.js View on Github external
};

// make some global injections
global.requestAnimationFrame = cb => {
  setImmediate(cb);
};

// create canvas in Node env
Konva.Util.createCanvasElement = () => {
  const node = new canvas.Canvas();
  node.style = {};
  return node;
};

// create canvas in Node env
Konva.Util.createImageElement = () => {
  const node = new canvas.Image();
  node.style = {};
  return node;
};

// _checkVisibility use dom element, in node we can skip it
Konva.Stage.prototype._checkVisibility = () => {};

module.exports = Konva;
github feedthejim / effective-barnacle / front / src / reducers / canvas.js View on Github external
x: 0,
      y: 0,
      width: window.innerWidth,
      height: window.innerHeight,
    },
  },
  players: [],
  foods: [],
  leaderboard: [],
  player: {
    username: 'undefined',
    points: [],
    id: -1,
    x: window.innerWidth / 2,
    y: window.innerHeight / 2,
    fillColor: Konva.Util.getRandomColor(),
  },
};

export default (state = initialState, action) => {
  switch (action.type) {
    case WEBSOCKET_CONNECT:
      return {
        ...state,
        player: {
          ...state.player,
          username: action.username,
        },
      };

    case WEBSOCKET_REGISTER_SUCCESS:
      return {
github feedthejim / effective-barnacle / front / src / reducers / canvas.js View on Github external
players: [...action.players],
        player: {
          ...(player ? player : state.player),
        },
      };
    }

    case ADD_COLORED_RECT:
      return {
        ...state,
        entities: [
          ...state.entities,
          {
            x: Math.random() * window.innerWidth,
            y: Math.random() * window.innerHeight,
            color: Konva.Util.getRandomColor(),
          },
        ],
      };

    default:
      return state;
  }
};
github holochain / holochain-ui / ui-src / src / hApps / holo-chat / components / presence / presenceArc.tsx View on Github external
setTimeout(() => {
      this.setState({ color: Konva.Util.getRandomColor() })
    }, 1000)
  }
github jakkra / SmartMirror / client / src / components / BounceGame.js View on Github external
constructor(...args) {
      super(...args);
      this.state = {
        color: Konva.Util.getRandomColor(),
        ballX: 100,
        ballY: 100,
        ballSpeedX: 10,
        ballSpeedY: 10,
        paddleX: 700,
        paddleY: window.innerHeight - 50,
        visaible: true,
      };
      this.draw = this.draw.bind(this);
      this.movePaddleRight = this.movePaddleRight.bind(this);
      this.movePaddleLeft = this.movePaddleLeft.bind(this);

    }

konva

<p align="center"> <img src="https://konvajs.org/android-chrome-192x192.png" alt="Konva logo" height="180" /> </p>

MIT
Latest version published 18 days ago

Package Health Score

88 / 100
Full package analysis