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

Add BlRoundedPolygonGeometry #490

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

tinchodias
Copy link
Collaborator

Fixes issue #451

TO DO:

  • tests needed
  • containsPoint: is not precise
  • we should cache some calculated values, to avoid repeating the same maths on every new frame
  • this is the closed polygon, it's a pity we don't support being an open geometry (a "polyline")
  • we may decide to do some refactorings such as merge it with it's superclass

- tests needed
- containsPoint: is not precise
- we should cache some calculated values, to avoid repeating the same maths on every new frame
- this is the closed polygon, it's a pity we don't support being an open geometry (a "polyline")
- we may decide to do some refactorings such as merge it with it's superclass
@tinchodias
Copy link
Collaborator Author

An example:

triangleCorners := {
	0 @ 0.
	100 @ 0.
	100 @ 100.
	200 @ 100.
	200 @ 200.
	0 @ 200.
	}.

ref := BlElement new
	position: 50 asPoint;
	geometry: (BlPolygonGeometry vertices: triangleCorners);
	background: Color darkGray;
	yourself.

e := BlElement new
	opacity: 0.75;
	position: 50 asPoint;
	geometry:
		(BlRoundedPolygonGeometry
			vertices: triangleCorners
			radius: 30);
	background: Color red;
	yourself.

e addEventHandlerOn: BlMouseEnterEvent do: [ :evt |
	evt consumed: true.
	evt target background: Color green ].
e addEventHandlerOn: BlMouseLeaveEvent do: [ :evt |
	evt consumed: true.
	evt target background: Color red ].

space := BlSpace new.
space useMorphicHost.
space extent: 300 asPoint.
space root
	addChild: ref;
	addChild: e.
space show.
Screen.Recording.2024-04-08.at.10.02.11.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant