+ context.fillRect(centerX, centerY, heartSize, heartSize);
+
+ // Left atrium
+ context.beginPath();
+ context.arc(centerX + radius, centerY, radius, 0, 2 * Math.PI, false);
+ context.fill();
+ context.closePath();
+
+ // Right atrium
+ context.beginPath();
+ context.arc(centerX + heartSize, centerY + radius, radius, 0, 2 * Math.PI, false);
+ context.fill();
+ context.closePath();
+
+ context.setTransform(1, 0, 0, 1, 0, 0);
+ }
+
+ // Sets the center from mouse
+ _setCenterFromMouse(event) {
+
+ this._showCursor();
+ this._targetCenter.x = event.offsetX;
+ this._targetCenter.y = event.offsetY;
+ setTimeout(this._hideCursor.bind(this), this._cursorTimeout);
+ }
+
+ // Binds the wheel event to resize the heart
+ _detectWheel() {
+
+ this.canvas.addEventListener('wheel', this._onWheel.bind(this));
+ }
+
+ // Handle the mouse wheel movement
+ _onWheel(event) {
+
+ if (!this._ticking) {
+ this._ticking = true;
+ window.requestAnimationFrame(this._resizeHeartFromDelta.bind(this, event.deltaY));
+ }
+ }
+
+ // Use delta to resize the heart
+ _resizeHeartFromDelta(delta) {
+
+ let heartSize = this.heartSize + (this._resizeMagnitude * delta);
+
+ if (heartSize > this.maxHeartSize) {
+ heartSize = this.maxHeartSize;
+ }
+
+ if (heartSize < this.minHeartSize) {
+ heartSize = this.minHeartSize;
+ }
+
+ this._targetHeartSize = heartSize;
+ this._ticking = false;
+ }
+
+ // Apply a class to show the cursor.
+ _showCursor() {
+
+ this.canvas.classList.add('mouse-moving');
+ }
+
+ // Remove class to hide the cursor.
+ _hideCursor() {
+
+ this.canvas.classList.remove('mouse-moving');