Namespace: Util

Konva. Util

Source:
konva.js

Methods


<static> getRandomColor()

return random hex color

Source:
konva.js
Example
shape.fill(Konva.Util.getRandomColor());

<static> getRGB(color)

get RGB components of a color

Parameters:
Name Type Description
color String
Source:
konva.js
Example
// each of the following examples return {r:0, g:0, b:255}
var rgb = Konva.Util.getRGB('blue');
var rgb = Konva.Util.getRGB('#0000ff');
var rgb = Konva.Util.getRGB('rgb(0,0,255)');

<static> haveIntersection(r1, r2)

check intersection of two client rectangles

Parameters:
Name Type Description
r1 Object

{ x, y, width, height } client rectangle

r2 Object

{ x, y, width, height } client rectangle

Source:
konva.js
Example
const overlapping = Konva.Util.haveIntersection(shape1.getClientRect(), shape2.getClientRect());