Draw.js 87 KB

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