Files
aowow/setup/tools/filegen/templates/global.js/line.js
Sarjuuk 6557e70d5c Template/Update (Part 47)
* split global.js into its components, so it can be reasonably processed by setup
 * make reputation requirements configurable
 * move Markup and Locale back into global.js (removed associated build scripts)
 * extend Icon to display iconId in lightbox popup
2025-09-25 16:01:14 +02:00

39 lines
1.3 KiB
JavaScript

function Line(x1, y1, x2, y2, type)
{
var left = Math.min(x1, x2),
right = Math.max(x1, x2),
top = Math.min(y1, y2),
bottom = Math.max(y1, y2),
width = (right - left),
height = (bottom - top),
length = Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)),
radian = Math.atan2(height, width),
sinTheta = Math.sin(radian),
cosTheta = Math.cos(radian);
var $line = $WH.ce('span');
$line.className = 'line';
$line.style.top = top.toFixed(2) + 'px';
$line.style.left = left.toFixed(2) + 'px';
$line.style.width = width.toFixed(2) + 'px';
$line.style.height = height.toFixed(2) + 'px';
var v = $WH.ce('var');
v.style.width = length.toFixed(2) + 'px';
v.style.OTransform = 'rotate(' + radian + 'rad)';
v.style.MozTransform = 'rotate(' + radian + 'rad)';
v.style.webkitTransform = 'rotate(' + radian + 'rad)';
v.style.filter = "progid:DXImageTransform.Microsoft.Matrix(sizingMethod='auto expand', M11=" + cosTheta + ', M12=' + (-1 * sinTheta) + ', M21=' + sinTheta + ', M22=' + cosTheta + ')';
$WH.ae($line, v);
if (!(x1 == left && y1 == top) && !(x2 == left && y2 == top))
$line.className += ' flipped';
if (type != null)
$line.className += ' line-' + type;
return $line;
}