why conic gradients cause aliasing when the value is an integer %?

compare both images. if i add 0.5, it looks smooth, if i don't then it looks jagged and ugly. why would it do this? is it performance traded for looks? but this is super jarring and ugly. can i even force it to use anti-aliasing without having to add 0.5?
No description
No description
21 Replies
Shane
Shane3mo ago
that is just how it's implemented
ἔρως
ἔρως3mo ago
it clearly can handle not looking like a staircase, so
Shane
Shane3mo ago
When I had to do something similar (pie chart) I built a SVG generator because I couldn't get conic gradients to do antialiasing
ἔρως
ἔρως3mo ago
i add 0.5 to the value, and it works
Shane
Shane3mo ago
If you do everything at perfect 1/8th? increments it looks fine iirc
ἔρως
ἔρως3mo ago
but, as you can imagine, i would rather not
Shane
Shane3mo ago
its ugly though its blurred, not true aliasing
ἔρως
ἔρως3mo ago
i know but it's close enough for what i needed it for what i need, the svg generator won't work, as i need html and css
Shane
Shane3mo ago
html can do svg directly tho You could also do it with clip path and some math in CSS if you hate yourself
ἔρως
ἔρως3mo ago
yes, but i need it to update with just css and html
Shane
Shane3mo ago
svg animations exist
ἔρως
ἔρως3mo ago
i know but i didn't knew how to make them work at the time i wrote that
ChooKing
ChooKing3mo ago
I never see this problem when I use degrees instead of percents.
ἔρως
ἔρως3mo ago
does it work well with rads instead of degrees?
Shane
Shane3mo ago
it has the same issue with degrees
Shane
Shane3mo ago
@ἔρως here is my cursed clip path solution https://codepen.io/Thisisntme/pen/LYvojPd
Shane
CodePen
LYvojPd
...
ἔρως
ἔρως3mo ago
that works. it's a pain to implement, but works
ChooKing
ChooKing3mo ago
Are you using the exact same starting value as the ending value of the previous color? It has to be slightly off. When I use degrees, I add 0.2 degrees to the next value. For example:
background-image: conic-gradient(blue 47deg, white 47.2deg);
background-image: conic-gradient(blue 47deg, white 47.2deg);
This should also work with percents, but I don't know the proper amount to add.
ἔρως
ἔρως3mo ago
no, i add 0.5
MarkBoots
MarkBoots3mo ago
i like to put the colorstops in custom vars and calc the "bleed" both ways. that way it's easy to change and the actual switch of the color happens on the meant value It's a bit more code, but easier to control
--stop1: 47deg;
--bleed: .5deg;
background-image: conic-gradient(
blue calc(var(--stop1) - var(--bleed) / 2)),
white calc(var(--stop1) + var(--bleed) / 2))
);
--stop1: 47deg;
--bleed: .5deg;
background-image: conic-gradient(
blue calc(var(--stop1) - var(--bleed) / 2)),
white calc(var(--stop1) + var(--bleed) / 2))
);
ἔρως
ἔρως3mo ago
that is interesting