1
0

Draw.js 91 KB

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