Skip to content
This repository has been archived by the owner on Jun 9, 2023. It is now read-only.

Circle variants for drawing modes #35

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft

Circle variants for drawing modes #35

wants to merge 19 commits into from

Conversation

fsobolev
Copy link
Owner

@fsobolev fsobolev commented Jan 31, 2023

PR to track progress of implementing Circle variants for drawing modes

Related issue: #7

@gregorni
Copy link
Collaborator

Nice

@gregorni
Copy link
Collaborator

Spine could actually look really cool in circle mode.

@gregorni
Copy link
Collaborator

I think Wave should be filled completely in circle instead of having a blank circle on the inside. We could think about introducing a setting for that, but I'm not sure if that's worth it.

@gregorni
Copy link
Collaborator

Looks amazing otherwise!

@fsobolev
Copy link
Owner Author

I think Wave should be filled completely in circle instead of having a blank circle on the inside. We could think about introducing a setting for that, but I'm not sure if that's worth it.

The setting would be a good compromise. Probably called "wave-circle-fill" in the schema, and in the UI it would be a switch with description "Fill completely", it can be added as the suffix of Wave row and only shown when Circle is on.

@fsobolev
Copy link
Owner Author

fsobolev commented Feb 2, 2023

Wave Circle Fill option added. It's not shown when Box variant is selected.

@fsobolev
Copy link
Owner Author

fsobolev commented Feb 2, 2023

It's probably can be expected from Circle Bars mode to have bars with constant width... But IMO this looks way cooler

@gregorni
Copy link
Collaborator

gregorni commented Feb 2, 2023

I can look into the code and see if I can work on some of the other modes. Problem is, I don't know anything about those Sinus and Cosinus functions.

@fsobolev
Copy link
Owner Author

fsobolev commented Feb 2, 2023

Problem is, I don't know anything about those Sinus and Cosinus functions.

They are used to get coordinates of a point on a circle. The formula is:

x = cos(angle) * radius
y = sin(angle) * radius

Let's see how it works with Bars. The x coordinate of the first point of a bar is calculated like this:

width / 2 + math.cos(2 * math.pi / ls * (i + offset / 100) - 0.5 * math.pi) * min_radius,

First we need to find an angle in radians. 2 * math.pi is the full circle (= 360 deg). It's divided by number of bars, and then multiplied by the index of current bar + offset. Imagine like you're slicing a pizza, let's say you want to share it across 12 people, but you can only cut from center to sides, so you need to do 12 cuts, each one rotated relatively to previous one by fixed angle, that's basically how it works 😄
- 0.5 * math.pi (- 90 deg) is used to rotate everything so the angle 0 will be on top of the circle instead of the right.
So now we have an angle, it's time to get it's cosinus and then multiply it by radius.
But since we want to draw our circle from the center of the area instead of the beginning of coordinates, width / 2 is added.
y coordinate is calculated the same, but using height and sinus instead of width and cosinus respectively.

Hope it helps you to understand how this works :)

@gregorni
Copy link
Collaborator

gregorni commented Feb 2, 2023

Thanks! I'll see what I can do from there.

@fsobolev
Copy link
Owner Author

fsobolev commented Feb 5, 2023

All changes made in #38 were merged here and I made Bars Circle mode working with proper use of offset and thickness.
There are 2 problems with this mode tho:

  1. To avoid really broken look, thickness was limited, but I didn't find good maximum value yet, currently it's limited to circle_length / number_of_bars * 0.25 which makes it maximum 12 when maximized (on 1360x768 display), so it's not very good.
  2. CPU usage is insane due to complex calculation of angles depending on thickness. It uses 7-10% more CPU for me compared to the same settings with Boxed variant. I hope to at least partially fix it by moving some calculations out of the loop to calculate most numbers once per frame instead of for each bar, I will do it tomorrow.

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

Successfully merging this pull request may close these issues.

2 participants