mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: circles
This commit is contained in:
1 parent
20f54a39d6
commit
67f9147aac
2 files changed
+28
-11
No files matched your search
+27
-10
@@ -1,23 +1,40 @@
|
|||||||
import { imgur } from '@blitzkit/core';
|
import { imgur } from '@blitzkit/core';
|
||||||
import { Box, type BoxProps } from '@radix-ui/themes';
|
import { Box, type BoxProps } from '@radix-ui/themes';
|
||||||
|
import { times } from 'lodash-es';
|
||||||
import { forwardRef } from 'react';
|
import { forwardRef } from 'react';
|
||||||
import { Var } from '../../../../../../../../core/radix/var';
|
import { Var } from '../../../../../../../../core/radix/var';
|
||||||
|
|
||||||
|
const DOTS = 32;
|
||||||
|
|
||||||
export const TargetCircle = forwardRef<HTMLDivElement, BoxProps>(
|
export const TargetCircle = forwardRef<HTMLDivElement, BoxProps>(
|
||||||
({ style, ...props }, ref) => {
|
({ ...props }, ref) => {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
ref={ref}
|
ref={ref}
|
||||||
width="10em"
|
|
||||||
height="10em"
|
|
||||||
style={{
|
|
||||||
borderRadius: '50%',
|
|
||||||
border: `0.125rem solid ${Var('green-9')}`,
|
|
||||||
...style,
|
|
||||||
}}
|
|
||||||
position="relative"
|
position="relative"
|
||||||
{...props}
|
{...props}
|
||||||
|
minWidth="23px"
|
||||||
|
minHeight="23px"
|
||||||
>
|
>
|
||||||
|
{times(DOTS, (index) => {
|
||||||
|
const angle = 2 * Math.PI * (index / DOTS);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
key={index}
|
||||||
|
style={{
|
||||||
|
borderRadius: '50%',
|
||||||
|
background: Var('grass-11'),
|
||||||
|
transform: `translate(-50%, -50%)`,
|
||||||
|
position: 'absolute',
|
||||||
|
}}
|
||||||
|
top={`${(0.5 * Math.sin(angle) + 0.5) * 100}%`}
|
||||||
|
left={`${(0.5 * Math.cos(angle) + 0.5) * 100}%`}
|
||||||
|
width={`${1 / 6}rem`}
|
||||||
|
height={`${1 / 6}rem`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
<Box
|
<Box
|
||||||
width="1rem"
|
width="1rem"
|
||||||
height="1rem"
|
height="1rem"
|
||||||
@@ -25,9 +42,9 @@ export const TargetCircle = forwardRef<HTMLDivElement, BoxProps>(
|
|||||||
top="50%"
|
top="50%"
|
||||||
left="50%"
|
left="50%"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(${imgur('kU9Xejd')})`,
|
backgroundImage: `url(${imgur('27Gwth4')})`,
|
||||||
backgroundSize: 'contain',
|
backgroundSize: 'contain',
|
||||||
transform: 'translateX(-50%) scale(90%)',
|
transform: 'translateX(-50%)',
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
+1
-1
@@ -208,7 +208,7 @@ export function SceneProps() {
|
|||||||
2 * Math.tan(degToRad((camera as PerspectiveCamera).fov) / 2);
|
2 * Math.tan(degToRad((camera as PerspectiveCamera).fov) / 2);
|
||||||
const screenSpaceSize =
|
const screenSpaceSize =
|
||||||
gl.domElement.clientHeight * (angularSize / verticalScreenSize);
|
gl.domElement.clientHeight * (angularSize / verticalScreenSize);
|
||||||
const targetCircleDotsSize = `${Math.max(38, screenSpaceSize)}px`;
|
const targetCircleDotsSize = `${screenSpaceSize}px`;
|
||||||
|
|
||||||
targetCircle.current.style.width = targetCircleDotsSize;
|
targetCircle.current.style.width = targetCircleDotsSize;
|
||||||
targetCircle.current.style.height = targetCircleDotsSize;
|
targetCircle.current.style.height = targetCircleDotsSize;
|
||||||
|
|||||||
Reference in new issue
Block a user