Draw.js 87 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891
  1. import { floorplanService } from '../Service/FloorplanService.js'
  2. import { stateService } from '../Service/StateService.js'
  3. import { coordinate } from '../Coordinate.js'
  4. import Style from '../Style.js'
  5. import VectorType from '../enum/VectorType.js'
  6. import SelectState from '../enum/SelectState.js'
  7. import { mathUtil } from '../MathUtil.js'
  8. import ElementEvents from '../enum/ElementEvents.js'
  9. import Constant from '../Constant.js'
  10. import { signService } from '../Service/SignService.js'
  11. export default class Draw {
  12. constructor() {
  13. this.context = null
  14. }
  15. initContext(canvas) {
  16. if (canvas) {
  17. this.context = canvas.getContext('2d')
  18. } else {
  19. this.context = null
  20. }
  21. }
  22. clear() {
  23. this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height)
  24. }
  25. drawBackGround(color) {
  26. this.context.save()
  27. this.context.fillStyle = color
  28. this.context.fillRect(0, 0, this.context.canvas.width, this.context.canvas.height)
  29. this.context.restore()
  30. }
  31. // setSVGAttr(svgId,width,height){
  32. // }
  33. drawWall(vector) {
  34. let start = floorplanService.getPoint(vector.start)
  35. let end = floorplanService.getPoint(vector.end)
  36. let points = []
  37. points.push(start)
  38. points.push(end)
  39. points = points.sort(sortNumber.bind(this))
  40. function sortNumber(a, b) {
  41. return mathUtil.getDistance(start, a) - mathUtil.getDistance(start, b)
  42. }
  43. this.context.save()
  44. this.context.beginPath()
  45. this.context.lineCap = 'round' //线段端点的样式
  46. //this.context.lineJoin= 'miter';
  47. this.context.strokeStyle = Style.Wall.strokeStyle
  48. this.context.lineWidth = Style.Wall.lineWidth * coordinate.ratio
  49. this.context.strokeStyle = Style.Wall.strokeStyle
  50. const selectItem = stateService.getSelectItem()
  51. const draggingItem = stateService.getDraggingItem()
  52. const focusItem = stateService.getFocusItem()
  53. if (selectItem && selectItem.type == VectorType.Wall) {
  54. if (vector.vectorId == selectItem.vectorId) {
  55. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  56. }
  57. } else if (draggingItem && draggingItem.type == VectorType.Wall) {
  58. if (vector.vectorId == draggingItem.vectorId) {
  59. this.context.strokeStyle = Style.Select.Wall.strokeStyle
  60. }
  61. }
  62. if (focusItem && focusItem.type == VectorType.Wall) {
  63. if (vector.vectorId == focusItem.vectorId) {
  64. this.context.strokeStyle = Style.Focus.Wall.strokeStyle
  65. }
  66. }
  67. for (let i = 0; i < points.length - 1; i += 2) {
  68. let point1 = coordinate.getScreenXY(points[i])
  69. let point2 = coordinate.getScreenXY(points[i + 1])
  70. this.context.moveTo(point1.x, point1.y)
  71. this.context.lineTo(point2.x, point2.y)
  72. }
  73. this.context.stroke()
  74. this.context.restore()
  75. }
  76. drawSpecialPoint() {
  77. const selectItem = stateService.getSelectItem()
  78. const draggingItem = stateService.getDraggingItem()
  79. const focusItem = stateService.getFocusItem()
  80. let point = null
  81. this.context.save()
  82. if (selectItem) {
  83. point = floorplanService.getPoint(selectItem.vectorId)
  84. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  85. this.context.strokeStyle = Style.Select.Point.strokeStyle
  86. this.context.fillStyle = Style.Select.Point.fillStyle
  87. }
  88. if (draggingItem) {
  89. point = floorplanService.getPoint(draggingItem.vectorId)
  90. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  91. this.context.strokeStyle = Style.Select.Point.strokeStyle
  92. this.context.fillStyle = Style.Select.Point.fillStyle
  93. }
  94. if (focusItem) {
  95. point = floorplanService.getPoint(focusItem.vectorId)
  96. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  97. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  98. this.context.fillStyle = Style.Focus.Point.fillStyle
  99. }
  100. if (point == null) {
  101. this.context.restore()
  102. return
  103. }
  104. const pt = coordinate.getScreenXY({ x: point.x, y: point.y })
  105. let radius = Style.Point.radius
  106. this.context.beginPath()
  107. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  108. this.context.stroke()
  109. this.context.fill()
  110. this.context.restore()
  111. }
  112. drawPoint(vector) {
  113. const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y })
  114. const selectItem = stateService.getSelectItem()
  115. const draggingItem = stateService.getDraggingItem()
  116. const focusItem = stateService.getFocusItem()
  117. // this.context.save()
  118. // this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  119. // this.context.strokeStyle = Style.Point.strokeStyle
  120. // this.context.fillStyle = Style.Point.fillStyle
  121. let radius = Style.Point.radius
  122. if (
  123. (draggingItem && draggingItem.type == VectorType.WallCorner && vector.vectorId == draggingItem.vectorId) ||
  124. (selectItem && selectItem.type == VectorType.WallCorner && vector.vectorId == selectItem.vectorId)
  125. ) {
  126. this.context.save()
  127. this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
  128. this.context.strokeStyle = Style.Select.Point.strokeStyle
  129. this.context.fillStyle = Style.Select.Point.fillStyle
  130. radius = Style.Select.Point.radius
  131. } else if (focusItem && focusItem.type == VectorType.WallCorner && vector.vectorId == focusItem.vectorId) {
  132. this.context.save()
  133. this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
  134. this.context.strokeStyle = Style.Focus.Point.strokeStyle
  135. this.context.fillStyle = Style.Focus.Point.fillStyle
  136. radius = Style.Focus.Point.radius
  137. } else {
  138. return
  139. }
  140. this.context.beginPath()
  141. this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  142. this.context.stroke()
  143. this.context.fill()
  144. this.context.restore()
  145. // this.drawText({ x: vector.x, y: vector.y }, vector.vectorId)
  146. }
  147. // 文字
  148. drawText(position, txt, screenCoord) {
  149. this.context.save()
  150. this.setCanvasStyle(Style.Font)
  151. this.context.font = '12px Microsoft YaHei'
  152. let pt = { x: position.x, y: position.y }
  153. if (!screenCoord) {
  154. pt = coordinate.getScreenXY({ x: position.x, y: position.y })
  155. }
  156. this.context.fillText(txt, pt.x, pt.y)
  157. this.context.restore()
  158. }
  159. drawTag(geometry) {
  160. this.context.save()
  161. this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio
  162. this.context.strokeStyle = Style.Tag.strokeStyle
  163. this.context.fillStyle = Style.Tag.fillStyle
  164. const selectItem = stateService.getSelectItem()
  165. const draggingItem = stateService.getDraggingItem()
  166. const focusItem = stateService.getFocusItem()
  167. if (selectItem && selectItem.type == VectorType.Tag) {
  168. if (geometry.vectorId == selectItem.vectorId) {
  169. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  170. this.context.fillStyle = Style.Select.Tag.fillStyle
  171. }
  172. } else if (draggingItem && draggingItem.type == VectorType.Tag) {
  173. if (geometry.vectorId == draggingItem.vectorId) {
  174. this.context.strokeStyle = Style.Select.Tag.strokeStyle
  175. this.context.fillStyle = Style.Select.Tag.fillStyle
  176. }
  177. }
  178. if (focusItem && focusItem.type == VectorType.Tag) {
  179. if (geometry.vectorId == focusItem.vectorId) {
  180. this.context.strokeStyle = Style.Focus.Tag.strokeStyle
  181. this.context.fillStyle = Style.Focus.Tag.fillStyle
  182. }
  183. }
  184. const fontSize = coordinate.ratio == Constant.ratio ? 36 : 12
  185. this.context.font = `400 ${fontSize}px Microsoft YaHei`
  186. //根据文字的长度,更新标注范围
  187. geometry.sideWidth = Math.max(this.context.measureText(geometry.value).width, this.context.measureText(parseFloat(geometry.value).toFixed(2)).width)
  188. geometry.setPoints2d()
  189. let points2d = geometry.points2d
  190. let points = []
  191. for (let i = 0; i < points2d.length; ++i) {
  192. points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
  193. }
  194. let pt = { x: geometry.center.x, y: geometry.center.y }
  195. pt = coordinate.getScreenXY({ x: geometry.center.x, y: geometry.center.y })
  196. const fontWidth1 = this.context.measureText(geometry.value).width
  197. const line1 = mathUtil.createLine1({ x: (points[0].x + points[3].x) / 2, y: (points[0].y + points[3].y) / 2 }, { x: (points[2].x + points[1].x) / 2, y: (points[2].y + points[1].y) / 2 })
  198. const fontStart1 = mathUtil.getDisPointsLine(line1, pt, fontWidth1 / 2, fontWidth1 / 2)
  199. if (fontStart1.newpoint1.x < fontStart1.newpoint2.x) {
  200. this.context.fillText(geometry.value, fontStart1.newpoint1.x, fontStart1.newpoint1.y)
  201. } else {
  202. this.context.fillText(geometry.value, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
  203. }
  204. this.context.restore()
  205. }
  206. drawTable(geometry){
  207. const leftTop = coordinate.getScreenXY({
  208. x:geometry.center.x - Math.abs(geometry.points[0].x - geometry.points[1].x)/2,
  209. y:geometry.center.y + Math.abs(geometry.points[0].y - geometry.points[3].y)/2,
  210. })
  211. for(let i=0;i<geometry.cells.length;++i){
  212. for(let j=0;j<geometry.cells[i].length;++j)
  213. {
  214. const cell = floorplanService.getCell(geometry.cells[i][j])
  215. const position = geometry.getCellPos(cell.vectorId)
  216. this.drawCell(cell,position.x + leftTop.x,position.y + leftTop.y)
  217. }
  218. }
  219. }
  220. drawCell(geometry,width,height){
  221. this.context.save()
  222. this.context.lineWidth = Style.Table.lineWidth * coordinate.ratio
  223. this.context.strokeStyle = Style.Table.strokeStyle
  224. this.context.fillStyle = Style.Table.fillStyle
  225. const selectItem = stateService.getSelectItem()
  226. const draggingItem = stateService.getDraggingItem()
  227. const focusItem = stateService.getFocusItem()
  228. if (selectItem && selectItem.type == VectorType.Table) {
  229. if (geometry.parent == selectItem.vectorId) {
  230. this.context.strokeStyle = Style.Select.Table.strokeStyle
  231. this.context.fillStyle = Style.Select.Table.fillStyle
  232. }
  233. } else if (draggingItem && draggingItem.type == VectorType.Table) {
  234. if (geometry.parent == draggingItem.vectorId) {
  235. this.context.strokeStyle = Style.Select.Table.strokeStyle
  236. this.context.fillStyle = Style.Select.Table.fillStyle
  237. }
  238. }
  239. if (focusItem && focusItem.type == VectorType.Table) {
  240. if (geometry.parent == focusItem.vectorId) {
  241. this.context.strokeStyle = Style.Focus.Table.strokeStyle
  242. this.context.fillStyle = Style.Focus.Table.fillStyle
  243. }
  244. }
  245. this.context.translate(width, height)
  246. this.context.beginPath()
  247. this.context.moveTo(0,0)
  248. this.context.lineTo(geometry.width,0)
  249. this.context.lineTo(geometry.width,geometry.height)
  250. this.context.lineTo(0,geometry.height)
  251. this.context.closePath();
  252. this.context.stroke()
  253. const defaultHeight = 24;
  254. const defaultWidth = 156;
  255. this.context.font = '12px Microsoft YaHei'
  256. const fontWidth = this.context.measureText(geometry.value).width
  257. //let rowCount = Math.ceil(geometry.height/defaultHeight) //分几行写
  258. let rowCount = Math.ceil(fontWidth/defaultWidth) //分几行写,根据要写的文字的长度来判断
  259. if(rowCount == 1){
  260. this.context.textAlign = "center";
  261. this.context.textBaseline = "middle";
  262. this.context.fillText(geometry.value, geometry.width/2, geometry.height/2)
  263. }
  264. //大于1行
  265. else{
  266. const rowWidth = Math.ceil(fontWidth/rowCount) //每行的长度
  267. const rowFontCount = Math.ceil(geometry.value.length/rowCount) //每行的文字个数
  268. this.context.textAlign = "left";
  269. for(let i=0;i<rowCount;++i){
  270. const value = geometry.value.substr(i*rowFontCount,rowFontCount)
  271. this.context.fillText(value, geometry.width/2 - rowWidth/2, 18+18*i)
  272. }
  273. }
  274. this.context.restore()
  275. }
  276. drawRectangle(geometry){
  277. let points = []
  278. for(let i=0;i<geometry.points.length;++i){
  279. points.push(coordinate.getScreenXY(geometry.points[i]))
  280. }
  281. this.context.save()
  282. this.context.beginPath()
  283. this.context.lineCap = 'round' //线段端点的样式;
  284. this.context.strokeStyle = Style.Rectangle.strokeStyle
  285. this.context.lineWidth = Style.Rectangle.lineWidth * coordinate.ratio
  286. this.context.strokeStyle = Style.Rectangle.strokeStyle
  287. const selectItem = stateService.getSelectItem()
  288. const draggingItem = stateService.getDraggingItem()
  289. const focusItem = stateService.getFocusItem()
  290. let fillFlag = false
  291. if (selectItem && selectItem.type == VectorType.Rectangle) {
  292. if (geometry.vectorId == selectItem.vectorId) {
  293. if(selectItem.selectIndex == SelectState.All){
  294. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  295. this.context.fillStyle = Style.Select.Rectangle.fillStyle
  296. fillFlag = true;
  297. }
  298. else if(selectItem.selectIndex.indexOf(SelectState.Side)>-1){
  299. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  300. }
  301. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  302. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  303. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  304. this.drawCircle({
  305. x:geometry.points[vertexIndex].x,
  306. y:geometry.points[vertexIndex].y,
  307. name: ElementEvents.StartAddWall
  308. })
  309. }
  310. }
  311. } else if (draggingItem && draggingItem.type == VectorType.Rectangle) {
  312. if (geometry.vectorId == draggingItem.vectorId) {
  313. if(draggingItem.selectIndex == SelectState.All){
  314. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  315. this.context.fillStyle = Style.Select.Rectangle.fillStyle
  316. fillFlag = true;
  317. }
  318. else if(draggingItem.selectIndex.indexOf(SelectState.Side)>-1){
  319. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  320. }
  321. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  322. this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
  323. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  324. this.drawCircle({
  325. x:geometry.points[vertexIndex].x,
  326. y:geometry.points[vertexIndex].y,
  327. name: ElementEvents.StartAddWall
  328. })
  329. }
  330. }
  331. }
  332. if (focusItem && focusItem.type == VectorType.Rectangle) {
  333. if (geometry.vectorId == focusItem.vectorId) {
  334. if(focusItem.selectIndex == SelectState.All){
  335. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  336. this.context.fillStyle = Style.Focus.Rectangle.fillStyle
  337. fillFlag = true;
  338. }
  339. else if(focusItem.selectIndex.indexOf(SelectState.Side)>-1){
  340. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  341. }
  342. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  343. this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
  344. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  345. this.drawCircle({
  346. x:geometry.points[vertexIndex].x,
  347. y:geometry.points[vertexIndex].y,
  348. name: ElementEvents.StartAddWall
  349. })
  350. }
  351. }
  352. }
  353. this.context.moveTo(points[0].x, points[0].y)
  354. for (let i = 1; i < points.length; ++i) {
  355. this.context.lineTo(points[i].x, points[i].y)
  356. }
  357. this.context.closePath();
  358. this.context.stroke()
  359. if(fillFlag){
  360. this.context.fill()
  361. }
  362. this.context.restore()
  363. }
  364. drawCircleGeo(geometry)
  365. {
  366. let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
  367. const twoPi = Math.PI * 2
  368. const pt = coordinate.getScreenXY(geometry.center)
  369. this.context.save()
  370. this.context.strokeStyle = Style.Circle.strokeStyle
  371. const selectItem = stateService.getSelectItem()
  372. const draggingItem = stateService.getDraggingItem()
  373. const focusItem = stateService.getFocusItem()
  374. let fillFlag = false
  375. if (selectItem && selectItem.type == VectorType.Circle) {
  376. if (geometry.vectorId == selectItem.vectorId) {
  377. if(selectItem.selectIndex == SelectState.All){
  378. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  379. this.context.fillStyle = Style.Select.Circle.fillStyle
  380. fillFlag = true;
  381. }
  382. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  383. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  384. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  385. this.drawCircle({
  386. x:geometry.points[vertexIndex].x,
  387. y:geometry.points[vertexIndex].y,
  388. name: ElementEvents.StartAddWall
  389. })
  390. this.drawRec(geometry.points)
  391. }
  392. }
  393. } else if (draggingItem && draggingItem.type == VectorType.Circle) {
  394. if (geometry.vectorId == draggingItem.vectorId) {
  395. if(draggingItem.selectIndex == SelectState.All){
  396. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  397. this.context.fillStyle = Style.Select.Circle.fillStyle
  398. fillFlag = true;
  399. }
  400. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  401. this.context.strokeStyle = Style.Select.Circle.strokeStyle
  402. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  403. this.drawCircle({
  404. x:geometry.points[vertexIndex].x,
  405. y:geometry.points[vertexIndex].y,
  406. name: ElementEvents.StartAddWall
  407. })
  408. this.drawRec(geometry.points)
  409. }
  410. }
  411. }
  412. if (focusItem && focusItem.type == VectorType.Circle) {
  413. if (geometry.vectorId == focusItem.vectorId) {
  414. if(focusItem.selectIndex == SelectState.All){
  415. this.context.strokeStyle = Style.Focus.Circle.strokeStyle
  416. this.context.fillStyle = Style.Focus.Circle.fillStyle
  417. fillFlag = true;
  418. }
  419. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  420. this.context.strokeStyle = Style.Focus.Circle.strokeStyle
  421. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  422. this.drawCircle({
  423. x:geometry.points[vertexIndex].x,
  424. y:geometry.points[vertexIndex].y,
  425. name: ElementEvents.StartAddWall
  426. })
  427. this.drawRec(geometry.points)
  428. }
  429. }
  430. }
  431. this.context.beginPath()
  432. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  433. this.context.stroke()
  434. if(fillFlag){
  435. this.context.fill()
  436. }
  437. this.context.restore()
  438. }
  439. drawIcon(geometry)
  440. {
  441. let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
  442. const twoPi = Math.PI * 2
  443. const pt = coordinate.getScreenXY(geometry.center)
  444. this.context.save()
  445. this.context.strokeStyle = Style.Icon.strokeStyle
  446. const selectItem = stateService.getSelectItem()
  447. const draggingItem = stateService.getDraggingItem()
  448. const focusItem = stateService.getFocusItem()
  449. let fillFlag = false
  450. if (selectItem && selectItem.type == VectorType.Icon) {
  451. if (geometry.vectorId == selectItem.vectorId) {
  452. if(selectItem.selectIndex == SelectState.All){
  453. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  454. this.context.fillStyle = Style.Select.Icon.fillStyle
  455. fillFlag = true;
  456. }
  457. else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  458. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  459. let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
  460. this.drawCircle({
  461. x:geometry.points[vertexIndex].x,
  462. y:geometry.points[vertexIndex].y,
  463. name: ElementEvents.StartAddWall
  464. })
  465. this.drawRec(geometry.points)
  466. }
  467. }
  468. } else if (draggingItem && draggingItem.type == VectorType.Icon) {
  469. if (geometry.vectorId == draggingItem.vectorId) {
  470. if(draggingItem.selectIndex == SelectState.All){
  471. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  472. this.context.fillStyle = Style.Select.Icon.fillStyle
  473. fillFlag = true;
  474. }
  475. else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  476. this.context.strokeStyle = Style.Select.Icon.strokeStyle
  477. let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
  478. this.drawCircle({
  479. x:geometry.points[vertexIndex].x,
  480. y:geometry.points[vertexIndex].y,
  481. name: ElementEvents.StartAddWall
  482. })
  483. this.drawRec(geometry.points)
  484. }
  485. }
  486. }
  487. if (focusItem && focusItem.type == VectorType.Icon) {
  488. if (geometry.vectorId == focusItem.vectorId) {
  489. if(focusItem.selectIndex == SelectState.All){
  490. this.context.strokeStyle = Style.Focus.Icon.strokeStyle
  491. this.context.fillStyle = Style.Focus.Icon.fillStyle
  492. fillFlag = true;
  493. }
  494. else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
  495. this.context.strokeStyle = Style.Focus.Icon.strokeStyle
  496. let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
  497. this.drawCircle({
  498. x:geometry.points[vertexIndex].x,
  499. y:geometry.points[vertexIndex].y,
  500. name: ElementEvents.StartAddWall
  501. })
  502. this.drawRec(geometry.points)
  503. }
  504. }
  505. }
  506. this.context.beginPath()
  507. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  508. this.context.stroke()
  509. if(fillFlag){
  510. this.context.fill()
  511. }
  512. this.context.restore()
  513. this.context.save()
  514. this.setCanvasStyle(Style.Font)
  515. let fonSize = Math.ceil(radius * 14/20);
  516. this.context.font = fonSize + Style.Font.font;
  517. let center = coordinate.getScreenXY(geometry.center);
  518. this.context.fillText(geometry.value, center.x , center.y)
  519. this.context.restore()
  520. }
  521. drawArrow(geometry){
  522. this.context.save()
  523. this.context.beginPath()
  524. this.context.lineCap = 'round' //线段端点的样式
  525. this.context.strokeStyle = Style.Arrow.strokeStyle
  526. this.context.lineWidth = Style.Arrow.lineWidth * coordinate.ratio
  527. const selectItem = stateService.getSelectItem()
  528. const draggingItem = stateService.getDraggingItem()
  529. const focusItem = stateService.getFocusItem()
  530. if (selectItem && selectItem.type == VectorType.Arrow) {
  531. if (geometry.vectorId == selectItem.vectorId) {
  532. this.context.strokeStyle = Style.Select.Arrow.strokeStyle
  533. if(selectItem.selectIndex == SelectState.Start){
  534. this.drawCircle({
  535. x:geometry.startPoint.x,
  536. y:geometry.startPoint.y,
  537. name: ElementEvents.StartAddWall
  538. })
  539. }
  540. else if(selectItem.selectIndex == SelectState.End){
  541. this.drawCircle({
  542. x:geometry.endPoint.x,
  543. y:geometry.endPoint.y,
  544. name: ElementEvents.StartAddWall
  545. })
  546. }
  547. }
  548. } else if (draggingItem && draggingItem.type == VectorType.Arrow) {
  549. if (geometry.vectorId == draggingItem.vectorId) {
  550. this.context.strokeStyle = Style.Select.Arrow.strokeStyle
  551. if(draggingItem.selectIndex == SelectState.Start){
  552. this.drawCircle({
  553. x:geometry.startPoint.x,
  554. y:geometry.startPoint.y,
  555. name: ElementEvents.StartAddWall
  556. })
  557. }
  558. else if(draggingItem.selectIndex == SelectState.End){
  559. this.drawCircle({
  560. x:geometry.endPoint.x,
  561. y:geometry.endPoint.y,
  562. name: ElementEvents.StartAddWall
  563. })
  564. }
  565. }
  566. }
  567. if (focusItem && focusItem.type == VectorType.Arrow) {
  568. if (geometry.vectorId == focusItem.vectorId) {
  569. this.context.strokeStyle = Style.Focus.Arrow.strokeStyle
  570. if(focusItem.selectIndex == SelectState.Start){
  571. this.drawCircle({
  572. x:geometry.startPoint.x,
  573. y:geometry.startPoint.y,
  574. name: ElementEvents.StartAddWall
  575. })
  576. }
  577. else if(focusItem.selectIndex == SelectState.End){
  578. this.drawCircle({
  579. x:geometry.endPoint.x,
  580. y:geometry.endPoint.y,
  581. name: ElementEvents.StartAddWall
  582. })
  583. }
  584. }
  585. }
  586. let point1 = coordinate.getScreenXY(geometry.startPoint)
  587. let point2 = coordinate.getScreenXY(geometry.endPoint)
  588. var headlen = 10; //自定义箭头线的长度
  589. var theta = 20; //自定义箭头线与直线的夹角,个人觉得45°刚刚好
  590. //箭头线终点坐标
  591. var arrowX, arrowY;
  592. let fromX = point2.x;
  593. let fromY = point2.y;
  594. let toX = point1.x;
  595. let toY = point1.y;
  596. // 计算各角度和对应的箭头终点坐标
  597. var angle = Math.atan2(fromY - toY, fromX - toX) * 180 / Math.PI;
  598. var angle1 = (angle + theta) * Math.PI / 180;
  599. var angle2 = (angle - theta) * Math.PI / 180;
  600. var topX = headlen * Math.cos(angle1);
  601. var topY = headlen * Math.sin(angle1);
  602. var botX = headlen * Math.cos(angle2);
  603. var botY = headlen * Math.sin(angle2);
  604. this.context.beginPath();
  605. //画直线
  606. this.context.moveTo(fromX, fromY);
  607. this.context.lineTo(toX, toY);
  608. arrowX = toX + topX;
  609. arrowY = toY + topY;
  610. //画上边箭头线
  611. this.context.moveTo(arrowX, arrowY);
  612. this.context.lineTo(toX, toY);
  613. arrowX = toX + botX;
  614. arrowY = toY + botY;
  615. //画下边箭头线
  616. this.context.lineTo(arrowX, arrowY);
  617. this.context.stroke()
  618. this.context.restore()
  619. }
  620. drawCircle(element) {
  621. let radius = null
  622. const twoPi = Math.PI * 2
  623. const pt = coordinate.getScreenXY(element)
  624. this.context.save()
  625. if (element.name == ElementEvents.StartAddWall) {
  626. radius = Style.Element.StartAddWall.radius * coordinate.ratio
  627. this.context.strokeStyle = Style.Element.StartAddWall.strokeStyle
  628. this.context.fillStyle = Style.Element.StartAddWall.fillStyle
  629. }
  630. this.context.beginPath()
  631. this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
  632. this.context.stroke()
  633. this.context.fill()
  634. this.context.restore()
  635. }
  636. drawRec(points){
  637. let point = coordinate.getScreenXY(points[0])
  638. this.context.moveTo(point.x, point.y)
  639. for (let i = 1; i < points.length; ++i) {
  640. point = coordinate.getScreenXY(points[i])
  641. this.context.lineTo(point.x, point.y)
  642. }
  643. this.context.closePath();
  644. this.context.stroke()
  645. }
  646. drawLine(element) {
  647. let start = coordinate.getScreenXY(element.start)
  648. let end = coordinate.getScreenXY(element.end)
  649. this.context.save()
  650. if (element.name == ElementEvents.VCheckLinesX) {
  651. this.context.lineWidth = Style.Element.VCheckLinesX.lineWidth * coordinate.ratio
  652. this.context.strokeStyle = Style.Element.VCheckLinesX.strokeStyle
  653. this.context.setLineDash([3, 2, 2])
  654. start.y = 0
  655. end.y = this.context.canvas.clientHeight
  656. } else if (element.name == ElementEvents.VCheckLinesY) {
  657. this.context.lineWidth = Style.Element.VCheckLinesY.lineWidth * coordinate.ratio
  658. this.context.strokeStyle = Style.Element.VCheckLinesY.strokeStyle
  659. this.context.setLineDash([3, 2, 2])
  660. start.x = 0
  661. end.x = this.context.canvas.clientWidth
  662. } else if (element.name == ElementEvents.NewWall) {
  663. this.context.lineWidth = Style.Element.NewWall.lineWidth * coordinate.ratio
  664. this.context.strokeStyle = Style.Element.NewWall.strokeStyle
  665. if (element.state == 'error') {
  666. this.context.strokeStyle = Style.Element.NewWall.errorStrokeStyle
  667. }
  668. } else if (element.name == ElementEvents.CheckLinesX) {
  669. this.context.lineWidth = Style.Element.CheckLinesX.lineWidth * coordinate.ratio
  670. this.context.strokeStyle = Style.Element.CheckLinesX.strokeStyle
  671. this.context.setLineDash([3, 2, 2])
  672. } else if (element.name == ElementEvents.CheckLinesY) {
  673. this.context.lineWidth = Style.Element.CheckLinesY.lineWidth * coordinate.ratio
  674. this.context.strokeStyle = Style.Element.CheckLinesY.strokeStyle
  675. this.context.setLineDash([3, 2, 2])
  676. }
  677. this.context.beginPath()
  678. this.context.moveTo(start.x, start.y)
  679. this.context.lineTo(end.x, end.y)
  680. this.context.stroke()
  681. this.context.restore()
  682. this.context.save()
  683. this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
  684. this.context.strokeStyle = Style.Point.strokeStyle
  685. this.context.fillStyle = Style.Point.fillStyle
  686. let radius = Style.Point.radius
  687. this.context.beginPath()
  688. this.context.arc(start.x, start.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
  689. this.context.stroke()
  690. this.context.fill()
  691. this.context.restore()
  692. }
  693. drawTitle(geometry){
  694. this.context.save()
  695. this.setCanvasStyle(Style.Title)
  696. const selectItem = stateService.getSelectItem()
  697. const draggingItem = stateService.getDraggingItem()
  698. const focusItem = stateService.getFocusItem()
  699. if (selectItem && selectItem.type == VectorType.Title) {
  700. this.context.strokeStyle = Style.Select.Title.strokeStyle
  701. this.context.fillStyle = Style.Select.Title.fillStyle
  702. } else if (draggingItem && draggingItem.type == VectorType.Title) {
  703. this.context.strokeStyle = Style.Select.Title.strokeStyle
  704. this.context.fillStyle = Style.Select.Title.fillStyle
  705. }
  706. if (focusItem && focusItem.type == VectorType.Title) {
  707. this.context.strokeStyle = Style.Focus.Title.strokeStyle
  708. this.context.fillStyle = Style.Focus.Title.fillStyle
  709. }
  710. //let pt = {}
  711. //pt.x = (this.context.canvas.width - this.context.measureText(geometry.value).width)/2
  712. this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height)
  713. this.context.restore()
  714. }
  715. drawImage(geometry){
  716. if(geometry.src != null){
  717. const pt = {
  718. x:30,
  719. y:150
  720. }
  721. this.context.save()
  722. if(geometry.image == null)
  723. {
  724. var img = new Image()
  725. img.src = geometry.src;
  726. img.crossOrigin=""
  727. img.onload = function () {
  728. this.context.drawImage(img, pt.x, pt.y, img.width, img.height)
  729. }.bind(this)
  730. geometry.image = img;
  731. }
  732. else{
  733. this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width, geometry.image.height)
  734. }
  735. this.context.restore()
  736. }
  737. }
  738. drawCompass(geometry){
  739. this.context.save()
  740. this.context.strokeStyle = Style.Compass.strokeStyle
  741. this.context.fillStyle = Style.Compass.fillStyle
  742. const selectItem = stateService.getSelectItem()
  743. const draggingItem = stateService.getDraggingItem()
  744. const focusItem = stateService.getFocusItem()
  745. if (selectItem && selectItem.type == VectorType.Compass) {
  746. if (geometry.vectorId == selectItem.vectorId) {
  747. this.context.strokeStyle = Style.Select.Compass.strokeStyle
  748. this.context.fillStyle = Style.Select.Compass.fillStyle
  749. }
  750. } else if (draggingItem && draggingItem.type == VectorType.Compass) {
  751. if (geometry.vectorId == draggingItem.vectorId) {
  752. this.context.strokeStyle = Style.Select.Compass.strokeStyle
  753. this.context.fillStyle = Style.Select.Compass.fillStyle
  754. }
  755. }
  756. if (focusItem && focusItem.type == VectorType.Compass) {
  757. if (geometry.vectorId == focusItem.vectorId) {
  758. this.context.strokeStyle = Style.Focus.Compass.strokeStyle
  759. this.context.fillStyle = Style.Focus.Compass.fillStyle
  760. }
  761. }
  762. this.context.translate(geometry.center.x,geometry.center.y)
  763. this.context.rotate((geometry.angle)/180 * Math.PI)
  764. if(geometry.angle == 90){
  765. this.context.translate( 32/2, -52)
  766. }
  767. else if(geometry.angle == 180){
  768. this.context.translate( -32, -52)
  769. }
  770. else if(geometry.angle == 270){
  771. this.context.translate( -52, -32/2)
  772. }
  773. this.context.lineWidth = 1
  774. this.context.miterLimit=4;
  775. this.context.font="15px ''";
  776. this.context.beginPath();
  777. this.context.moveTo(12.5221,3.262);
  778. this.context.lineTo(8.93807,3.262);
  779. this.context.lineTo(8.93807,4.284);
  780. this.context.lineTo(12.5221,4.284);
  781. this.context.lineTo(12.5221,8.204);
  782. this.context.bezierCurveTo(11.0241,8.778,9.54007,9.352,8.51807,9.688);
  783. this.context.lineTo(8.99407,10.724);
  784. this.context.bezierCurveTo(10.0021,10.304,11.2761,9.786,12.5221,9.24);
  785. this.context.lineTo(12.5221,12.334);
  786. this.context.lineTo(13.5861,12.334);
  787. this.context.lineTo(13.5861,0);
  788. this.context.lineTo(12.5221,0);
  789. this.context.lineTo(12.5221,3.262);
  790. this.context.closePath();
  791. this.context.moveTo(17.6881,11.13);
  792. this.context.bezierCurveTo(17.0721,11.13,16.9601,11.004,16.9601,10.29);
  793. this.context.lineTo(16.9601,5.726);
  794. this.context.bezierCurveTo(18.4581,4.9,20.0821,3.934,21.2581,2.982);
  795. this.context.lineTo(20.4181,2.114);
  796. this.context.bezierCurveTo(19.5781,2.912,18.2621,3.85,16.9601,4.648);
  797. this.context.lineTo(16.9601,0);
  798. this.context.lineTo(15.8961,0);
  799. this.context.lineTo(15.8961,10.276);
  800. this.context.bezierCurveTo(15.8961,11.746,16.2741,12.152,17.5901,12.152);
  801. this.context.lineTo(19.7741,12.152);
  802. this.context.bezierCurveTo(21.1321,12.152,21.4261,11.27,21.5521,8.722);
  803. this.context.bezierCurveTo(21.2581,8.652,20.8241,8.442,20.5441,8.232);
  804. this.context.bezierCurveTo(20.4461,10.556,20.3481,11.13,19.6901,11.13);
  805. this.context.lineTo(17.6881,11.13);
  806. this.context.closePath();
  807. this.context.fill();
  808. this.context.stroke();
  809. this.context.beginPath();
  810. this.context.moveTo(24.8494,49.3321);
  811. this.context.lineTo(28.7452,51);
  812. this.context.lineTo(27.3498,47.2775);
  813. this.context.bezierCurveTo(30.224,44.385,32,40.3999,32,36);
  814. this.context.bezierCurveTo(32,27.5465,25.4442,20.6242,17.1394,20.0399);
  815. this.context.lineTo(15.9998,17);
  816. this.context.lineTo(14.8602,20.04);
  817. this.context.bezierCurveTo(6.55559,20.6245,0,27.5467,0,36);
  818. this.context.bezierCurveTo(0,40.3998,1.77588,44.3847,4.64993,47.2772);
  819. this.context.lineTo(3.25439,51);
  820. this.context.lineTo(7.15046,49.3319);
  821. this.context.bezierCurveTo(9.68503,51.0177,12.7278,52,16,52);
  822. this.context.bezierCurveTo(19.2721,52,22.3148,51.0178,24.8494,49.3321);
  823. this.context.closePath();
  824. this.context.moveTo(26.5656,45.1856);
  825. this.context.lineTo(17.9232,22.131);
  826. this.context.bezierCurveTo(24.7452,23.0683,30,28.9205,30,36);
  827. this.context.bezierCurveTo(30,39.5148,28.7048,42.7271,26.5656,45.1856);
  828. this.context.closePath();
  829. this.context.moveTo(14.0763,22.1311);
  830. this.context.lineTo(5.43414,45.1852);
  831. this.context.bezierCurveTo(3.29512,42.7268,2,39.5146,2,36);
  832. this.context.bezierCurveTo(2,28.9206,7.25457,23.0685,14.0763,22.1311);
  833. this.context.closePath();
  834. this.context.moveTo(7.43459,47.0749);
  835. this.context.bezierCurveTo(7.28407,46.9583,7.13599,46.8387,6.99045,46.7162);
  836. this.context.lineTo(15,25.3497);
  837. this.context.lineTo(15,43.8358);
  838. this.context.lineTo(7.43459,47.0749);
  839. this.context.closePath();
  840. this.context.moveTo(9.4198,48.3604);
  841. this.context.lineTo(15.9998,45.5432);
  842. this.context.lineTo(22.58,48.3605);
  843. this.context.bezierCurveTo(20.6184,49.4069,18.3785,50,16,50);
  844. this.context.bezierCurveTo(13.6214,50,11.3814,49.4068,9.4198,48.3604);
  845. this.context.closePath();
  846. this.context.fill();
  847. this.context.stroke();
  848. this.context.restore();
  849. }
  850. setCanvasStyle(style) {
  851. for (const key in style) {
  852. if (key != 'isFill' && key != 'isStroke') {
  853. this.context[key] = style[key]
  854. }
  855. }
  856. }
  857. /*************************************************************************************家具**********************************************************************************************/
  858. drawSign(geometry) {
  859. if (geometry.geoType == VectorType.Cigaret) {
  860. this.drawCigaret(geometry)
  861. } else if (geometry.geoType == VectorType.FirePoint) {
  862. this.drawFirePoint(geometry)
  863. } else if (geometry.geoType == VectorType.LeftFootPrint) {
  864. this.drawLeftFootPrint(geometry)
  865. } else if (geometry.geoType == VectorType.RightFootPrint) {
  866. this.drawRightFootPrint(geometry)
  867. } else if (geometry.geoType == VectorType.LeftShoePrint) {
  868. this.drawLeftShoePrint(geometry)
  869. } else if (geometry.geoType == VectorType.RightShoePrint) {
  870. this.drawRightShoePrint(geometry)
  871. } else if (geometry.geoType == VectorType.FingerPrint) {
  872. this.drawFingerPrint(geometry)
  873. } else if (geometry.geoType == VectorType.DeadBody) {
  874. this.drawDeadBody(geometry)
  875. } else if (geometry.geoType == VectorType.BloodStain) {
  876. this.drawBloodStain(geometry)
  877. }
  878. }
  879. drawCigaret(geometry) {
  880. const selectItem = stateService.getSelectItem()
  881. const draggingItem = stateService.getDraggingItem()
  882. const focusItem = stateService.getFocusItem()
  883. this.context.save()
  884. this.context.strokeStyle = Style.Sign.strokeStyle
  885. this.context.fillStyle = Style.Sign.fillStyle
  886. if (selectItem && selectItem.type == VectorType.Cigaret) {
  887. if (geometry.vectorId == selectItem.vectorId) {
  888. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  889. this.context.fillStyle = Style.Select.Sign.fillStyle
  890. }
  891. } else if (draggingItem && draggingItem.type == VectorType.Cigaret) {
  892. if (geometry.vectorId == draggingItem.vectorId) {
  893. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  894. this.context.fillStyle = Style.Select.Sign.fillStyle
  895. }
  896. }
  897. if (focusItem && focusItem.type == VectorType.Cigaret) {
  898. if (geometry.vectorId == focusItem.vectorId) {
  899. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  900. this.context.fillStyle = Style.Focus.Sign.fillStyle
  901. }
  902. }
  903. const center = coordinate.getScreenXY({
  904. x: geometry.center.x,
  905. y: geometry.center.y,
  906. })
  907. const pt = coordinate.getScreenXY({
  908. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  909. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  910. })
  911. this.context.translate(center.x, center.y)
  912. this.context.rotate((geometry.angle / 180) * Math.PI)
  913. this.context.translate(pt.x - center.x, pt.y - center.y)
  914. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  915. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  916. this.context.miterLimit = 4
  917. this.context.font = "15px ''"
  918. this.context.beginPath();
  919. this.context.moveTo(38.6342,4);
  920. this.context.bezierCurveTo(38.6342,4,41.1545,9.5,39.1546,12.5);
  921. this.context.bezierCurveTo(37.1547,15.5,39.1546,19,39.1546,19);
  922. this.context.bezierCurveTo(36.0776,15.923,34.9395,14,37.1547,10.5);
  923. this.context.bezierCurveTo(39.3699,7,38.6342,4,38.6342,4);
  924. this.context.closePath();
  925. this.context.fill();
  926. this.context.stroke();
  927. this.context.beginPath();
  928. this.context.moveTo(4,29);
  929. this.context.bezierCurveTo(2.89543,29,2,29.8954,2,31);
  930. this.context.lineTo(2,39);
  931. this.context.bezierCurveTo(2,40.1046,2.89543,41,4,41);
  932. this.context.lineTo(34,41);
  933. this.context.lineTo(34,29);
  934. this.context.lineTo(4,29);
  935. this.context.closePath();
  936. this.context.fill();
  937. this.context.stroke();
  938. this.context.beginPath();
  939. this.context.moveTo(40.7714,20.5);
  940. this.context.bezierCurveTo(38.7716,17.5,41.2918,12,41.2918,12);
  941. this.context.bezierCurveTo(41.2918,12,40.5561,15,42.7713,18.5);
  942. this.context.bezierCurveTo(44.9866,22,43.8485,23.923,40.7714,27);
  943. this.context.bezierCurveTo(40.7714,27,42.7713,23.5,40.7714,20.5);
  944. this.context.closePath();
  945. this.context.fill();
  946. this.context.stroke();
  947. this.context.beginPath();
  948. this.context.moveTo(37.5,29);
  949. this.context.bezierCurveTo(36.6716,29,36,29.6716,36,30.5);
  950. this.context.lineTo(36,39.5);
  951. this.context.bezierCurveTo(36,40.3284,36.6716,41,37.5,41);
  952. this.context.bezierCurveTo(38.3284,41,39,40.3284,39,39.5);
  953. this.context.lineTo(39,30.5);
  954. this.context.bezierCurveTo(39,29.6716,38.3284,29,37.5,29);
  955. this.context.closePath();
  956. this.context.fill();
  957. this.context.stroke();
  958. this.context.beginPath();
  959. this.context.moveTo(42,29);
  960. this.context.bezierCurveTo(41.1716,29,40.5,29.6716,40.5,30.5);
  961. this.context.lineTo(40.5,39.5);
  962. this.context.bezierCurveTo(40.5,40.3284,41.1716,41,42,41);
  963. this.context.bezierCurveTo(42.8284,41,43.5,40.3284,43.5,39.5);
  964. this.context.lineTo(43.5,30.5);
  965. this.context.bezierCurveTo(43.5,29.6716,42.8284,29,42,29);
  966. this.context.closePath();
  967. this.context.fill();
  968. this.context.stroke();
  969. this.context.restore();
  970. }
  971. drawFirePoint(geometry) {
  972. const selectItem = stateService.getSelectItem()
  973. const draggingItem = stateService.getDraggingItem()
  974. const focusItem = stateService.getFocusItem()
  975. this.context.save()
  976. this.context.strokeStyle = Style.Sign.strokeStyle
  977. this.context.fillStyle = Style.Sign.fillStyle
  978. if (selectItem && selectItem.type == VectorType.FirePoint) {
  979. if (geometry.vectorId == selectItem.vectorId) {
  980. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  981. this.context.fillStyle = Style.Select.Sign.fillStyle
  982. }
  983. } else if (draggingItem && draggingItem.type == VectorType.FirePoint) {
  984. if (geometry.vectorId == draggingItem.vectorId) {
  985. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  986. this.context.fillStyle = Style.Select.Sign.fillStyle
  987. }
  988. }
  989. if (focusItem && focusItem.type == VectorType.FirePoint) {
  990. if (geometry.vectorId == focusItem.vectorId) {
  991. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  992. this.context.fillStyle = Style.Focus.Sign.fillStyle
  993. }
  994. }
  995. const center = coordinate.getScreenXY({
  996. x: geometry.center.x,
  997. y: geometry.center.y,
  998. })
  999. const pt = coordinate.getScreenXY({
  1000. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1001. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1002. })
  1003. this.context.translate(center.x, center.y)
  1004. this.context.rotate((geometry.angle / 180) * Math.PI)
  1005. this.context.translate(pt.x - center.x, pt.y - center.y)
  1006. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1007. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
  1008. this.context.strokeStyle="rgba(0,0,0,0)";
  1009. this.context.miterLimit=4;
  1010. this.context.font="15px ''";
  1011. this.context.fillStyle="#FF4D4F";
  1012. this.context.beginPath();
  1013. this.context.moveTo(6.15863,28.8837);
  1014. this.context.bezierCurveTo(4.84988,35.4972,11.9564,43.3721,15.8216,45);
  1015. this.context.bezierCurveTo(15.8216,45,13.2504,38.8,14.8553,34.7442);
  1016. this.context.bezierCurveTo(16.7879,29.8605,19.6868,25.9535,19.6868,25.9535);
  1017. this.context.bezierCurveTo(19.6868,25.9535,20.1699,26.9302,20.6531,28.8837);
  1018. this.context.bezierCurveTo(21.1363,30.8372,21.1363,31.3256,21.1363,31.3256);
  1019. this.context.bezierCurveTo(21.1363,31.3256,22.9249,29.2771,23.5519,27.4186);
  1020. this.context.bezierCurveTo(24.4676,24.7049,24.0351,20.093,24.0351,20.093);
  1021. this.context.bezierCurveTo(24.0351,20.093,29.8166,25.9798,31.2823,30.8372);
  1022. this.context.bezierCurveTo(32.8795,36.1307,30.7991,45,30.7991,45);
  1023. this.context.bezierCurveTo(30.7991,45,40.7338,38.6512,41.9116,29.8605);
  1024. this.context.bezierCurveTo(42.9992,21.7424,33.698,11.3023,33.698,11.3023);
  1025. this.context.bezierCurveTo(33.698,11.3023,34.148,13.8357,33.698,15.6977);
  1026. this.context.bezierCurveTo(33.3976,16.9405,32.2486,18.6279,32.2486,18.6279);
  1027. this.context.bezierCurveTo(32.2486,18.6279,30.7991,13.884,27.9004,9.83721);
  1028. this.context.bezierCurveTo(25.5478,6.55294,20.6531,3,20.6531,3);
  1029. this.context.bezierCurveTo(20.6531,3,20.6531,9.34884,19.2037,13.7442);
  1030. this.context.bezierCurveTo(17.7542,18.1395,12.9227,22.5349,12.9227,22.5349);
  1031. this.context.lineTo(11.4733,15.2093);
  1032. this.context.bezierCurveTo(10.0238,17.9767,7.12508,24,6.15863,28.8837);
  1033. this.context.closePath();
  1034. this.context.fill();
  1035. this.context.stroke();
  1036. this.context.restore();
  1037. }
  1038. drawLeftFootPrint(geometry) {
  1039. const selectItem = stateService.getSelectItem()
  1040. const draggingItem = stateService.getDraggingItem()
  1041. const focusItem = stateService.getFocusItem()
  1042. this.context.save()
  1043. this.context.strokeStyle = Style.Sign.strokeStyle
  1044. this.context.fillStyle = Style.Sign.fillStyle
  1045. if (selectItem && selectItem.type == VectorType.LeftFootPrint) {
  1046. if (geometry.vectorId == selectItem.vectorId) {
  1047. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1048. this.context.fillStyle = Style.Select.Sign.fillStyle
  1049. }
  1050. } else if (draggingItem && draggingItem.type == VectorType.LeftFootPrint) {
  1051. if (geometry.vectorId == draggingItem.vectorId) {
  1052. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1053. this.context.fillStyle = Style.Select.Sign.fillStyle
  1054. }
  1055. }
  1056. if (focusItem && focusItem.type == VectorType.LeftFootPrint) {
  1057. if (geometry.vectorId == focusItem.vectorId) {
  1058. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1059. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1060. }
  1061. }
  1062. const center = coordinate.getScreenXY({
  1063. x: geometry.center.x,
  1064. y: geometry.center.y,
  1065. })
  1066. const pt = coordinate.getScreenXY({
  1067. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1068. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1069. })
  1070. this.context.translate(center.x, center.y)
  1071. this.context.rotate((geometry.angle / 180) * Math.PI)
  1072. this.context.translate(pt.x - center.x, pt.y - center.y)
  1073. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1074. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1075. this.context.strokeStyle="rgba(0,0,0,0)";
  1076. this.context.miterLimit=4;
  1077. this.context.font="15px ''";
  1078. this.context.fillStyle="black";
  1079. this.context.beginPath();
  1080. this.context.moveTo(26.5,7);
  1081. this.context.bezierCurveTo(25.1193,7,24,5.88071,24,4.5);
  1082. this.context.bezierCurveTo(24,3.11929,25.1193,2,26.5,2);
  1083. this.context.bezierCurveTo(27.8807,2,29,3.11929,29,4.5);
  1084. this.context.bezierCurveTo(29,5.88071,27.8807,7,26.5,7);
  1085. this.context.closePath();
  1086. this.context.fill();
  1087. this.context.stroke();
  1088. this.context.beginPath();
  1089. this.context.moveTo(32,12);
  1090. this.context.bezierCurveTo(30.3431,12,29,10.6569,29,9);
  1091. this.context.bezierCurveTo(29,7.34315,30.3431,6,32,6);
  1092. this.context.bezierCurveTo(33.6569,6,35,7.34315,35,9);
  1093. this.context.bezierCurveTo(35,10.6569,33.6569,12,32,12);
  1094. this.context.closePath();
  1095. this.context.fill();
  1096. this.context.stroke();
  1097. this.context.beginPath();
  1098. this.context.moveTo(18,5);
  1099. this.context.bezierCurveTo(18,6.10457,18.8954,7,20,7);
  1100. this.context.bezierCurveTo(21.1046,7,22,6.10457,22,5);
  1101. this.context.bezierCurveTo(22,3.89543,21.1046,3,20,3);
  1102. this.context.bezierCurveTo(18.8954,3,18,3.89543,18,5);
  1103. this.context.closePath();
  1104. this.context.fill();
  1105. this.context.stroke();
  1106. this.context.beginPath();
  1107. this.context.moveTo(15,10);
  1108. this.context.bezierCurveTo(13.8954,10,13,9.10457,13,8);
  1109. this.context.bezierCurveTo(13,6.89543,13.8954,6,15,6);
  1110. this.context.bezierCurveTo(16.1046,6,17,6.89543,17,8);
  1111. this.context.bezierCurveTo(17,9.10457,16.1046,10,15,10);
  1112. this.context.closePath();
  1113. this.context.fill();
  1114. this.context.stroke();
  1115. this.context.beginPath();
  1116. this.context.moveTo(10,12.5);
  1117. this.context.bezierCurveTo(10,13.3284,10.6716,14,11.5,14);
  1118. this.context.bezierCurveTo(12.3284,14,13,13.3284,13,12.5);
  1119. this.context.bezierCurveTo(13,11.6716,12.3284,11,11.5,11);
  1120. this.context.bezierCurveTo(10.6716,11,10,11.6716,10,12.5);
  1121. this.context.closePath();
  1122. this.context.fill();
  1123. this.context.stroke();
  1124. this.context.beginPath();
  1125. this.context.moveTo(29.0721,31.5068);
  1126. this.context.bezierCurveTo(29.0721,31.5068,28.037,29.0085,29.0721,27.2243);
  1127. this.context.bezierCurveTo(30.1072,25.4402,30.9125,23.8936,31.6392,20.6224);
  1128. this.context.bezierCurveTo(32.3658,17.3511,30.3143,9.73826,22.1998,10.0059);
  1129. this.context.bezierCurveTo(14.0852,10.2735,13.2572,17.4108,13.0088,21.4254);
  1130. this.context.bezierCurveTo(12.7604,25.44,17.8113,38.0193,21.4544,42.1233);
  1131. this.context.bezierCurveTo(25.0975,46.2273,27.6647,46.5838,29.9831,45.424);
  1132. this.context.bezierCurveTo(32.3016,44.2642,33.3778,42.5692,32.881,40.4282);
  1133. this.context.bezierCurveTo(32.3842,38.2873,29.0721,31.5068,29.0721,31.5068);
  1134. this.context.closePath();
  1135. this.context.fill();
  1136. this.context.stroke();
  1137. this.context.restore();
  1138. }
  1139. drawRightFootPrint(geometry) {
  1140. const selectItem = stateService.getSelectItem()
  1141. const draggingItem = stateService.getDraggingItem()
  1142. const focusItem = stateService.getFocusItem()
  1143. this.context.save()
  1144. this.context.strokeStyle = Style.Sign.strokeStyle
  1145. this.context.fillStyle = Style.Sign.fillStyle
  1146. if (selectItem && selectItem.type == VectorType.RightFootPrint) {
  1147. if (geometry.vectorId == selectItem.vectorId) {
  1148. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1149. this.context.fillStyle = Style.Select.Sign.fillStyle
  1150. }
  1151. } else if (draggingItem && draggingItem.type == VectorType.RightFootPrint) {
  1152. if (geometry.vectorId == draggingItem.vectorId) {
  1153. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1154. this.context.fillStyle = Style.Select.Sign.fillStyle
  1155. }
  1156. }
  1157. if (focusItem && focusItem.type == VectorType.RightFootPrint) {
  1158. if (geometry.vectorId == focusItem.vectorId) {
  1159. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1160. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1161. }
  1162. }
  1163. const center = coordinate.getScreenXY({
  1164. x: geometry.center.x,
  1165. y: geometry.center.y,
  1166. })
  1167. const pt = coordinate.getScreenXY({
  1168. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1169. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1170. })
  1171. this.context.translate(center.x, center.y)
  1172. this.context.rotate((geometry.angle / 180) * Math.PI)
  1173. this.context.translate(pt.x - center.x, pt.y - center.y)
  1174. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1175. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1176. this.context.strokeStyle="rgba(0,0,0,0)";
  1177. this.context.miterLimit=4;
  1178. this.context.font="15px ''";
  1179. this.context.fillStyle="black";
  1180. this.context.beginPath();
  1181. this.context.moveTo(18.5,7);
  1182. this.context.bezierCurveTo(19.8807,7,21,5.88071,21,4.5);
  1183. this.context.bezierCurveTo(21,3.11929,19.8807,2,18.5,2);
  1184. this.context.bezierCurveTo(17.1193,2,16,3.11929,16,4.5);
  1185. this.context.bezierCurveTo(16,5.88071,17.1193,7,18.5,7);
  1186. this.context.closePath();
  1187. this.context.fill();
  1188. this.context.stroke();
  1189. this.context.beginPath();
  1190. this.context.moveTo(13,12);
  1191. this.context.bezierCurveTo(14.6569,12,16,10.6569,16,9);
  1192. this.context.bezierCurveTo(16,7.34315,14.6569,6,13,6);
  1193. this.context.bezierCurveTo(11.3431,6,10,7.34315,10,9);
  1194. this.context.bezierCurveTo(10,10.6569,11.3431,12,13,12);
  1195. this.context.closePath();
  1196. this.context.fill();
  1197. this.context.stroke();
  1198. this.context.beginPath();
  1199. this.context.moveTo(27,5);
  1200. this.context.bezierCurveTo(27,6.10457,26.1046,7,25,7);
  1201. this.context.bezierCurveTo(23.8954,7,23,6.10457,23,5);
  1202. this.context.bezierCurveTo(23,3.89543,23.8954,3,25,3);
  1203. this.context.bezierCurveTo(26.1046,3,27,3.89543,27,5);
  1204. this.context.closePath();
  1205. this.context.fill();
  1206. this.context.stroke();
  1207. this.context.beginPath();
  1208. this.context.moveTo(30,10);
  1209. this.context.bezierCurveTo(31.1046,10,32,9.10457,32,8);
  1210. this.context.bezierCurveTo(32,6.89543,31.1046,6,30,6);
  1211. this.context.bezierCurveTo(28.8954,6,28,6.89543,28,8);
  1212. this.context.bezierCurveTo(28,9.10457,28.8954,10,30,10);
  1213. this.context.closePath();
  1214. this.context.fill();
  1215. this.context.stroke();
  1216. this.context.beginPath();
  1217. this.context.moveTo(35,12.5);
  1218. this.context.bezierCurveTo(35,13.3284,34.3284,14,33.5,14);
  1219. this.context.bezierCurveTo(32.6716,14,32,13.3284,32,12.5);
  1220. this.context.bezierCurveTo(32,11.6716,32.6716,11,33.5,11);
  1221. this.context.bezierCurveTo(34.3284,11,35,11.6716,35,12.5);
  1222. this.context.closePath();
  1223. this.context.fill();
  1224. this.context.stroke();
  1225. this.context.beginPath();
  1226. this.context.moveTo(15.9279,31.5068);
  1227. this.context.bezierCurveTo(15.9279,31.5068,16.963,29.0085,15.9279,27.2243);
  1228. this.context.bezierCurveTo(14.8928,25.4402,14.0875,23.8936,13.3608,20.6224);
  1229. this.context.bezierCurveTo(12.6342,17.3511,14.6857,9.73826,22.8002,10.0059);
  1230. this.context.bezierCurveTo(30.9148,10.2735,31.7428,17.4108,31.9912,21.4254);
  1231. this.context.bezierCurveTo(32.2396,25.44,27.1887,38.0193,23.5456,42.1233);
  1232. this.context.bezierCurveTo(19.9025,46.2273,17.3353,46.5838,15.0169,45.424);
  1233. this.context.bezierCurveTo(12.6984,44.2642,11.6222,42.5692,12.119,40.4282);
  1234. this.context.bezierCurveTo(12.6158,38.2873,15.9279,31.5068,15.9279,31.5068);
  1235. this.context.closePath();
  1236. this.context.fill();
  1237. this.context.stroke();
  1238. this.context.restore();
  1239. }
  1240. drawLeftShoePrint(geometry) {
  1241. const selectItem = stateService.getSelectItem()
  1242. const draggingItem = stateService.getDraggingItem()
  1243. const focusItem = stateService.getFocusItem()
  1244. this.context.save()
  1245. this.context.strokeStyle = Style.Sign.strokeStyle
  1246. this.context.fillStyle = Style.Sign.fillStyle
  1247. if (selectItem && selectItem.type == VectorType.LeftShoePrint) {
  1248. if (geometry.vectorId == selectItem.vectorId) {
  1249. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1250. this.context.fillStyle = Style.Select.Sign.fillStyle
  1251. }
  1252. } else if (draggingItem && draggingItem.type == VectorType.LeftShoePrint) {
  1253. if (geometry.vectorId == draggingItem.vectorId) {
  1254. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1255. this.context.fillStyle = Style.Select.Sign.fillStyle
  1256. }
  1257. }
  1258. if (focusItem && focusItem.type == VectorType.LeftShoePrint) {
  1259. if (geometry.vectorId == focusItem.vectorId) {
  1260. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1261. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1262. }
  1263. }
  1264. const center = coordinate.getScreenXY({
  1265. x: geometry.center.x,
  1266. y: geometry.center.y,
  1267. })
  1268. const pt = coordinate.getScreenXY({
  1269. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1270. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1271. })
  1272. this.context.translate(center.x, center.y)
  1273. this.context.rotate((geometry.angle / 180) * Math.PI)
  1274. this.context.translate(pt.x - center.x, pt.y - center.y)
  1275. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1276. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1277. this.context.strokeStyle="rgba(0,0,0,0)";
  1278. this.context.miterLimit=4;
  1279. this.context.fillStyle="black";
  1280. this.context.font=" 15px ''";
  1281. this.context.beginPath();
  1282. this.context.moveTo(29.9064,30.2635);
  1283. this.context.lineTo(18.3897,31.999);
  1284. this.context.bezierCurveTo(18.3897,31.999,14,24.0766,14,18.5101);
  1285. this.context.bezierCurveTo(14,9.43774,16.8732,1.75238,22.3803,2.00508);
  1286. this.context.bezierCurveTo(28.3968,2.28117,31,9.00467,31,15.3264);
  1287. this.context.bezierCurveTo(31,18.8919,30.7015,20.0653,29.9867,22.8753);
  1288. this.context.bezierCurveTo(29.7961,23.6244,29.5759,24.4898,29.3239,25.5478);
  1289. this.context.bezierCurveTo(28.9957,26.926,29.9064,30.2635,29.9064,30.2635);
  1290. this.context.closePath();
  1291. this.context.fill();
  1292. this.context.stroke();
  1293. this.context.beginPath();
  1294. this.context.moveTo(30.5,34);
  1295. this.context.lineTo(19,35.4383);
  1296. this.context.bezierCurveTo(19,35.4383,19.316,39.7531,19.8057,42.3198);
  1297. this.context.bezierCurveTo(20.2953,44.8865,22.9828,46.465,26.2418,45.8773);
  1298. this.context.bezierCurveTo(29.5007,45.2895,32.4426,43.1091,31.9447,40.287);
  1299. this.context.bezierCurveTo(31.4469,37.4649,30.5,34,30.5,34);
  1300. this.context.closePath();
  1301. this.context.fill();
  1302. this.context.stroke();
  1303. this.context.restore();
  1304. }
  1305. drawRightShoePrint(geometry) {
  1306. const selectItem = stateService.getSelectItem()
  1307. const draggingItem = stateService.getDraggingItem()
  1308. const focusItem = stateService.getFocusItem()
  1309. this.context.save()
  1310. this.context.strokeStyle = Style.Sign.strokeStyle
  1311. this.context.fillStyle = Style.Sign.fillStyle
  1312. if (selectItem && selectItem.type == VectorType.RightShoePrint) {
  1313. if (geometry.vectorId == selectItem.vectorId) {
  1314. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1315. this.context.fillStyle = Style.Select.Sign.fillStyle
  1316. }
  1317. } else if (draggingItem && draggingItem.type == VectorType.RightShoePrint) {
  1318. if (geometry.vectorId == draggingItem.vectorId) {
  1319. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1320. this.context.fillStyle = Style.Select.Sign.fillStyle
  1321. }
  1322. }
  1323. if (focusItem && focusItem.type == VectorType.RightShoePrint) {
  1324. if (geometry.vectorId == focusItem.vectorId) {
  1325. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1326. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1327. }
  1328. }
  1329. const center = coordinate.getScreenXY({
  1330. x: geometry.center.x,
  1331. y: geometry.center.y,
  1332. })
  1333. const pt = coordinate.getScreenXY({
  1334. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1335. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1336. })
  1337. this.context.translate(center.x, center.y)
  1338. this.context.rotate((geometry.angle / 180) * Math.PI)
  1339. this.context.translate(pt.x - center.x, pt.y - center.y)
  1340. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1341. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1342. this.context.strokeStyle="rgba(0,0,0,0)";
  1343. this.context.miterLimit=4;
  1344. this.context.font="15px ''";
  1345. this.context.fillStyle="black";
  1346. this.context.beginPath();
  1347. this.context.moveTo(16.0936,30.2635);
  1348. this.context.lineTo(27.6103,31.999);
  1349. this.context.bezierCurveTo(27.6103,31.999,32,24.0766,32,18.5101);
  1350. this.context.bezierCurveTo(32,9.43774,29.1268,1.75238,23.6197,2.00508);
  1351. this.context.bezierCurveTo(17.6032,2.28117,15,9.00467,15,15.3264);
  1352. this.context.bezierCurveTo(15,18.8919,15.2985,20.0653,16.0133,22.8753);
  1353. this.context.bezierCurveTo(16.2039,23.6244,16.4241,24.4898,16.6761,25.5478);
  1354. this.context.bezierCurveTo(17.0043,26.926,16.0936,30.2635,16.0936,30.2635);
  1355. this.context.closePath();
  1356. this.context.fill();
  1357. this.context.stroke();
  1358. this.context.beginPath();
  1359. this.context.moveTo(15.5,34);
  1360. this.context.lineTo(27,35.4383);
  1361. this.context.bezierCurveTo(27,35.4383,26.684,39.7531,26.1943,42.3198);
  1362. this.context.bezierCurveTo(25.7047,44.8865,23.0172,46.465,19.7582,45.8773);
  1363. this.context.bezierCurveTo(16.4993,45.2895,13.5574,43.1091,14.0553,40.287);
  1364. this.context.bezierCurveTo(14.5531,37.4649,15.5,34,15.5,34);
  1365. this.context.closePath();
  1366. this.context.fill();
  1367. this.context.stroke();
  1368. this.context.restore();
  1369. }
  1370. drawFingerPrint(geometry) {
  1371. const selectItem = stateService.getSelectItem()
  1372. const draggingItem = stateService.getDraggingItem()
  1373. const focusItem = stateService.getFocusItem()
  1374. this.context.save()
  1375. this.context.strokeStyle = Style.Sign.strokeStyle
  1376. this.context.fillStyle = Style.Sign.fillStyle
  1377. if (selectItem && selectItem.type == VectorType.FingerPrint) {
  1378. if (geometry.vectorId == selectItem.vectorId) {
  1379. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1380. this.context.fillStyle = Style.Select.Sign.fillStyle
  1381. }
  1382. } else if (draggingItem && draggingItem.type == VectorType.FingerPrint) {
  1383. if (geometry.vectorId == draggingItem.vectorId) {
  1384. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1385. this.context.fillStyle = Style.Select.Sign.fillStyle
  1386. }
  1387. }
  1388. if (focusItem && focusItem.type == VectorType.FingerPrint) {
  1389. if (geometry.vectorId == focusItem.vectorId) {
  1390. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1391. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1392. }
  1393. }
  1394. const center = coordinate.getScreenXY({
  1395. x: geometry.center.x,
  1396. y: geometry.center.y,
  1397. })
  1398. const pt = coordinate.getScreenXY({
  1399. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1400. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1401. })
  1402. this.context.translate(center.x, center.y)
  1403. this.context.rotate((geometry.angle / 180) * Math.PI)
  1404. this.context.translate(pt.x - center.x, pt.y - center.y)
  1405. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1406. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1407. this.context.strokeStyle="rgba(0,0,0,0)";
  1408. this.context.miterLimit=4;
  1409. this.context.font="15px ''";
  1410. this.context.fillStyle="black";
  1411. this.context.beginPath();
  1412. this.context.moveTo(43.4999,21.5);
  1413. this.context.bezierCurveTo(43.4999,16.542,39.7109,10.8816,34.1276,7.63537);
  1414. this.context.bezierCurveTo(28.4657,4.34348,20.8249,3.43868,12.9856,8.14233);
  1415. this.context.bezierCurveTo(6.24753,12.1852,4.43294,18.9936,4.70686,25.2575);
  1416. this.context.bezierCurveTo(4.97928,31.4873,7.31395,37.4063,9.18082,40.0733);
  1417. this.context.bezierCurveTo(9.49752,40.5258,10.121,40.6358,10.5735,40.3191);
  1418. this.context.bezierCurveTo(11.026,40.0024,11.136,39.3789,10.8193,38.9265);
  1419. this.context.bezierCurveTo(9.18619,36.5933,6.96197,31.0477,6.70495,25.1701);
  1420. this.context.bezierCurveTo(6.44942,19.3268,8.13483,13.3852,14.0146,9.85731);
  1421. this.context.bezierCurveTo(21.1752,5.56085,28.0343,6.40615,33.1223,9.36438);
  1422. this.context.bezierCurveTo(38.289,12.3683,41.4999,17.458,41.4999,21.5);
  1423. this.context.bezierCurveTo(41.4999,24.6008,40.785,26.4882,39.8962,27.6385);
  1424. this.context.bezierCurveTo(39.0131,28.7814,37.8743,29.3053,36.8039,29.5194);
  1425. this.context.bezierCurveTo(33.9357,30.0933,31.4302,27.9399,30.9899,24.8585);
  1426. this.context.bezierCurveTo(30.438,20.9948,27.6176,17.4999,23,17.4999);
  1427. this.context.bezierCurveTo(20.6398,17.4999,18.5331,18.6977,17.4181,20.9277);
  1428. this.context.bezierCurveTo(16.3192,23.1255,16.2513,26.1767,17.5583,29.8362);
  1429. this.context.bezierCurveTo(18.5365,32.5753,20.7176,35.1665,22.999,37.2483);
  1430. this.context.bezierCurveTo(25.2933,39.3417,27.7947,41.0153,29.5528,41.8943);
  1431. this.context.bezierCurveTo(30.0468,42.1413,30.6474,41.9411,30.8944,41.4471);
  1432. this.context.bezierCurveTo(31.1414,40.9531,30.9412,40.3525,30.4472,40.1055);
  1433. this.context.bezierCurveTo(28.8719,39.3178,26.5208,37.7543,24.3471,35.7709);
  1434. this.context.bezierCurveTo(22.1606,33.7757,20.2584,31.4503,19.4417,29.1636);
  1435. this.context.bezierCurveTo(18.2488,25.8233,18.4309,23.3744,19.207,21.8222);
  1436. this.context.bezierCurveTo(19.9669,20.3022,21.3602,19.4999,23,19.4999);
  1437. this.context.bezierCurveTo(26.3823,19.4999,28.562,22.0051,29.01,25.1413);
  1438. this.context.bezierCurveTo(29.5699,29.0599,32.9258,32.3349,37.1962,31.4806);
  1439. this.context.bezierCurveTo(38.6259,31.1946,40.237,30.4684,41.4788,28.8614);
  1440. this.context.bezierCurveTo(42.7149,27.2617,43.4999,24.8992,43.4999,21.5);
  1441. this.context.closePath();
  1442. this.context.fill();
  1443. this.context.stroke();
  1444. this.context.beginPath();
  1445. this.context.moveTo(28.3137,13.9002);
  1446. this.context.bezierCurveTo(24.531,12.0661,19.8915,12.2936,16.2281,16.1858);
  1447. this.context.bezierCurveTo(12.5481,20.0959,12.3111,24.8487,13.7047,29.4641);
  1448. this.context.bezierCurveTo(15.1069,34.1077,18.1345,38.4781,20.738,41.3257);
  1449. this.context.bezierCurveTo(21.1106,41.7333,21.0823,42.3658,20.6747,42.7385);
  1450. this.context.bezierCurveTo(20.2671,43.1112,19.6346,43.0828,19.2619,42.6752);
  1451. this.context.bezierCurveTo(16.5321,39.6895,13.3063,35.0635,11.7901,30.0422);
  1452. this.context.bezierCurveTo(10.2654,24.9927,10.445,19.4122,14.7717,14.8151);
  1453. this.context.bezierCurveTo(19.1085,10.2073,24.719,9.93463,29.1863,12.1005);
  1454. this.context.bezierCurveTo(33.601,14.241,36.9999,18.8096,36.9999,24.0005);
  1455. this.context.bezierCurveTo(36.9999,24.5528,36.5522,25.0005,35.9999,25.0005);
  1456. this.context.bezierCurveTo(35.4477,25.0005,34.9999,24.5528,34.9999,24.0005);
  1457. this.context.bezierCurveTo(34.9999,19.6911,32.1489,15.7597,28.3137,13.9002);
  1458. this.context.closePath();
  1459. this.context.fill();
  1460. this.context.stroke();
  1461. this.context.beginPath();
  1462. this.context.moveTo(23.3825,24.507);
  1463. this.context.bezierCurveTo(23.93,24.4422,24.4265,24.8327,24.4928,25.3797);
  1464. this.context.lineTo(24.493,25.381);
  1465. this.context.bezierCurveTo(24.493,25.3814,24.4932,25.3825,23.5001,25.5001);
  1466. this.context.lineTo(22.507,25.6177);
  1467. this.context.bezierCurveTo(22.4421,25.0693,22.834,24.572,23.3825,24.507);
  1468. this.context.closePath();
  1469. this.context.fill();
  1470. this.context.stroke();
  1471. this.context.beginPath();
  1472. this.context.moveTo(23.5001,25.5001);
  1473. this.context.lineTo(24.4932,25.3825);
  1474. this.context.lineTo(24.4934,25.3844);
  1475. this.context.lineTo(24.498,25.4166);
  1476. this.context.bezierCurveTo(24.5026,25.4479,24.5105,25.4984,24.5228,25.5664);
  1477. this.context.bezierCurveTo(24.5472,25.7024,24.5887,25.9078,24.6548,26.1683);
  1478. this.context.bezierCurveTo(24.7871,26.6901,25.0169,27.4283,25.4033,28.2707);
  1479. this.context.bezierCurveTo(26.1756,29.9543,27.5658,32.0393,30.0477,33.6633);
  1480. this.context.bezierCurveTo(32.5055,35.2717,35.0375,35.6213,36.9758,35.563);
  1481. this.context.bezierCurveTo(37.9445,35.534,38.7565,35.403,39.3219,35.2806);
  1482. this.context.bezierCurveTo(39.6041,35.2195,39.8233,35.1608,39.9682,35.1188);
  1483. this.context.bezierCurveTo(40.0407,35.0978,40.0944,35.081,40.1279,35.0701);
  1484. this.context.bezierCurveTo(40.1373,35.0671,40.1451,35.0645,40.1512,35.0625);
  1485. this.context.bezierCurveTo(40.1561,35.0609,40.16,35.0596,40.1629,35.0586);
  1486. this.context.lineTo(40.1665,35.0574);
  1487. this.context.lineTo(40.1686,35.0566);
  1488. this.context.bezierCurveTo(40.6887,34.8739,41.2588,35.1466,41.4428,35.6665);
  1489. this.context.bezierCurveTo(41.6271,36.1871,41.3544,36.7586,40.8337,36.9428);
  1490. this.context.lineTo(40.5001,36.0001);
  1491. this.context.bezierCurveTo(40.8337,36.9428,40.8342,36.9427,40.8337,36.9428);
  1492. this.context.lineTo(40.8319,36.9435);
  1493. this.context.lineTo(40.8295,36.9443);
  1494. this.context.lineTo(40.8233,36.9465);
  1495. this.context.lineTo(40.8046,36.9529);
  1496. this.context.bezierCurveTo(40.7893,36.958,40.7687,36.9649,40.7427,36.9733);
  1497. this.context.bezierCurveTo(40.6909,36.99,40.618,37.0128,40.5254,37.0396);
  1498. this.context.bezierCurveTo(40.3403,37.0933,40.0763,37.1636,39.7451,37.2353);
  1499. this.context.bezierCurveTo(39.0837,37.3785,38.1486,37.5287,37.0358,37.5621);
  1500. this.context.bezierCurveTo(34.8114,37.6289,31.8434,37.2285,28.9525,35.3369);
  1501. this.context.bezierCurveTo(26.0858,33.4609,24.476,31.0459,23.5854,29.1045);
  1502. this.context.bezierCurveTo(23.1404,28.1344,22.8731,27.2789,22.7161,26.66);
  1503. this.context.bezierCurveTo(22.6376,26.3502,22.5864,26.0986,22.5543,25.9202);
  1504. this.context.bezierCurveTo(22.5383,25.8309,22.527,25.7598,22.5195,25.7088);
  1505. this.context.bezierCurveTo(22.5157,25.6833,22.5129,25.6628,22.5108,25.6476);
  1506. this.context.lineTo(22.5084,25.6286);
  1507. this.context.lineTo(22.5076,25.6222);
  1508. this.context.lineTo(22.5073,25.6197);
  1509. this.context.lineTo(22.507,25.6177);
  1510. this.context.bezierCurveTo(22.507,25.6172,22.507,25.6177,23.5001,25.5001);
  1511. this.context.closePath();
  1512. this.context.fill();
  1513. this.context.stroke();
  1514. this.context.restore();
  1515. }
  1516. drawDeadBody(geometry) {
  1517. const selectItem = stateService.getSelectItem()
  1518. const draggingItem = stateService.getDraggingItem()
  1519. const focusItem = stateService.getFocusItem()
  1520. this.context.save()
  1521. this.context.strokeStyle = Style.Sign.strokeStyle
  1522. this.context.fillStyle = Style.Sign.fillStyle
  1523. if (selectItem && selectItem.type == VectorType.DeadBody) {
  1524. if (geometry.vectorId == selectItem.vectorId) {
  1525. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1526. this.context.fillStyle = Style.Select.Sign.fillStyle
  1527. }
  1528. } else if (draggingItem && draggingItem.type == VectorType.DeadBody) {
  1529. if (geometry.vectorId == draggingItem.vectorId) {
  1530. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1531. this.context.fillStyle = Style.Select.Sign.fillStyle
  1532. }
  1533. }
  1534. if (focusItem && focusItem.type == VectorType.DeadBody) {
  1535. if (geometry.vectorId == focusItem.vectorId) {
  1536. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1537. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1538. }
  1539. }
  1540. const center = coordinate.getScreenXY({
  1541. x: geometry.center.x,
  1542. y: geometry.center.y,
  1543. })
  1544. const pt = coordinate.getScreenXY({
  1545. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1546. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1547. })
  1548. this.context.translate(center.x, center.y)
  1549. this.context.rotate((geometry.angle / 180) * Math.PI)
  1550. this.context.translate(pt.x - center.x, pt.y - center.y)
  1551. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1552. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1553. this.context.strokeStyle="rgba(0,0,0,0)";
  1554. this.context.miterLimit=4;
  1555. this.context.font="15px ''";
  1556. this.context.fillStyle="#040101";
  1557. this.context.beginPath();
  1558. this.context.moveTo(5.91335,12.2268);
  1559. this.context.bezierCurveTo(4.35883,11.5123,3.17581,11.4098,2.00721,12.6867);
  1560. this.context.lineTo(2,13.7478);
  1561. this.context.bezierCurveTo(2.29231,15.0665,3.42071,15.5909,4.46298,16.0752);
  1562. this.context.bezierCurveTo(4.51387,16.0989,4.56455,16.1224,4.61492,16.146);
  1563. this.context.bezierCurveTo(11.3957,19.2976,16.3298,24.5608,21.2386,29.8665);
  1564. this.context.bezierCurveTo(21.9491,30.6341,21.8878,31.0197,20.7841,31.1647);
  1565. this.context.bezierCurveTo(19.2801,31.3628,18.7752,32.3001,19.0853,33.6654);
  1566. this.context.bezierCurveTo(19.5326,35.6498,20.0123,37.627,20.6327,39.5689);
  1567. this.context.bezierCurveTo(20.7153,39.9046,20.8859,40.2134,21.1276,40.4646);
  1568. this.context.bezierCurveTo(21.3692,40.7159,21.6735,40.9009,22.0104,41.0015);
  1569. this.context.lineTo(22.7318,41.0015);
  1570. this.context.bezierCurveTo(23.5253,40.5699,23.9725,39.9403,23.785,39.0313);
  1571. this.context.bezierCurveTo(23.7124,38.6795,23.6668,38.3204,23.6213,37.9616);
  1572. this.context.bezierCurveTo(23.5492,37.3932,23.4772,36.8256,23.2981,36.29);
  1573. this.context.bezierCurveTo(22.8184,34.8645,23.3702,34.5816,24.6975,34.7372);
  1574. this.context.bezierCurveTo(26.9098,34.9961,28.9508,33.7344,30.5482,32.747);
  1575. this.context.bezierCurveTo(31.0238,32.453,31.46,32.1833,31.8497,31.9853);
  1576. this.context.bezierCurveTo(32.2324,31.7909,32.6231,31.5841,33.0213,31.3734);
  1577. this.context.bezierCurveTo(34.3907,30.6486,35.848,29.8773,37.3681,29.4032);
  1578. this.context.bezierCurveTo(37.9053,29.2344,38.2276,29.511,38.5499,29.7877);
  1579. this.context.bezierCurveTo(38.6194,29.8473,38.6888,29.9069,38.7603,29.962);
  1580. this.context.bezierCurveTo(40.191,31.0821,41.6277,32.2081,43.0705,33.34);
  1581. this.context.bezierCurveTo(43.9,33.9908,44.7584,34.2986,45.5772,33.3789);
  1582. this.context.bezierCurveTo(46.3959,32.4593,45.9018,31.6634,45.1444,30.956);
  1583. this.context.bezierCurveTo(44.6458,30.494,44.1439,30.0346,43.6418,29.575);
  1584. this.context.bezierCurveTo(42.4948,28.5252,41.3468,27.4745,40.2355,26.3895);
  1585. this.context.bezierCurveTo(39.3158,25.4876,38.4213,25.0313,37.0796,25.5442);
  1586. this.context.bezierCurveTo(34.0823,26.6973,25.2493,20.2632,24.7877,18.7175);
  1587. this.context.bezierCurveTo(24.4268,17.5159,24.8984,16.0559,25.3601,14.6263);
  1588. this.context.bezierCurveTo(25.5168,14.1411,25.6724,13.6594,25.794,13.1925);
  1589. this.context.bezierCurveTo(26.1835,11.6715,25.5343,10.7589,24.1889,10.3628);
  1590. this.context.bezierCurveTo(21.4117,9.55275,18.6056,8.84533,15.796,8.13791);
  1591. this.context.bezierCurveTo(14.768,7.87969,13.7293,7.87262,13.3686,9.16721);
  1592. this.context.bezierCurveTo(13.0404,10.3522,13.6211,11.0136,14.7356,11.4133);
  1593. this.context.bezierCurveTo(16.5065,12.0535,18.263,12.7256,20.0159,13.433);
  1594. this.context.bezierCurveTo(20.0817,13.4588,20.1525,13.4826,20.2245,13.5068);
  1595. this.context.bezierCurveTo(20.6456,13.6484,21.1094,13.8043,20.8815,14.4658);
  1596. this.context.bezierCurveTo(20.4549,15.6984,20.0227,16.9292,19.5629,18.2388);
  1597. this.context.bezierCurveTo(19.3774,18.7669,19.1875,19.3079,18.9916,19.8671);
  1598. this.context.bezierCurveTo(14.9916,16.4537,10.4759,14.3208,5.91335,12.2268);
  1599. this.context.closePath();
  1600. this.context.fill();
  1601. this.context.stroke();
  1602. this.context.beginPath();
  1603. this.context.moveTo(34.7105,32.0067);
  1604. this.context.bezierCurveTo(32.6436,31.8937,31.1351,33.2167,31.0119,35.2432);
  1605. this.context.bezierCurveTo(30.9738,35.7034,31.0276,36.1666,31.17,36.6057);
  1606. this.context.bezierCurveTo(31.3124,37.0448,31.5406,37.4509,31.8411,37.8002);
  1607. this.context.bezierCurveTo(32.1417,38.1495,32.5086,38.435,32.9204,38.6399);
  1608. this.context.bezierCurveTo(33.3322,38.8448,33.7805,38.965,34.2391,38.9935);
  1609. this.context.bezierCurveTo(35.1675,39.0499,36.0808,38.7378,36.7827,38.1244);
  1610. this.context.bezierCurveTo(37.4845,37.511,37.9188,36.6452,37.9922,35.7133);
  1611. this.context.bezierCurveTo(38.0231,35.2524,37.9623,34.79,37.8134,34.353);
  1612. this.context.bezierCurveTo(37.6645,33.916,37.4305,33.5132,37.1249,33.1681);
  1613. this.context.bezierCurveTo(36.8194,32.823,36.4486,32.5426,36.034,32.3432);
  1614. this.context.bezierCurveTo(35.6195,32.1438,35.1695,32.0294,34.7105,32.0067);
  1615. this.context.closePath();
  1616. this.context.fill();
  1617. this.context.stroke();
  1618. this.context.restore();
  1619. }
  1620. drawBloodStain(geometry) {
  1621. const selectItem = stateService.getSelectItem()
  1622. const draggingItem = stateService.getDraggingItem()
  1623. const focusItem = stateService.getFocusItem()
  1624. this.context.save()
  1625. this.context.strokeStyle = Style.Sign.strokeStyle
  1626. this.context.fillStyle = Style.Sign.fillStyle
  1627. if (selectItem && selectItem.type == VectorType.BloodStain) {
  1628. if (geometry.vectorId == selectItem.vectorId) {
  1629. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1630. this.context.fillStyle = Style.Select.Sign.fillStyle
  1631. }
  1632. } else if (draggingItem && draggingItem.type == VectorType.BloodStain) {
  1633. if (geometry.vectorId == draggingItem.vectorId) {
  1634. this.context.strokeStyle = Style.Select.Sign.strokeStyle
  1635. this.context.fillStyle = Style.Select.Sign.fillStyle
  1636. }
  1637. }
  1638. if (focusItem && focusItem.type == VectorType.BloodStain) {
  1639. if (geometry.vectorId == focusItem.vectorId) {
  1640. this.context.strokeStyle = Style.Focus.Sign.strokeStyle
  1641. this.context.fillStyle = Style.Focus.Sign.fillStyle
  1642. }
  1643. }
  1644. const center = coordinate.getScreenXY({
  1645. x: geometry.center.x,
  1646. y: geometry.center.y,
  1647. })
  1648. const pt = coordinate.getScreenXY({
  1649. x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
  1650. y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
  1651. })
  1652. this.context.translate(center.x, center.y)
  1653. this.context.rotate((geometry.angle / 180) * Math.PI)
  1654. this.context.translate(pt.x - center.x, pt.y - center.y)
  1655. this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom, (geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1656. this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32 * coordinate.zoom/Constant.defaultZoom)
  1657. this.context.strokeStyle="rgba(0,0,0,0)";
  1658. this.context.miterLimit=4;
  1659. this.context.font="15px ''";
  1660. this.context.fillStyle="#FF4D4F";
  1661. this.context.beginPath();
  1662. this.context.moveTo(11.7832,43.4124);
  1663. this.context.bezierCurveTo(13.9788,44.5378,19.4679,44.5355,19.468,38.91);
  1664. this.context.bezierCurveTo(19.468,33.2844,21.1146,29.3458,26.0549,28.7831);
  1665. this.context.bezierCurveTo(26.3893,28.745,26.7385,28.7077,27.1002,28.669);
  1666. this.context.bezierCurveTo(32.0834,28.1363,39.425,27.3516,42.5224,20.9046);
  1667. this.context.bezierCurveTo(44.2471,17.3148,41.7011,10.7791,28.2507,7.40168);
  1668. this.context.bezierCurveTo(14.3038,3.89964,6.84294,7.40168,5.19509,13.0273);
  1669. this.context.bezierCurveTo(3.54725,18.6528,12.8799,26.5313,12.8799,26.5313);
  1670. this.context.bezierCurveTo(12.8799,26.5313,16.1646,30.722,15.0766,33.2844);
  1671. this.context.bezierCurveTo(14.9608,34.6355,13.8708,35.0844,12.6391,35.5917);
  1672. this.context.bezierCurveTo(11.5358,36.0461,10.3188,36.5474,9.58641,37.7858);
  1673. this.context.bezierCurveTo(8.03737,40.4055,9.58751,42.2871,11.7832,43.4124);
  1674. this.context.closePath();
  1675. this.context.fill();
  1676. this.context.stroke();
  1677. this.context.beginPath();
  1678. this.context.moveTo(32.8372,34.4465);
  1679. this.context.bezierCurveTo(32.3576,36.4893,31.5484,37,29.9586,37);
  1680. this.context.bezierCurveTo(28.3688,37,26.6003,35.9786,27.08,34.4465);
  1681. this.context.bezierCurveTo(27.5598,32.9144,29.5522,32,31.1421,32);
  1682. this.context.bezierCurveTo(32.7319,32,33.3169,32.4037,32.8372,34.4465);
  1683. this.context.closePath();
  1684. this.context.fill();
  1685. this.context.stroke();
  1686. this.context.beginPath();
  1687. this.context.moveTo(37.4462,43);
  1688. this.context.bezierCurveTo(38.8566,43,40,42.3284,40,41.5);
  1689. this.context.bezierCurveTo(40,40.6716,38.3459,40,36.9355,40);
  1690. this.context.bezierCurveTo(35.525,40,35,40.6716,35,41.5);
  1691. this.context.bezierCurveTo(35,42.3284,36.0358,43,37.4462,43);
  1692. this.context.closePath();
  1693. this.context.fill();
  1694. this.context.stroke();
  1695. this.context.restore();
  1696. }
  1697. /***************************************************************************************************************************************************************************************/
  1698. }
  1699. const draw = new Draw()
  1700. export { draw }