()
| 1423 | } |
| 1424 | |
| 1425 | clear() { |
| 1426 | const w = this.params.defaultSize.width === 'fill' ? this.wrapper.clientWidth : this.params.defaultSize.width; |
| 1427 | const h = this.params.defaultSize.height === 'fill' ? this.wrapper.clientHeight : this.params.defaultSize.height; |
| 1428 | this.resize(w, h); |
| 1429 | this.clearBackground(); |
| 1430 | this.worklog.captureState(true); |
| 1431 | this.worklog.clean = true; |
| 1432 | this.syncToolElement(); |
| 1433 | this.adjustSizeFull(); |
| 1434 | |
| 1435 | if (this.params.initText && this.worklog.empty) { |
| 1436 | this.ctx.lineWidth = 3; |
| 1437 | this.ctx.strokeStyle = '#fff'; |
| 1438 | const initTexts = this.wrapper.querySelectorAll('.init-text'); |
| 1439 | if (initTexts.length > 0) { |
| 1440 | initTexts.forEach((text) => { |
| 1441 | text.remove(); |
| 1442 | }); |
| 1443 | } |
| 1444 | this.initText = document.createElement('div'); |
| 1445 | this.initText.classList.add('init-text'); |
| 1446 | this.wrapper.append(this.initText); |
| 1447 | this.initText.innerHTML = '<div style="pointer-events: none;position:absolute;top:50%;width:100%;left: 50%; transform: translate(-50%, -50%)">' + |
| 1448 | `${this.params.initText}</div>`; |
| 1449 | this.initText.style.left = '0'; |
| 1450 | this.initText.style.top = '0'; |
| 1451 | this.initText.style.right = '0'; |
| 1452 | this.initText.style.bottom = '0'; |
| 1453 | this.initText.style.pointerEvents = 'none'; |
| 1454 | this.initText.style['text-align'] = 'center'; |
| 1455 | this.initText.style.position = 'absolute'; |
| 1456 | this.initText.style.color = this.params.initTextColor; |
| 1457 | this.initText.style['font-family'] = this.params.initTextStyle.split(/ (.+)/)[1]; |
| 1458 | this.initText.style['font-size'] = this.params.initTextStyle.split(/ (.+)/)[0]; |
| 1459 | |
| 1460 | this.wrapper.addEventListener('click', () => { |
| 1461 | this.initText.remove(); |
| 1462 | this.initText = null; |
| 1463 | }, { once: true }); |
| 1464 | } |
| 1465 | } |
| 1466 | |
| 1467 | clearBackground() { |
| 1468 | this.ctx.beginPath(); |
no test coverage detected