<template>
  <div :style="styles"></div>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import { rgbToHex } from '@/functions/colours';
import { DataOverlayMcad } from '@3cr/viewer-types-ts';

interface Props {
  mcad: DataOverlayMcad;
  size?: number;
}

const props = withDefaults(defineProps<Props>(), {
  size: 12
});

const color = computed(() => {
  const { R, G, B } = props.mcad.Colour;
  const toByte = (n: number) => n * 255;
  return rgbToHex(toByte(R), toByte(G), toByte(B));
});

const styles = computed(() => {
  return {
    display: 'inline-block',
    'background-color': color.value,
    width: '8px',
    height: '8px',
    'border-radius': '50px'
  };
});
</script>
