MCPcopy Create free account
hub / github.com/codecombat/codecombat / createLineForEditor

Method createLineForEditor

app/views/play/CampaignView.js:1485–1497  ·  view source on GitHub ↗
(o1, o2, options = {})

Source from the content-addressed store, hash-verified

1483 }
1484
1485 createLineForEditor (o1, o2, options = {}) {
1486 const mapHeight = parseFloat($('.map').css('height'))
1487 const mapWidth = parseFloat($('.map').css('width'))
1488 if (!(mapHeight > 0)) { return }
1489 const ratio = mapWidth / mapHeight
1490 const p1 = { x: o1.x, y: o1.y / ratio }
1491 const p2 = { x: o2.x, y: o2.y / ratio }
1492 const length = Math.sqrt(Math.pow(p1.x - p2.x, 2) + Math.pow(p1.y - p2.y, 2))
1493 const angle = (Math.atan2(p1.y - p2.y, p2.x - p1.x) * 180) / Math.PI
1494 const transform = `translateY(-50%) translateX(-50%) rotate(${angle}deg) translateX(50%)`
1495 const line = $('<div>').appendTo('.map').addClass('next-level-line').toggleClass('thin-connection', !!options.thin).css({ transform, width: length + '%', left: o1.x + '%', bottom: (o1.y - 0.5) + '%' })
1496 return line.append($('<div class="line">')).append($('<div class="point">'))
1497 }
1498
1499 createVisualConnections () {
1500 const visualConnections = this.campaign?.get('visualConnections') || []

Callers 1

createLinesForEditorMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected