setSamplingPoint.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. export default class setSamplingPoint {
  2. constructor(startX,startY,canvas,ctx,score,id) {
  3. this.startX = startX
  4. this.startY = startY
  5. this.endX = this.startX
  6. this.endY = this.startY
  7. this.canvas = canvas
  8. this.ctx = ctx
  9. this.score = score
  10. this.id = id
  11. this.w = 0
  12. this.h = 0
  13. this.isDrawing = false
  14. }
  15. setDrawStatus (e) {
  16. this.isDrawing = e
  17. }
  18. getDrawStatus () {
  19. return this.isDrawing
  20. }
  21. draw() {
  22. this.ctx.save();
  23. this.ctx.beginPath()
  24. this.ctx.font = '20px serif'
  25. this.ctx.fillStyle = 'red'
  26. this.ctx.textAlign = 'left'
  27. this.ctx.textBaseline = 'bottom'
  28. this.ctx.fillText(this.score, this.startX, this.startY)
  29. this.ctx.fill()
  30. this.ctx.closePath()
  31. this.ctx.beginPath()
  32. this.ctx.font = '45px serif'
  33. this.ctx.fillStyle = 'red'
  34. this.ctx.textAlign = 'left'
  35. this.ctx.textBaseline = 'bottom'
  36. // const iconImage = new Image();
  37. // iconImage.src = require('../assets/icon/icon_all_right.png');
  38. // iconImage.onload = () => {
  39. // console.log("小图标加载成功");
  40. // // 绘制小图标
  41. // const iconWidth = 40; // 小图标大小
  42. // const iconHeight = 40;
  43. // this.ctx.drawImage(iconImage, this.startX, this.startY, iconWidth, iconHeight);
  44. // };
  45. this.ctx.fillText('✓', this.startX - 25, this.startY + 5)
  46. this.ctx.closePath()
  47. this.ctx.restore();
  48. }
  49. }