aotds-docks/src/lib/components/Weapons/Arc.svelte

51 lines
842 B
Svelte
Raw Normal View History

2022-03-01 17:42:33 +00:00
<g {transform}>
<path d={path} class:active on:click />
</g>
2020-07-19 20:21:28 +00:00
<script>
2022-03-01 17:42:33 +00:00
export let arc;
export let radius;
export let active = false;
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
const rotation = {
2020-07-19 20:21:28 +00:00
F: 0,
FS: 300,
AS: 240,
A: 180,
AP: 120,
FP: 60,
2022-03-01 17:42:33 +00:00
};
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
let y, x_delta;
$: y = Math.round(radius * (1 - Math.sin((60 / 180) * Math.PI)));
$: x_delta = Math.round(radius * Math.cos((60 / 180) * Math.PI));
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
let path;
$: path = `M ${radius},${radius} L ${
radius - x_delta
},${y} A ${radius},${radius} 0 0 1 ${radius + x_delta},${y} Z`;
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
let transform;
$: transform = `rotate(${rotation[arc]},${radius},${radius})`;
2020-07-19 20:21:28 +00:00
</script>
<style>
2022-03-01 17:42:33 +00:00
path {
2020-07-19 20:21:28 +00:00
fill: lightgrey;
stroke: white;
stroke-width: 2px;
2022-03-01 17:42:33 +00:00
}
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
path:hover {
2020-07-19 20:21:28 +00:00
fill: pink;
2022-03-01 17:42:33 +00:00
}
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
path.active:hover {
2020-07-19 20:21:28 +00:00
fill: pink;
2022-03-01 17:42:33 +00:00
}
2020-07-19 20:21:28 +00:00
2022-03-01 17:42:33 +00:00
path.active {
2020-07-19 20:21:28 +00:00
fill: #313131;
2022-03-01 17:42:33 +00:00
}
2020-07-19 20:21:28 +00:00
</style>