Skip to content

Instantly share code, notes, and snippets.

@betafcc
Last active December 23, 2023 20:35
Show Gist options
  • Select an option

  • Save betafcc/a9e0fe1b02228e0153ccd3e1cf0fd571 to your computer and use it in GitHub Desktop.

Select an option

Save betafcc/a9e0fe1b02228e0153ccd3e1cf0fd571 to your computer and use it in GitHub Desktop.

Revisions

  1. betafcc revised this gist Dec 23, 2023. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions Ticks.tsx
    Original file line number Diff line number Diff line change
    @@ -9,18 +9,20 @@ export const Ticks: FC<
    count: number
    length: number
    width: number
    align: 'in' | 'out' | 'center'
    }
    > = ({ r, count, length, width, ...props }) => {
    > = ({ r, count, length, width, align, ...props }) => {
    const C = 2 * Math.PI * r

    return (
    <circle
    {...props}
    r={r}
    r={align === 'in' ? r - length / 2 : align === 'out' ? r + length / 2 : r}
    strokeWidth={length}
    pathLength={C}
    strokeDasharray={`${width} ${C / count - width}`}
    strokeDashoffset={`${width / 2}`}
    />
    )
    }

  2. betafcc created this gist Dec 23, 2023.
    26 changes: 26 additions & 0 deletions Ticks.tsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,26 @@
    import { ComponentProps, FC } from 'react'

    export const Ticks: FC<
    Omit<
    ComponentProps<'circle'>,
    'strokeWidth' | 'pathLength' | 'strokeDasharray' | 'strokeDashoffset' | 'r'
    > & {
    r: number
    count: number
    length: number
    width: number
    }
    > = ({ r, count, length, width, ...props }) => {
    const C = 2 * Math.PI * r

    return (
    <circle
    {...props}
    r={r}
    strokeWidth={length}
    pathLength={C}
    strokeDasharray={`${width} ${C / count - width}`}
    strokeDashoffset={`${width / 2}`}
    />
    )
    }