Skip to content

Instantly share code, notes, and snippets.

@mariorcardoso
Last active June 6, 2017 13:46
Show Gist options
  • Save mariorcardoso/297642ebadfdd23b63523e2194c92825 to your computer and use it in GitHub Desktop.
Save mariorcardoso/297642ebadfdd23b63523e2194c92825 to your computer and use it in GitHub Desktop.
class Rectangle {
constructor(height, width, color) {
this.height = height
this.width = width
this.color = color
}
draw(layer, stage) {
const rectangle = new Konva.Rect({
x: Math.random() * stage.getWidth(),
y: Math.random() * stage.getHeight(),
width: this.width,
height: this.height,
fill: this.color,
stroke: this.color,
strokeWidth: 1,
draggable: true,
shadowColor: 'black',
shadowBlur: 10,
shadowOffset: {x: 5, y: 5},
shadowOpacity: 0.6,
scale: {x: 1, y: 1},
startScale: 1
});
layer.add(rectangle);
}
}
export { Rectangle }
import { Rectangle } from './rectangle'
class Square extends Rectangle {
constructor(size, color) {
super(size, size, color)
}
}
export { Square }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment