123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890 |
- import { floorplanService } from '../Service/FloorplanService.js'
- import { stateService } from '../Service/StateService.js'
- import { coordinate } from '../Coordinate.js'
- import Style from '../Style.js'
- import VectorType from '../enum/VectorType.js'
- import SelectState from '../enum/SelectState.js'
- import { mathUtil } from '../MathUtil.js'
- import ElementEvents from '../enum/ElementEvents.js'
- import Constant from '../Constant.js'
- import { signService } from '../Service/SignService.js'
- export default class Draw {
- constructor() {
- this.context = null
- }
- initContext(canvas) {
- if (canvas) {
- this.context = canvas.getContext('2d')
- } else {
- this.context = null
- }
- }
- clear() {
- this.context.clearRect(0, 0, this.context.canvas.width, this.context.canvas.height)
- }
- drawBackGround(color) {
- this.context.save()
- this.context.fillStyle = color
- this.context.fillRect(0, 0, this.context.canvas.width, this.context.canvas.height)
- this.context.restore()
- }
- // setSVGAttr(svgId,width,height){
- // }
- drawWall(vector) {
- let start = floorplanService.getPoint(vector.start)
- let end = floorplanService.getPoint(vector.end)
- let points = []
- points.push(start)
- points.push(end)
- points = points.sort(sortNumber.bind(this))
- function sortNumber(a, b) {
- return mathUtil.getDistance(start, a) - mathUtil.getDistance(start, b)
- }
- this.context.save()
- this.context.beginPath()
- this.context.lineCap = 'round' //线段端点的样式
- //this.context.lineJoin= 'miter';
- this.context.strokeStyle = Style.Wall.strokeStyle
- this.context.lineWidth = Style.Wall.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Wall.strokeStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Wall) {
- if (vector.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Wall.strokeStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.Wall) {
- if (vector.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Wall.strokeStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.Wall) {
- if (vector.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Wall.strokeStyle
- }
- }
- for (let i = 0; i < points.length - 1; i += 2) {
- let point1 = coordinate.getScreenXY(points[i])
- let point2 = coordinate.getScreenXY(points[i + 1])
- this.context.moveTo(point1.x, point1.y)
- this.context.lineTo(point2.x, point2.y)
- }
- this.context.stroke()
- this.context.restore()
- }
- drawSpecialPoint() {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- let point = null
- this.context.save()
- if (selectItem) {
- point = floorplanService.getPoint(selectItem.vectorId)
- this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Select.Point.strokeStyle
- this.context.fillStyle = Style.Select.Point.fillStyle
- }
- if (draggingItem) {
- point = floorplanService.getPoint(draggingItem.vectorId)
- this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Select.Point.strokeStyle
- this.context.fillStyle = Style.Select.Point.fillStyle
- }
- if (focusItem) {
- point = floorplanService.getPoint(focusItem.vectorId)
- this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Focus.Point.strokeStyle
- this.context.fillStyle = Style.Focus.Point.fillStyle
- }
- if (point == null) {
- this.context.restore()
- return
- }
- const pt = coordinate.getScreenXY({ x: point.x, y: point.y })
- let radius = Style.Point.radius
- this.context.beginPath()
- this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
- this.context.stroke()
- this.context.fill()
- this.context.restore()
- }
- drawPoint(vector) {
- const pt = coordinate.getScreenXY({ x: vector.x, y: vector.y })
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- // this.context.save()
- // this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
- // this.context.strokeStyle = Style.Point.strokeStyle
- // this.context.fillStyle = Style.Point.fillStyle
- let radius = Style.Point.radius
- if (
- (draggingItem && draggingItem.type == VectorType.WallCorner && vector.vectorId == draggingItem.vectorId) ||
- (selectItem && selectItem.type == VectorType.WallCorner && vector.vectorId == selectItem.vectorId)
- ) {
- this.context.save()
- this.context.lineWidth = Style.Select.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Select.Point.strokeStyle
- this.context.fillStyle = Style.Select.Point.fillStyle
- radius = Style.Select.Point.radius
- } else if (focusItem && focusItem.type == VectorType.WallCorner && vector.vectorId == focusItem.vectorId) {
- this.context.save()
- this.context.lineWidth = Style.Focus.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Focus.Point.strokeStyle
- this.context.fillStyle = Style.Focus.Point.fillStyle
- radius = Style.Focus.Point.radius
- } else {
- return
- }
- this.context.beginPath()
- this.context.arc(pt.x, pt.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
- this.context.stroke()
- this.context.fill()
- this.context.restore()
- // this.drawText({ x: vector.x, y: vector.y }, vector.vectorId)
- }
- // 文字
- drawText(position, txt, screenCoord) {
- this.context.save()
- this.setCanvasStyle(Style.Font)
- this.context.font = '12px Microsoft YaHei'
- let pt = { x: position.x, y: position.y }
- if (!screenCoord) {
- pt = coordinate.getScreenXY({ x: position.x, y: position.y })
- }
- this.context.fillText(txt, pt.x, pt.y)
- this.context.restore()
- }
- drawTag(geometry) {
- this.context.save()
- this.context.lineWidth = Style.Tag.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Tag.strokeStyle
- this.context.fillStyle = Style.Tag.fillStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Tag) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Tag.strokeStyle
- this.context.fillStyle = Style.Select.Tag.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.Tag) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Tag.strokeStyle
- this.context.fillStyle = Style.Select.Tag.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.Tag) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Tag.strokeStyle
- this.context.fillStyle = Style.Focus.Tag.fillStyle
- }
- }
- const fontSize = coordinate.ratio == Constant.ratio ? 36 : 12
- this.context.font = `400 ${fontSize}px Microsoft YaHei`
- //根据文字的长度,更新标注范围
- geometry.sideWidth = Math.max(this.context.measureText(geometry.value).width, this.context.measureText(parseFloat(geometry.value).toFixed(2)).width)
- geometry.setPoints2d()
- let points2d = geometry.points2d
- let points = []
- for (let i = 0; i < points2d.length; ++i) {
- points[i] = coordinate.getScreenXY({ x: points2d[i].x, y: points2d[i].y })
- }
- let pt = { x: geometry.center.x, y: geometry.center.y }
- pt = coordinate.getScreenXY({ x: geometry.center.x, y: geometry.center.y })
- const fontWidth1 = this.context.measureText(geometry.value).width
- 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 })
- const fontStart1 = mathUtil.getDisPointsLine(line1, pt, fontWidth1 / 2, fontWidth1 / 2)
- if (fontStart1.newpoint1.x < fontStart1.newpoint2.x) {
- this.context.fillText(geometry.value, fontStart1.newpoint1.x, fontStart1.newpoint1.y)
- } else {
- this.context.fillText(geometry.value, fontStart1.newpoint2.x, fontStart1.newpoint2.y)
- }
- this.context.restore()
- }
- drawTable(geometry){
- const leftTop = coordinate.getScreenXY({
- x:geometry.center.x - Math.abs(geometry.points[0].x - geometry.points[1].x)/2,
- y:geometry.center.y + Math.abs(geometry.points[0].y - geometry.points[3].y)/2,
- })
- for(let i=0;i<geometry.cells.length;++i){
- for(let j=0;j<geometry.cells[i].length;++j)
- {
- const cell = floorplanService.getCell(geometry.cells[i][j])
- const position = geometry.getCellPos(cell.vectorId)
- this.drawCell(cell,position.x + leftTop.x,position.y + leftTop.y)
- }
- }
- }
- drawCell(geometry,width,height){
- this.context.save()
- this.context.lineWidth = Style.Table.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Table.strokeStyle
- this.context.fillStyle = Style.Table.fillStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Table) {
- if (geometry.parent == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Table.strokeStyle
- this.context.fillStyle = Style.Select.Table.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.Table) {
- if (geometry.parent == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Table.strokeStyle
- this.context.fillStyle = Style.Select.Table.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.Table) {
- if (geometry.parent == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Table.strokeStyle
- this.context.fillStyle = Style.Focus.Table.fillStyle
- }
- }
- this.context.translate(width, height)
- this.context.beginPath()
- this.context.moveTo(0,0)
- this.context.lineTo(geometry.width,0)
- this.context.lineTo(geometry.width,geometry.height)
- this.context.lineTo(0,geometry.height)
- this.context.closePath();
- this.context.stroke()
- const defaultHeight = 24;
- const defaultWidth = 156;
- this.context.font = '12px Microsoft YaHei'
- const fontWidth = this.context.measureText(geometry.value).width
- //let rowCount = Math.ceil(geometry.height/defaultHeight) //分几行写
- let rowCount = Math.ceil(fontWidth/defaultWidth) //分几行写,根据要写的文字的长度来判断
- if(rowCount == 1){
- this.context.textAlign = "center";
- this.context.textBaseline = "middle";
- this.context.fillText(geometry.value, geometry.width/2, geometry.height/2)
- }
- //大于1行
- else{
- const rowWidth = Math.ceil(fontWidth/rowCount) //每行的长度
- const rowFontCount = Math.ceil(geometry.value.length/rowCount) //每行的文字个数
- this.context.textAlign = "left";
- for(let i=0;i<rowCount;++i){
- const value = geometry.value.substr(i*rowFontCount,rowFontCount)
- this.context.fillText(value, geometry.width/2 - rowWidth/2, 18+18*i)
- }
- }
- this.context.restore()
- }
- drawRectangle(geometry){
- let points = []
- for(let i=0;i<geometry.points.length;++i){
- points.push(coordinate.getScreenXY(geometry.points[i]))
- }
- this.context.save()
- this.context.beginPath()
- this.context.lineCap = 'round' //线段端点的样式;
- this.context.strokeStyle = Style.Rectangle.strokeStyle
- this.context.lineWidth = Style.Rectangle.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Rectangle.strokeStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- let fillFlag = false
-
- if (selectItem && selectItem.type == VectorType.Rectangle) {
- if (geometry.vectorId == selectItem.vectorId) {
- if(selectItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- this.context.fillStyle = Style.Select.Rectangle.fillStyle
- fillFlag = true;
- }
- else if(selectItem.selectIndex.indexOf(SelectState.Side)>-1){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- }
- else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- } else if (draggingItem && draggingItem.type == VectorType.Rectangle) {
- if (geometry.vectorId == draggingItem.vectorId) {
- if(draggingItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- this.context.fillStyle = Style.Select.Rectangle.fillStyle
- fillFlag = true;
- }
- else if(draggingItem.selectIndex.indexOf(SelectState.Side)>-1){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- }
- else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Rectangle.strokeStyle
- let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- }
- if (focusItem && focusItem.type == VectorType.Rectangle) {
- if (geometry.vectorId == focusItem.vectorId) {
- if(focusItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
- this.context.fillStyle = Style.Focus.Rectangle.fillStyle
- fillFlag = true;
- }
- else if(focusItem.selectIndex.indexOf(SelectState.Side)>-1){
- this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
- }
- else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Focus.Rectangle.strokeStyle
- let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- }
- this.context.moveTo(points[0].x, points[0].y)
- for (let i = 1; i < points.length; ++i) {
- this.context.lineTo(points[i].x, points[i].y)
- }
- this.context.closePath();
- this.context.stroke()
- if(fillFlag){
- this.context.fill()
- }
- this.context.restore()
- }
- drawCircleGeo(geometry)
- {
- let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
- const twoPi = Math.PI * 2
- const pt = coordinate.getScreenXY(geometry.center)
- this.context.save()
- this.context.strokeStyle = Style.Circle.strokeStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- let fillFlag = false
-
- if (selectItem && selectItem.type == VectorType.Circle) {
- if (geometry.vectorId == selectItem.vectorId) {
- if(selectItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Circle.strokeStyle
- this.context.fillStyle = Style.Select.Circle.fillStyle
- fillFlag = true;
- }
- else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Circle.strokeStyle
- let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- } else if (draggingItem && draggingItem.type == VectorType.Circle) {
- if (geometry.vectorId == draggingItem.vectorId) {
- if(draggingItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Circle.strokeStyle
- this.context.fillStyle = Style.Select.Circle.fillStyle
- fillFlag = true;
- }
- else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Circle.strokeStyle
- let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- }
- if (focusItem && focusItem.type == VectorType.Circle) {
- if (geometry.vectorId == focusItem.vectorId) {
- if(focusItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Focus.Circle.strokeStyle
- this.context.fillStyle = Style.Focus.Circle.fillStyle
- fillFlag = true;
- }
- else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Focus.Circle.strokeStyle
- let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- }
- this.context.beginPath()
- this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
- this.context.stroke()
- if(fillFlag){
- this.context.fill()
- }
- this.context.restore()
- }
- drawIcon(geometry)
- {
- let radius = geometry.radius * coordinate.res * coordinate.zoom/Constant.defaultZoom
- const twoPi = Math.PI * 2
- const pt = coordinate.getScreenXY(geometry.center)
- this.context.save()
- this.context.strokeStyle = Style.Icon.strokeStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- let fillFlag = false
-
- if (selectItem && selectItem.type == VectorType.Icon) {
- if (geometry.vectorId == selectItem.vectorId) {
- if(selectItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Icon.strokeStyle
- this.context.fillStyle = Style.Select.Icon.fillStyle
- fillFlag = true;
- }
- else if(selectItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Icon.strokeStyle
- let vertexIndex = selectItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- } else if (draggingItem && draggingItem.type == VectorType.Icon) {
- if (geometry.vectorId == draggingItem.vectorId) {
- if(draggingItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Select.Icon.strokeStyle
- this.context.fillStyle = Style.Select.Icon.fillStyle
- fillFlag = true;
- }
- else if(draggingItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Select.Icon.strokeStyle
- let vertexIndex = draggingItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- }
- if (focusItem && focusItem.type == VectorType.Icon) {
- if (geometry.vectorId == focusItem.vectorId) {
- if(focusItem.selectIndex == SelectState.All){
- this.context.strokeStyle = Style.Focus.Icon.strokeStyle
- this.context.fillStyle = Style.Focus.Icon.fillStyle
- fillFlag = true;
- }
- else if(focusItem.selectIndex.indexOf(SelectState.Vertex)>-1){
- this.context.strokeStyle = Style.Focus.Icon.strokeStyle
- let vertexIndex = focusItem.selectIndex.replace(SelectState.Vertex+'_','');
- this.drawCircle({
- x:geometry.points[vertexIndex].x,
- y:geometry.points[vertexIndex].y,
- name: ElementEvents.StartAddWall
- })
- this.drawRec(geometry.points)
- }
- }
- }
- this.context.beginPath()
- this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
- this.context.stroke()
- if(fillFlag){
- this.context.fill()
- }
- this.context.restore()
- this.context.save()
- this.setCanvasStyle(Style.Font)
-
- let fonSize = Math.ceil(radius * 14/20);
- this.context.font = fonSize + Style.Font.font;
- let center = coordinate.getScreenXY(geometry.center);
- this.context.fillText(geometry.value, center.x , center.y)
- this.context.restore()
- }
- drawArrow(geometry){
- this.context.save()
- this.context.beginPath()
- this.context.lineCap = 'round' //线段端点的样式
- this.context.strokeStyle = Style.Arrow.strokeStyle
- this.context.lineWidth = Style.Arrow.lineWidth * coordinate.ratio
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Arrow) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Arrow.strokeStyle
- if(selectItem.selectIndex == SelectState.Start){
- this.drawCircle({
- x:geometry.startPoint.x,
- y:geometry.startPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- else if(selectItem.selectIndex == SelectState.End){
- this.drawCircle({
- x:geometry.endPoint.x,
- y:geometry.endPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- } else if (draggingItem && draggingItem.type == VectorType.Arrow) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Arrow.strokeStyle
- if(draggingItem.selectIndex == SelectState.Start){
- this.drawCircle({
- x:geometry.startPoint.x,
- y:geometry.startPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- else if(draggingItem.selectIndex == SelectState.End){
- this.drawCircle({
- x:geometry.endPoint.x,
- y:geometry.endPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- }
- if (focusItem && focusItem.type == VectorType.Arrow) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Arrow.strokeStyle
- if(focusItem.selectIndex == SelectState.Start){
- this.drawCircle({
- x:geometry.startPoint.x,
- y:geometry.startPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- else if(focusItem.selectIndex == SelectState.End){
- this.drawCircle({
- x:geometry.endPoint.x,
- y:geometry.endPoint.y,
- name: ElementEvents.StartAddWall
- })
- }
- }
- }
- let point1 = coordinate.getScreenXY(geometry.startPoint)
- let point2 = coordinate.getScreenXY(geometry.endPoint)
-
- var headlen = 10; //自定义箭头线的长度
- var theta = 20; //自定义箭头线与直线的夹角,个人觉得45°刚刚好
- //箭头线终点坐标
- var arrowX, arrowY;
- let fromX = point2.x;
- let fromY = point2.y;
- let toX = point1.x;
- let toY = point1.y;
- // 计算各角度和对应的箭头终点坐标
- var angle = Math.atan2(fromY - toY, fromX - toX) * 180 / Math.PI;
- var angle1 = (angle + theta) * Math.PI / 180;
- var angle2 = (angle - theta) * Math.PI / 180;
- var topX = headlen * Math.cos(angle1);
- var topY = headlen * Math.sin(angle1);
- var botX = headlen * Math.cos(angle2);
- var botY = headlen * Math.sin(angle2);
- this.context.beginPath();
- //画直线
- this.context.moveTo(fromX, fromY);
- this.context.lineTo(toX, toY);
-
- arrowX = toX + topX;
- arrowY = toY + topY;
- //画上边箭头线
- this.context.moveTo(arrowX, arrowY);
- this.context.lineTo(toX, toY);
-
- arrowX = toX + botX;
- arrowY = toY + botY;
- //画下边箭头线
- this.context.lineTo(arrowX, arrowY);
- this.context.stroke()
- this.context.restore()
- }
- drawCircle(element) {
- let radius = null
- const twoPi = Math.PI * 2
- const pt = coordinate.getScreenXY(element)
- this.context.save()
- if (element.name == ElementEvents.StartAddWall) {
- radius = Style.Element.StartAddWall.radius * coordinate.ratio
- this.context.strokeStyle = Style.Element.StartAddWall.strokeStyle
- this.context.fillStyle = Style.Element.StartAddWall.fillStyle
- }
- this.context.beginPath()
- this.context.arc(pt.x, pt.y, radius, 0, twoPi, true)
- this.context.stroke()
- this.context.fill()
- this.context.restore()
- }
- drawRec(points){
- let point = coordinate.getScreenXY(points[0])
- this.context.moveTo(point.x, point.y)
- for (let i = 1; i < points.length; ++i) {
- point = coordinate.getScreenXY(points[i])
- this.context.lineTo(point.x, point.y)
- }
- this.context.closePath();
- this.context.stroke()
- }
- drawLine(element) {
- let start = coordinate.getScreenXY(element.start)
- let end = coordinate.getScreenXY(element.end)
- this.context.save()
- if (element.name == ElementEvents.VCheckLinesX) {
- this.context.lineWidth = Style.Element.VCheckLinesX.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Element.VCheckLinesX.strokeStyle
- this.context.setLineDash([3, 2, 2])
- start.y = 0
- end.y = this.context.canvas.clientHeight
- } else if (element.name == ElementEvents.VCheckLinesY) {
- this.context.lineWidth = Style.Element.VCheckLinesY.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Element.VCheckLinesY.strokeStyle
- this.context.setLineDash([3, 2, 2])
- start.x = 0
- end.x = this.context.canvas.clientWidth
- } else if (element.name == ElementEvents.NewWall) {
- this.context.lineWidth = Style.Element.NewWall.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Element.NewWall.strokeStyle
- if (element.state == 'error') {
- this.context.strokeStyle = Style.Element.NewWall.errorStrokeStyle
- }
- } else if (element.name == ElementEvents.CheckLinesX) {
- this.context.lineWidth = Style.Element.CheckLinesX.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Element.CheckLinesX.strokeStyle
- this.context.setLineDash([3, 2, 2])
- } else if (element.name == ElementEvents.CheckLinesY) {
- this.context.lineWidth = Style.Element.CheckLinesY.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Element.CheckLinesY.strokeStyle
- this.context.setLineDash([3, 2, 2])
- }
- this.context.beginPath()
- this.context.moveTo(start.x, start.y)
- this.context.lineTo(end.x, end.y)
- this.context.stroke()
- this.context.restore()
- this.context.save()
- this.context.lineWidth = Style.Point.lineWidth * coordinate.ratio
- this.context.strokeStyle = Style.Point.strokeStyle
- this.context.fillStyle = Style.Point.fillStyle
- let radius = Style.Point.radius
- this.context.beginPath()
- this.context.arc(start.x, start.y, radius * coordinate.ratio, 0, Math.PI * 2, true)
- this.context.stroke()
- this.context.fill()
- this.context.restore()
- }
- drawTitle(geometry){
-
- this.context.save()
- this.setCanvasStyle(Style.Title)
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Title) {
- this.context.strokeStyle = Style.Select.Title.strokeStyle
- this.context.fillStyle = Style.Select.Title.fillStyle
- } else if (draggingItem && draggingItem.type == VectorType.Title) {
- this.context.strokeStyle = Style.Select.Title.strokeStyle
- this.context.fillStyle = Style.Select.Title.fillStyle
- }
- if (focusItem && focusItem.type == VectorType.Title) {
- this.context.strokeStyle = Style.Focus.Title.strokeStyle
- this.context.fillStyle = Style.Focus.Title.fillStyle
- }
- //let pt = {}
- //pt.x = (this.context.canvas.width - this.context.measureText(geometry.value).width)/2
- this.context.fillText(geometry.value, this.context.canvas.width/2, geometry.height)
- this.context.restore()
- }
- drawImage(geometry){
- if(geometry.src != null){
- const pt = {
- x:30,
- y:150
- }
- this.context.save()
- if(geometry.image == null)
- {
- var img = new Image()
- img.src = geometry.src;
- img.crossOrigin=""
- img.onload = function () {
- this.context.drawImage(img, pt.x, pt.y, img.width, img.height)
- }.bind(this)
- geometry.image = img;
- }
- else{
- this.context.drawImage(geometry.image, pt.x, pt.y, geometry.image.width, geometry.image.height)
- }
- this.context.restore()
- }
- }
- drawCompass(geometry){
-
- this.context.save()
- this.context.strokeStyle = Style.Compass.strokeStyle
- this.context.fillStyle = Style.Compass.fillStyle
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- if (selectItem && selectItem.type == VectorType.Compass) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Compass.strokeStyle
- this.context.fillStyle = Style.Select.Compass.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.Compass) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Compass.strokeStyle
- this.context.fillStyle = Style.Select.Compass.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.Compass) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Compass.strokeStyle
- this.context.fillStyle = Style.Focus.Compass.fillStyle
- }
- }
- this.context.translate(geometry.center.x,geometry.center.y)
- this.context.rotate((geometry.angle)/180 * Math.PI)
- if(geometry.angle == 90){
- this.context.translate( 32/2, -52)
- }
- else if(geometry.angle == 180){
- this.context.translate( -32, -52)
- }
- else if(geometry.angle == 270){
- this.context.translate( -52, -32/2)
- }
- this.context.lineWidth = 1
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.beginPath();
- this.context.moveTo(12.5221,3.262);
- this.context.lineTo(8.93807,3.262);
- this.context.lineTo(8.93807,4.284);
- this.context.lineTo(12.5221,4.284);
- this.context.lineTo(12.5221,8.204);
- this.context.bezierCurveTo(11.0241,8.778,9.54007,9.352,8.51807,9.688);
- this.context.lineTo(8.99407,10.724);
- this.context.bezierCurveTo(10.0021,10.304,11.2761,9.786,12.5221,9.24);
- this.context.lineTo(12.5221,12.334);
- this.context.lineTo(13.5861,12.334);
- this.context.lineTo(13.5861,0);
- this.context.lineTo(12.5221,0);
- this.context.lineTo(12.5221,3.262);
- this.context.closePath();
- this.context.moveTo(17.6881,11.13);
- this.context.bezierCurveTo(17.0721,11.13,16.9601,11.004,16.9601,10.29);
- this.context.lineTo(16.9601,5.726);
- this.context.bezierCurveTo(18.4581,4.9,20.0821,3.934,21.2581,2.982);
- this.context.lineTo(20.4181,2.114);
- this.context.bezierCurveTo(19.5781,2.912,18.2621,3.85,16.9601,4.648);
- this.context.lineTo(16.9601,0);
- this.context.lineTo(15.8961,0);
- this.context.lineTo(15.8961,10.276);
- this.context.bezierCurveTo(15.8961,11.746,16.2741,12.152,17.5901,12.152);
- this.context.lineTo(19.7741,12.152);
- this.context.bezierCurveTo(21.1321,12.152,21.4261,11.27,21.5521,8.722);
- this.context.bezierCurveTo(21.2581,8.652,20.8241,8.442,20.5441,8.232);
- this.context.bezierCurveTo(20.4461,10.556,20.3481,11.13,19.6901,11.13);
- this.context.lineTo(17.6881,11.13);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(24.8494,49.3321);
- this.context.lineTo(28.7452,51);
- this.context.lineTo(27.3498,47.2775);
- this.context.bezierCurveTo(30.224,44.385,32,40.3999,32,36);
- this.context.bezierCurveTo(32,27.5465,25.4442,20.6242,17.1394,20.0399);
- this.context.lineTo(15.9998,17);
- this.context.lineTo(14.8602,20.04);
- this.context.bezierCurveTo(6.55559,20.6245,0,27.5467,0,36);
- this.context.bezierCurveTo(0,40.3998,1.77588,44.3847,4.64993,47.2772);
- this.context.lineTo(3.25439,51);
- this.context.lineTo(7.15046,49.3319);
- this.context.bezierCurveTo(9.68503,51.0177,12.7278,52,16,52);
- this.context.bezierCurveTo(19.2721,52,22.3148,51.0178,24.8494,49.3321);
- this.context.closePath();
- this.context.moveTo(26.5656,45.1856);
- this.context.lineTo(17.9232,22.131);
- this.context.bezierCurveTo(24.7452,23.0683,30,28.9205,30,36);
- this.context.bezierCurveTo(30,39.5148,28.7048,42.7271,26.5656,45.1856);
- this.context.closePath();
- this.context.moveTo(14.0763,22.1311);
- this.context.lineTo(5.43414,45.1852);
- this.context.bezierCurveTo(3.29512,42.7268,2,39.5146,2,36);
- this.context.bezierCurveTo(2,28.9206,7.25457,23.0685,14.0763,22.1311);
- this.context.closePath();
- this.context.moveTo(7.43459,47.0749);
- this.context.bezierCurveTo(7.28407,46.9583,7.13599,46.8387,6.99045,46.7162);
- this.context.lineTo(15,25.3497);
- this.context.lineTo(15,43.8358);
- this.context.lineTo(7.43459,47.0749);
- this.context.closePath();
- this.context.moveTo(9.4198,48.3604);
- this.context.lineTo(15.9998,45.5432);
- this.context.lineTo(22.58,48.3605);
- this.context.bezierCurveTo(20.6184,49.4069,18.3785,50,16,50);
- this.context.bezierCurveTo(13.6214,50,11.3814,49.4068,9.4198,48.3604);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- setCanvasStyle(style) {
- for (const key in style) {
- if (key != 'isFill' && key != 'isStroke') {
- this.context[key] = style[key]
- }
- }
- }
- /*************************************************************************************家具**********************************************************************************************/
- drawSign(geometry) {
- if (geometry.geoType == VectorType.Cigaret) {
- this.drawCigaret(geometry)
- } else if (geometry.geoType == VectorType.FirePoint) {
- this.drawFirePoint(geometry)
- } else if (geometry.geoType == VectorType.LeftFootPrint) {
- this.drawLeftFootPrint(geometry)
- } else if (geometry.geoType == VectorType.RightFootPrint) {
- this.drawRightFootPrint(geometry)
- } else if (geometry.geoType == VectorType.LeftShoePrint) {
- this.drawLeftShoePrint(geometry)
- } else if (geometry.geoType == VectorType.RightShoePrint) {
- this.drawRightShoePrint(geometry)
- } else if (geometry.geoType == VectorType.FingerPrint) {
- this.drawFingerPrint(geometry)
- } else if (geometry.geoType == VectorType.DeadBody) {
- this.drawDeadBody(geometry)
- } else if (geometry.geoType == VectorType.BloodStain) {
- this.drawBloodStain(geometry)
- }
- }
- drawCigaret(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.Cigaret) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.Cigaret) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.Cigaret) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.miterLimit = 4
- this.context.font = "15px ''"
- this.context.beginPath();
- this.context.moveTo(38.6342,4);
- this.context.bezierCurveTo(38.6342,4,41.1545,9.5,39.1546,12.5);
- this.context.bezierCurveTo(37.1547,15.5,39.1546,19,39.1546,19);
- this.context.bezierCurveTo(36.0776,15.923,34.9395,14,37.1547,10.5);
- this.context.bezierCurveTo(39.3699,7,38.6342,4,38.6342,4);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(4,29);
- this.context.bezierCurveTo(2.89543,29,2,29.8954,2,31);
- this.context.lineTo(2,39);
- this.context.bezierCurveTo(2,40.1046,2.89543,41,4,41);
- this.context.lineTo(34,41);
- this.context.lineTo(34,29);
- this.context.lineTo(4,29);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
-
- this.context.beginPath();
- this.context.moveTo(40.7714,20.5);
- this.context.bezierCurveTo(38.7716,17.5,41.2918,12,41.2918,12);
- this.context.bezierCurveTo(41.2918,12,40.5561,15,42.7713,18.5);
- this.context.bezierCurveTo(44.9866,22,43.8485,23.923,40.7714,27);
- this.context.bezierCurveTo(40.7714,27,42.7713,23.5,40.7714,20.5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
-
- this.context.beginPath();
- this.context.moveTo(37.5,29);
- this.context.bezierCurveTo(36.6716,29,36,29.6716,36,30.5);
- this.context.lineTo(36,39.5);
- this.context.bezierCurveTo(36,40.3284,36.6716,41,37.5,41);
- this.context.bezierCurveTo(38.3284,41,39,40.3284,39,39.5);
- this.context.lineTo(39,30.5);
- this.context.bezierCurveTo(39,29.6716,38.3284,29,37.5,29);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
-
- this.context.beginPath();
- this.context.moveTo(42,29);
- this.context.bezierCurveTo(41.1716,29,40.5,29.6716,40.5,30.5);
- this.context.lineTo(40.5,39.5);
- this.context.bezierCurveTo(40.5,40.3284,41.1716,41,42,41);
- this.context.bezierCurveTo(42.8284,41,43.5,40.3284,43.5,39.5);
- this.context.lineTo(43.5,30.5);
- this.context.bezierCurveTo(43.5,29.6716,42.8284,29,42,29);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
-
- drawFirePoint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.FirePoint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.FirePoint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.FirePoint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="#FF4D4F";
- this.context.beginPath();
- this.context.moveTo(6.15863,28.8837);
- this.context.bezierCurveTo(4.84988,35.4972,11.9564,43.3721,15.8216,45);
- this.context.bezierCurveTo(15.8216,45,13.2504,38.8,14.8553,34.7442);
- this.context.bezierCurveTo(16.7879,29.8605,19.6868,25.9535,19.6868,25.9535);
- this.context.bezierCurveTo(19.6868,25.9535,20.1699,26.9302,20.6531,28.8837);
- this.context.bezierCurveTo(21.1363,30.8372,21.1363,31.3256,21.1363,31.3256);
- this.context.bezierCurveTo(21.1363,31.3256,22.9249,29.2771,23.5519,27.4186);
- this.context.bezierCurveTo(24.4676,24.7049,24.0351,20.093,24.0351,20.093);
- this.context.bezierCurveTo(24.0351,20.093,29.8166,25.9798,31.2823,30.8372);
- this.context.bezierCurveTo(32.8795,36.1307,30.7991,45,30.7991,45);
- this.context.bezierCurveTo(30.7991,45,40.7338,38.6512,41.9116,29.8605);
- this.context.bezierCurveTo(42.9992,21.7424,33.698,11.3023,33.698,11.3023);
- this.context.bezierCurveTo(33.698,11.3023,34.148,13.8357,33.698,15.6977);
- this.context.bezierCurveTo(33.3976,16.9405,32.2486,18.6279,32.2486,18.6279);
- this.context.bezierCurveTo(32.2486,18.6279,30.7991,13.884,27.9004,9.83721);
- this.context.bezierCurveTo(25.5478,6.55294,20.6531,3,20.6531,3);
- this.context.bezierCurveTo(20.6531,3,20.6531,9.34884,19.2037,13.7442);
- this.context.bezierCurveTo(17.7542,18.1395,12.9227,22.5349,12.9227,22.5349);
- this.context.lineTo(11.4733,15.2093);
- this.context.bezierCurveTo(10.0238,17.9767,7.12508,24,6.15863,28.8837);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawLeftFootPrint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.LeftFootPrint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.LeftFootPrint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.LeftFootPrint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="black";
- this.context.beginPath();
- this.context.moveTo(26.5,7);
- this.context.bezierCurveTo(25.1193,7,24,5.88071,24,4.5);
- this.context.bezierCurveTo(24,3.11929,25.1193,2,26.5,2);
- this.context.bezierCurveTo(27.8807,2,29,3.11929,29,4.5);
- this.context.bezierCurveTo(29,5.88071,27.8807,7,26.5,7);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(32,12);
- this.context.bezierCurveTo(30.3431,12,29,10.6569,29,9);
- this.context.bezierCurveTo(29,7.34315,30.3431,6,32,6);
- this.context.bezierCurveTo(33.6569,6,35,7.34315,35,9);
- this.context.bezierCurveTo(35,10.6569,33.6569,12,32,12);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(18,5);
- this.context.bezierCurveTo(18,6.10457,18.8954,7,20,7);
- this.context.bezierCurveTo(21.1046,7,22,6.10457,22,5);
- this.context.bezierCurveTo(22,3.89543,21.1046,3,20,3);
- this.context.bezierCurveTo(18.8954,3,18,3.89543,18,5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(15,10);
- this.context.bezierCurveTo(13.8954,10,13,9.10457,13,8);
- this.context.bezierCurveTo(13,6.89543,13.8954,6,15,6);
- this.context.bezierCurveTo(16.1046,6,17,6.89543,17,8);
- this.context.bezierCurveTo(17,9.10457,16.1046,10,15,10);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(10,12.5);
- this.context.bezierCurveTo(10,13.3284,10.6716,14,11.5,14);
- this.context.bezierCurveTo(12.3284,14,13,13.3284,13,12.5);
- this.context.bezierCurveTo(13,11.6716,12.3284,11,11.5,11);
- this.context.bezierCurveTo(10.6716,11,10,11.6716,10,12.5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(29.0721,31.5068);
- this.context.bezierCurveTo(29.0721,31.5068,28.037,29.0085,29.0721,27.2243);
- this.context.bezierCurveTo(30.1072,25.4402,30.9125,23.8936,31.6392,20.6224);
- this.context.bezierCurveTo(32.3658,17.3511,30.3143,9.73826,22.1998,10.0059);
- this.context.bezierCurveTo(14.0852,10.2735,13.2572,17.4108,13.0088,21.4254);
- this.context.bezierCurveTo(12.7604,25.44,17.8113,38.0193,21.4544,42.1233);
- this.context.bezierCurveTo(25.0975,46.2273,27.6647,46.5838,29.9831,45.424);
- this.context.bezierCurveTo(32.3016,44.2642,33.3778,42.5692,32.881,40.4282);
- this.context.bezierCurveTo(32.3842,38.2873,29.0721,31.5068,29.0721,31.5068);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawRightFootPrint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.RightFootPrint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.RightFootPrint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.RightFootPrint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="black";
- this.context.beginPath();
- this.context.moveTo(18.5,7);
- this.context.bezierCurveTo(19.8807,7,21,5.88071,21,4.5);
- this.context.bezierCurveTo(21,3.11929,19.8807,2,18.5,2);
- this.context.bezierCurveTo(17.1193,2,16,3.11929,16,4.5);
- this.context.bezierCurveTo(16,5.88071,17.1193,7,18.5,7);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(13,12);
- this.context.bezierCurveTo(14.6569,12,16,10.6569,16,9);
- this.context.bezierCurveTo(16,7.34315,14.6569,6,13,6);
- this.context.bezierCurveTo(11.3431,6,10,7.34315,10,9);
- this.context.bezierCurveTo(10,10.6569,11.3431,12,13,12);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(27,5);
- this.context.bezierCurveTo(27,6.10457,26.1046,7,25,7);
- this.context.bezierCurveTo(23.8954,7,23,6.10457,23,5);
- this.context.bezierCurveTo(23,3.89543,23.8954,3,25,3);
- this.context.bezierCurveTo(26.1046,3,27,3.89543,27,5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(30,10);
- this.context.bezierCurveTo(31.1046,10,32,9.10457,32,8);
- this.context.bezierCurveTo(32,6.89543,31.1046,6,30,6);
- this.context.bezierCurveTo(28.8954,6,28,6.89543,28,8);
- this.context.bezierCurveTo(28,9.10457,28.8954,10,30,10);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(35,12.5);
- this.context.bezierCurveTo(35,13.3284,34.3284,14,33.5,14);
- this.context.bezierCurveTo(32.6716,14,32,13.3284,32,12.5);
- this.context.bezierCurveTo(32,11.6716,32.6716,11,33.5,11);
- this.context.bezierCurveTo(34.3284,11,35,11.6716,35,12.5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(15.9279,31.5068);
- this.context.bezierCurveTo(15.9279,31.5068,16.963,29.0085,15.9279,27.2243);
- this.context.bezierCurveTo(14.8928,25.4402,14.0875,23.8936,13.3608,20.6224);
- this.context.bezierCurveTo(12.6342,17.3511,14.6857,9.73826,22.8002,10.0059);
- this.context.bezierCurveTo(30.9148,10.2735,31.7428,17.4108,31.9912,21.4254);
- this.context.bezierCurveTo(32.2396,25.44,27.1887,38.0193,23.5456,42.1233);
- this.context.bezierCurveTo(19.9025,46.2273,17.3353,46.5838,15.0169,45.424);
- this.context.bezierCurveTo(12.6984,44.2642,11.6222,42.5692,12.119,40.4282);
- this.context.bezierCurveTo(12.6158,38.2873,15.9279,31.5068,15.9279,31.5068);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawLeftShoePrint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.LeftShoePrint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.LeftShoePrint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.LeftShoePrint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.fillStyle="black";
- this.context.font=" 15px ''";
- this.context.beginPath();
- this.context.moveTo(29.9064,30.2635);
- this.context.lineTo(18.3897,31.999);
- this.context.bezierCurveTo(18.3897,31.999,14,24.0766,14,18.5101);
- this.context.bezierCurveTo(14,9.43774,16.8732,1.75238,22.3803,2.00508);
- this.context.bezierCurveTo(28.3968,2.28117,31,9.00467,31,15.3264);
- this.context.bezierCurveTo(31,18.8919,30.7015,20.0653,29.9867,22.8753);
- this.context.bezierCurveTo(29.7961,23.6244,29.5759,24.4898,29.3239,25.5478);
- this.context.bezierCurveTo(28.9957,26.926,29.9064,30.2635,29.9064,30.2635);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(30.5,34);
- this.context.lineTo(19,35.4383);
- this.context.bezierCurveTo(19,35.4383,19.316,39.7531,19.8057,42.3198);
- this.context.bezierCurveTo(20.2953,44.8865,22.9828,46.465,26.2418,45.8773);
- this.context.bezierCurveTo(29.5007,45.2895,32.4426,43.1091,31.9447,40.287);
- this.context.bezierCurveTo(31.4469,37.4649,30.5,34,30.5,34);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawRightShoePrint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.RightShoePrint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.RightShoePrint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.RightShoePrint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="black";
- this.context.beginPath();
- this.context.moveTo(16.0936,30.2635);
- this.context.lineTo(27.6103,31.999);
- this.context.bezierCurveTo(27.6103,31.999,32,24.0766,32,18.5101);
- this.context.bezierCurveTo(32,9.43774,29.1268,1.75238,23.6197,2.00508);
- this.context.bezierCurveTo(17.6032,2.28117,15,9.00467,15,15.3264);
- this.context.bezierCurveTo(15,18.8919,15.2985,20.0653,16.0133,22.8753);
- this.context.bezierCurveTo(16.2039,23.6244,16.4241,24.4898,16.6761,25.5478);
- this.context.bezierCurveTo(17.0043,26.926,16.0936,30.2635,16.0936,30.2635);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(15.5,34);
- this.context.lineTo(27,35.4383);
- this.context.bezierCurveTo(27,35.4383,26.684,39.7531,26.1943,42.3198);
- this.context.bezierCurveTo(25.7047,44.8865,23.0172,46.465,19.7582,45.8773);
- this.context.bezierCurveTo(16.4993,45.2895,13.5574,43.1091,14.0553,40.287);
- this.context.bezierCurveTo(14.5531,37.4649,15.5,34,15.5,34);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawFingerPrint(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.FingerPrint) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.FingerPrint) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.FingerPrint) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="black";
- this.context.beginPath();
- this.context.moveTo(43.4999,21.5);
- this.context.bezierCurveTo(43.4999,16.542,39.7109,10.8816,34.1276,7.63537);
- this.context.bezierCurveTo(28.4657,4.34348,20.8249,3.43868,12.9856,8.14233);
- this.context.bezierCurveTo(6.24753,12.1852,4.43294,18.9936,4.70686,25.2575);
- this.context.bezierCurveTo(4.97928,31.4873,7.31395,37.4063,9.18082,40.0733);
- this.context.bezierCurveTo(9.49752,40.5258,10.121,40.6358,10.5735,40.3191);
- this.context.bezierCurveTo(11.026,40.0024,11.136,39.3789,10.8193,38.9265);
- this.context.bezierCurveTo(9.18619,36.5933,6.96197,31.0477,6.70495,25.1701);
- this.context.bezierCurveTo(6.44942,19.3268,8.13483,13.3852,14.0146,9.85731);
- this.context.bezierCurveTo(21.1752,5.56085,28.0343,6.40615,33.1223,9.36438);
- this.context.bezierCurveTo(38.289,12.3683,41.4999,17.458,41.4999,21.5);
- this.context.bezierCurveTo(41.4999,24.6008,40.785,26.4882,39.8962,27.6385);
- this.context.bezierCurveTo(39.0131,28.7814,37.8743,29.3053,36.8039,29.5194);
- this.context.bezierCurveTo(33.9357,30.0933,31.4302,27.9399,30.9899,24.8585);
- this.context.bezierCurveTo(30.438,20.9948,27.6176,17.4999,23,17.4999);
- this.context.bezierCurveTo(20.6398,17.4999,18.5331,18.6977,17.4181,20.9277);
- this.context.bezierCurveTo(16.3192,23.1255,16.2513,26.1767,17.5583,29.8362);
- this.context.bezierCurveTo(18.5365,32.5753,20.7176,35.1665,22.999,37.2483);
- this.context.bezierCurveTo(25.2933,39.3417,27.7947,41.0153,29.5528,41.8943);
- this.context.bezierCurveTo(30.0468,42.1413,30.6474,41.9411,30.8944,41.4471);
- this.context.bezierCurveTo(31.1414,40.9531,30.9412,40.3525,30.4472,40.1055);
- this.context.bezierCurveTo(28.8719,39.3178,26.5208,37.7543,24.3471,35.7709);
- this.context.bezierCurveTo(22.1606,33.7757,20.2584,31.4503,19.4417,29.1636);
- this.context.bezierCurveTo(18.2488,25.8233,18.4309,23.3744,19.207,21.8222);
- this.context.bezierCurveTo(19.9669,20.3022,21.3602,19.4999,23,19.4999);
- this.context.bezierCurveTo(26.3823,19.4999,28.562,22.0051,29.01,25.1413);
- this.context.bezierCurveTo(29.5699,29.0599,32.9258,32.3349,37.1962,31.4806);
- this.context.bezierCurveTo(38.6259,31.1946,40.237,30.4684,41.4788,28.8614);
- this.context.bezierCurveTo(42.7149,27.2617,43.4999,24.8992,43.4999,21.5);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(28.3137,13.9002);
- this.context.bezierCurveTo(24.531,12.0661,19.8915,12.2936,16.2281,16.1858);
- this.context.bezierCurveTo(12.5481,20.0959,12.3111,24.8487,13.7047,29.4641);
- this.context.bezierCurveTo(15.1069,34.1077,18.1345,38.4781,20.738,41.3257);
- this.context.bezierCurveTo(21.1106,41.7333,21.0823,42.3658,20.6747,42.7385);
- this.context.bezierCurveTo(20.2671,43.1112,19.6346,43.0828,19.2619,42.6752);
- this.context.bezierCurveTo(16.5321,39.6895,13.3063,35.0635,11.7901,30.0422);
- this.context.bezierCurveTo(10.2654,24.9927,10.445,19.4122,14.7717,14.8151);
- this.context.bezierCurveTo(19.1085,10.2073,24.719,9.93463,29.1863,12.1005);
- this.context.bezierCurveTo(33.601,14.241,36.9999,18.8096,36.9999,24.0005);
- this.context.bezierCurveTo(36.9999,24.5528,36.5522,25.0005,35.9999,25.0005);
- this.context.bezierCurveTo(35.4477,25.0005,34.9999,24.5528,34.9999,24.0005);
- this.context.bezierCurveTo(34.9999,19.6911,32.1489,15.7597,28.3137,13.9002);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(23.3825,24.507);
- this.context.bezierCurveTo(23.93,24.4422,24.4265,24.8327,24.4928,25.3797);
- this.context.lineTo(24.493,25.381);
- this.context.bezierCurveTo(24.493,25.3814,24.4932,25.3825,23.5001,25.5001);
- this.context.lineTo(22.507,25.6177);
- this.context.bezierCurveTo(22.4421,25.0693,22.834,24.572,23.3825,24.507);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(23.5001,25.5001);
- this.context.lineTo(24.4932,25.3825);
- this.context.lineTo(24.4934,25.3844);
- this.context.lineTo(24.498,25.4166);
- this.context.bezierCurveTo(24.5026,25.4479,24.5105,25.4984,24.5228,25.5664);
- this.context.bezierCurveTo(24.5472,25.7024,24.5887,25.9078,24.6548,26.1683);
- this.context.bezierCurveTo(24.7871,26.6901,25.0169,27.4283,25.4033,28.2707);
- this.context.bezierCurveTo(26.1756,29.9543,27.5658,32.0393,30.0477,33.6633);
- this.context.bezierCurveTo(32.5055,35.2717,35.0375,35.6213,36.9758,35.563);
- this.context.bezierCurveTo(37.9445,35.534,38.7565,35.403,39.3219,35.2806);
- this.context.bezierCurveTo(39.6041,35.2195,39.8233,35.1608,39.9682,35.1188);
- this.context.bezierCurveTo(40.0407,35.0978,40.0944,35.081,40.1279,35.0701);
- this.context.bezierCurveTo(40.1373,35.0671,40.1451,35.0645,40.1512,35.0625);
- this.context.bezierCurveTo(40.1561,35.0609,40.16,35.0596,40.1629,35.0586);
- this.context.lineTo(40.1665,35.0574);
- this.context.lineTo(40.1686,35.0566);
- this.context.bezierCurveTo(40.6887,34.8739,41.2588,35.1466,41.4428,35.6665);
- this.context.bezierCurveTo(41.6271,36.1871,41.3544,36.7586,40.8337,36.9428);
- this.context.lineTo(40.5001,36.0001);
- this.context.bezierCurveTo(40.8337,36.9428,40.8342,36.9427,40.8337,36.9428);
- this.context.lineTo(40.8319,36.9435);
- this.context.lineTo(40.8295,36.9443);
- this.context.lineTo(40.8233,36.9465);
- this.context.lineTo(40.8046,36.9529);
- this.context.bezierCurveTo(40.7893,36.958,40.7687,36.9649,40.7427,36.9733);
- this.context.bezierCurveTo(40.6909,36.99,40.618,37.0128,40.5254,37.0396);
- this.context.bezierCurveTo(40.3403,37.0933,40.0763,37.1636,39.7451,37.2353);
- this.context.bezierCurveTo(39.0837,37.3785,38.1486,37.5287,37.0358,37.5621);
- this.context.bezierCurveTo(34.8114,37.6289,31.8434,37.2285,28.9525,35.3369);
- this.context.bezierCurveTo(26.0858,33.4609,24.476,31.0459,23.5854,29.1045);
- this.context.bezierCurveTo(23.1404,28.1344,22.8731,27.2789,22.7161,26.66);
- this.context.bezierCurveTo(22.6376,26.3502,22.5864,26.0986,22.5543,25.9202);
- this.context.bezierCurveTo(22.5383,25.8309,22.527,25.7598,22.5195,25.7088);
- this.context.bezierCurveTo(22.5157,25.6833,22.5129,25.6628,22.5108,25.6476);
- this.context.lineTo(22.5084,25.6286);
- this.context.lineTo(22.5076,25.6222);
- this.context.lineTo(22.5073,25.6197);
- this.context.lineTo(22.507,25.6177);
- this.context.bezierCurveTo(22.507,25.6172,22.507,25.6177,23.5001,25.5001);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawDeadBody(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.DeadBody) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.DeadBody) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.DeadBody) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="#040101";
- this.context.beginPath();
- this.context.moveTo(5.91335,12.2268);
- this.context.bezierCurveTo(4.35883,11.5123,3.17581,11.4098,2.00721,12.6867);
- this.context.lineTo(2,13.7478);
- this.context.bezierCurveTo(2.29231,15.0665,3.42071,15.5909,4.46298,16.0752);
- this.context.bezierCurveTo(4.51387,16.0989,4.56455,16.1224,4.61492,16.146);
- this.context.bezierCurveTo(11.3957,19.2976,16.3298,24.5608,21.2386,29.8665);
- this.context.bezierCurveTo(21.9491,30.6341,21.8878,31.0197,20.7841,31.1647);
- this.context.bezierCurveTo(19.2801,31.3628,18.7752,32.3001,19.0853,33.6654);
- this.context.bezierCurveTo(19.5326,35.6498,20.0123,37.627,20.6327,39.5689);
- this.context.bezierCurveTo(20.7153,39.9046,20.8859,40.2134,21.1276,40.4646);
- this.context.bezierCurveTo(21.3692,40.7159,21.6735,40.9009,22.0104,41.0015);
- this.context.lineTo(22.7318,41.0015);
- this.context.bezierCurveTo(23.5253,40.5699,23.9725,39.9403,23.785,39.0313);
- this.context.bezierCurveTo(23.7124,38.6795,23.6668,38.3204,23.6213,37.9616);
- this.context.bezierCurveTo(23.5492,37.3932,23.4772,36.8256,23.2981,36.29);
- this.context.bezierCurveTo(22.8184,34.8645,23.3702,34.5816,24.6975,34.7372);
- this.context.bezierCurveTo(26.9098,34.9961,28.9508,33.7344,30.5482,32.747);
- this.context.bezierCurveTo(31.0238,32.453,31.46,32.1833,31.8497,31.9853);
- this.context.bezierCurveTo(32.2324,31.7909,32.6231,31.5841,33.0213,31.3734);
- this.context.bezierCurveTo(34.3907,30.6486,35.848,29.8773,37.3681,29.4032);
- this.context.bezierCurveTo(37.9053,29.2344,38.2276,29.511,38.5499,29.7877);
- this.context.bezierCurveTo(38.6194,29.8473,38.6888,29.9069,38.7603,29.962);
- this.context.bezierCurveTo(40.191,31.0821,41.6277,32.2081,43.0705,33.34);
- this.context.bezierCurveTo(43.9,33.9908,44.7584,34.2986,45.5772,33.3789);
- this.context.bezierCurveTo(46.3959,32.4593,45.9018,31.6634,45.1444,30.956);
- this.context.bezierCurveTo(44.6458,30.494,44.1439,30.0346,43.6418,29.575);
- this.context.bezierCurveTo(42.4948,28.5252,41.3468,27.4745,40.2355,26.3895);
- this.context.bezierCurveTo(39.3158,25.4876,38.4213,25.0313,37.0796,25.5442);
- this.context.bezierCurveTo(34.0823,26.6973,25.2493,20.2632,24.7877,18.7175);
- this.context.bezierCurveTo(24.4268,17.5159,24.8984,16.0559,25.3601,14.6263);
- this.context.bezierCurveTo(25.5168,14.1411,25.6724,13.6594,25.794,13.1925);
- this.context.bezierCurveTo(26.1835,11.6715,25.5343,10.7589,24.1889,10.3628);
- this.context.bezierCurveTo(21.4117,9.55275,18.6056,8.84533,15.796,8.13791);
- this.context.bezierCurveTo(14.768,7.87969,13.7293,7.87262,13.3686,9.16721);
- this.context.bezierCurveTo(13.0404,10.3522,13.6211,11.0136,14.7356,11.4133);
- this.context.bezierCurveTo(16.5065,12.0535,18.263,12.7256,20.0159,13.433);
- this.context.bezierCurveTo(20.0817,13.4588,20.1525,13.4826,20.2245,13.5068);
- this.context.bezierCurveTo(20.6456,13.6484,21.1094,13.8043,20.8815,14.4658);
- this.context.bezierCurveTo(20.4549,15.6984,20.0227,16.9292,19.5629,18.2388);
- this.context.bezierCurveTo(19.3774,18.7669,19.1875,19.3079,18.9916,19.8671);
- this.context.bezierCurveTo(14.9916,16.4537,10.4759,14.3208,5.91335,12.2268);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(34.7105,32.0067);
- this.context.bezierCurveTo(32.6436,31.8937,31.1351,33.2167,31.0119,35.2432);
- this.context.bezierCurveTo(30.9738,35.7034,31.0276,36.1666,31.17,36.6057);
- this.context.bezierCurveTo(31.3124,37.0448,31.5406,37.4509,31.8411,37.8002);
- this.context.bezierCurveTo(32.1417,38.1495,32.5086,38.435,32.9204,38.6399);
- this.context.bezierCurveTo(33.3322,38.8448,33.7805,38.965,34.2391,38.9935);
- this.context.bezierCurveTo(35.1675,39.0499,36.0808,38.7378,36.7827,38.1244);
- this.context.bezierCurveTo(37.4845,37.511,37.9188,36.6452,37.9922,35.7133);
- this.context.bezierCurveTo(38.0231,35.2524,37.9623,34.79,37.8134,34.353);
- this.context.bezierCurveTo(37.6645,33.916,37.4305,33.5132,37.1249,33.1681);
- this.context.bezierCurveTo(36.8194,32.823,36.4486,32.5426,36.034,32.3432);
- this.context.bezierCurveTo(35.6195,32.1438,35.1695,32.0294,34.7105,32.0067);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- drawBloodStain(geometry) {
- const selectItem = stateService.getSelectItem()
- const draggingItem = stateService.getDraggingItem()
- const focusItem = stateService.getFocusItem()
- this.context.save()
- this.context.strokeStyle = Style.Sign.strokeStyle
- this.context.fillStyle = Style.Sign.fillStyle
- if (selectItem && selectItem.type == VectorType.BloodStain) {
- if (geometry.vectorId == selectItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- } else if (draggingItem && draggingItem.type == VectorType.BloodStain) {
- if (geometry.vectorId == draggingItem.vectorId) {
- this.context.strokeStyle = Style.Select.Sign.strokeStyle
- this.context.fillStyle = Style.Select.Sign.fillStyle
- }
- }
- if (focusItem && focusItem.type == VectorType.BloodStain) {
- if (geometry.vectorId == focusItem.vectorId) {
- this.context.strokeStyle = Style.Focus.Sign.strokeStyle
- this.context.fillStyle = Style.Focus.Sign.fillStyle
- }
- }
- const center = coordinate.getScreenXY({
- x: geometry.center.x,
- y: geometry.center.y,
- })
- const pt = coordinate.getScreenXY({
- x: geometry.center.x - (geometry.getLen() * geometry.scale) / 2,
- y: geometry.center.y + (geometry.getLen() * geometry.scale) / 2,
- })
- this.context.translate(center.x, center.y)
- this.context.rotate((geometry.angle / 180) * Math.PI)
- this.context.translate(pt.x - center.x, pt.y - center.y)
- this.context.scale((geometry.getLen() * geometry.scale * coordinate.res) / 32, (geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.lineWidth = 1 / ((geometry.getLen() * geometry.scale * coordinate.res) / 32)
- this.context.strokeStyle="rgba(0,0,0,0)";
- this.context.miterLimit=4;
- this.context.font="15px ''";
- this.context.fillStyle="#FF4D4F";
- this.context.beginPath();
- this.context.moveTo(11.7832,43.4124);
- this.context.bezierCurveTo(13.9788,44.5378,19.4679,44.5355,19.468,38.91);
- this.context.bezierCurveTo(19.468,33.2844,21.1146,29.3458,26.0549,28.7831);
- this.context.bezierCurveTo(26.3893,28.745,26.7385,28.7077,27.1002,28.669);
- this.context.bezierCurveTo(32.0834,28.1363,39.425,27.3516,42.5224,20.9046);
- this.context.bezierCurveTo(44.2471,17.3148,41.7011,10.7791,28.2507,7.40168);
- this.context.bezierCurveTo(14.3038,3.89964,6.84294,7.40168,5.19509,13.0273);
- this.context.bezierCurveTo(3.54725,18.6528,12.8799,26.5313,12.8799,26.5313);
- this.context.bezierCurveTo(12.8799,26.5313,16.1646,30.722,15.0766,33.2844);
- this.context.bezierCurveTo(14.9608,34.6355,13.8708,35.0844,12.6391,35.5917);
- this.context.bezierCurveTo(11.5358,36.0461,10.3188,36.5474,9.58641,37.7858);
- this.context.bezierCurveTo(8.03737,40.4055,9.58751,42.2871,11.7832,43.4124);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(32.8372,34.4465);
- this.context.bezierCurveTo(32.3576,36.4893,31.5484,37,29.9586,37);
- this.context.bezierCurveTo(28.3688,37,26.6003,35.9786,27.08,34.4465);
- this.context.bezierCurveTo(27.5598,32.9144,29.5522,32,31.1421,32);
- this.context.bezierCurveTo(32.7319,32,33.3169,32.4037,32.8372,34.4465);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.beginPath();
- this.context.moveTo(37.4462,43);
- this.context.bezierCurveTo(38.8566,43,40,42.3284,40,41.5);
- this.context.bezierCurveTo(40,40.6716,38.3459,40,36.9355,40);
- this.context.bezierCurveTo(35.525,40,35,40.6716,35,41.5);
- this.context.bezierCurveTo(35,42.3284,36.0358,43,37.4462,43);
- this.context.closePath();
- this.context.fill();
- this.context.stroke();
- this.context.restore();
- }
- /***************************************************************************************************************************************************************************************/
- }
- const draw = new Draw()
- export { draw }
|