website

source code for the ttmaths.uk website
Log | Files | Refs | README

Segment.jsx (462B)


      1 import { getColourClass, getMidpoint } from "../../scripts/graphUtils";
      2 
      3 export default function Segment({ points, marker = null, colour = "auto" }) {
      4   if (!marker) {
      5     const [i, f] = points;
      6     return <line x1={i[0]} y1={i[1]} x2={f[0]} y2={f[1]} class={getColourClass(colour)} />;
      7   }
      8   const allPoints = [points[0], getMidpoint(points), points[1]];
      9   return <polyline points={allPoints} marker-mid={`url(#${marker})`} class={getColourClass(colour)} />;
     10 }