Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polygon side tweening moves the 0 point on the middle of the created edge #1041

Closed
HastagGuigui opened this issue May 14, 2024 · 1 comment · Fixed by #1045
Closed

Polygon side tweening moves the 0 point on the middle of the created edge #1041

HastagGuigui opened this issue May 14, 2024 · 1 comment · Fixed by #1045
Assignees
Labels
a-2d Relates to the 2d package b-enhancement New feature or request c-accepted The issue is ready to be worked on

Comments

@HastagGuigui
Copy link

Describe the bug
I'm working on a maths animation and there's a part involving a polygon with circles on each vertex, but tweening its side count results in the 0 point of getPointAtPercentage to being moved to the middle of the created edge.
image

To Reproduce

export default makeScene2D(function* (view) {
  let polygon = createRef<Polygon>();

	let side_count = createSignal(3);

	view.add(
		<Polygon ref={polygon} sides={()=>side_count()} lineWidth={8} stroke={"white"} size={512} y={200} opacity={0}/>
	)
	const cercles: Circle[] = [];
	polygon().add(
		<>
		{range(10).map(index => (
			<Circle 
				ref={makeRef(cercles, index)}
				position={() => polygon().getPointAtPercentage(index/side_count()).position}
				lineWidth={8}
				stroke={"white"}
				size={() => polygon().getPointAtPercentage(0).position.sub(
						polygon().getPointAtPercentage(1/side_count()).position).magnitude
				}
				opacity={() => index+0.9>=side_count() ? 0.0 : 1.0}
			>
			<Txt stroke={"black"} fill={"white"} lineWidth={4} fontSize={32}
				strokeFirst={true}
				text={() => "" + index/side_count()}/>
			</Circle>
		))}
		</>
	);
	yield* side_count(10, 2.0).wait(0.5).to(3, 2.0);


});

Expected behavior
I would have expected the 0 point to be on a vertex... not entirely sure actually, but I wish there was an easier way to get a polygon's points.

Package versions:

  • core: 3.15.2
  • two: 3.15.2
  • ui: 3.15.2
  • vitePlugin: 3.15.1

Additional context
Not sure if this is a bug or just jank

@HastagGuigui HastagGuigui added the b-bug Something isn't working label May 14, 2024
@HastagGuigui
Copy link
Author

nevermind middle of the edge is intended it's just the other circles end up misaligned for a reason I don't know

@aarthificial aarthificial added b-enhancement New feature or request c-accepted The issue is ready to be worked on a-2d Relates to the 2d package and removed b-bug Something isn't working labels May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a-2d Relates to the 2d package b-enhancement New feature or request c-accepted The issue is ready to be worked on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants