home.social

#cssmaths — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #cssmaths, aggregated by home.social.

  1. That is, we need to add:
    i*2*α_dx

    If k > 1, then we need to add half a turn as well, that is:
    round(down, k)*180°

    Adding these to the angular progress along the edge, we get the conic-gradient angle producing a point that moves at constant speed along the perimeter.

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  2. That is, we need to add:
    i*2*α_dx

    If k > 1, then we need to add half a turn as well, that is:
    round(down, k)*180°

    Adding these to the angular progress along the edge, we get the conic-gradient angle producing a point that moves at constant speed along the perimeter.

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  3. That is, we need to add:
    i*2*α_dx

    If k > 1, then we need to add half a turn as well, that is:
    round(down, k)*180°

    Adding these to the angular progress along the edge, we get the conic-gradient angle producing a point that moves at constant speed along the perimeter.

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  4. That is, we need to add:
    i*2*α_dx

    If k > 1, then we need to add half a turn as well, that is:
    round(down, k)*180°

    Adding these to the angular progress along the edge, we get the conic-gradient angle producing a point that moves at constant speed along the perimeter.

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  5. We know the distance from the middle of the rectangle to the middle of the current edge.

    It's half the length of the other edge:
    j*50cqw + i*50cqh

    Absolute value of the absolute distance of the current progress point to the middle of the edge it's on:
    (p - .5)*(j*100cqh + i*100cqw)

    These form a right triangle out of which we can get the angle of their hypotenuse with the axis perpendicular onto the current edge.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  6. We know the distance from the middle of the rectangle to the middle of the current edge.

    It's half the length of the other edge:
    j*50cqw + i*50cqh

    Absolute value of the absolute distance of the current progress point to the middle of the edge it's on:
    (p - .5)*(j*100cqh + i*100cqw)

    These form a right triangle out of which we can get the angle of their hypotenuse with the axis perpendicular onto the current edge.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  7. We know the distance from the middle of the rectangle to the middle of the current edge.

    It's half the length of the other edge:
    j*50cqw + i*50cqh

    Absolute value of the absolute distance of the current progress point to the middle of the edge it's on:
    (p - .5)*(j*100cqh + i*100cqw)

    These form a right triangle out of which we can get the angle of their hypotenuse with the axis perpendicular onto the current edge.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  8. We know the distance from the middle of the rectangle to the middle of the current edge.

    It's half the length of the other edge:
    j*50cqw + i*50cqh

    Absolute value of the absolute distance of the current progress point to the middle of the edge it's on:
    (p - .5)*(j*100cqh + i*100cqw)

    These form a right triangle out of which we can get the angle of their hypotenuse with the axis perpendicular onto the current edge.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  9. Progress along a vertical edge is:
    mod(k, 1)/f
    Progress along a horizontal one is:
    (mod(k, 1) - f)/(1 - f)

    Progress along a generic edge is:
    p = j*mod(k, 1)/f + i*(mod(k, 1) - f)/(1 - f)

    Length traveled along the current generic edge:
    j*mod(k, 1)/f*100cqh +
    i*(mod(k, 1) - f)/(1 - f)*100cqw

    Signed relative distance from middle of the current generic edge: p - .5

    We get the absolute value of this difference & its sign.

    #CSS #coding #web #dev #webDev #webDevelopment #frontend #cssMaths #code

  10. Progress along a vertical edge is:
    mod(k, 1)/f
    Progress along a horizontal one is:
    (mod(k, 1) - f)/(1 - f)

    Progress along a generic edge is:
    p = j*mod(k, 1)/f + i*(mod(k, 1) - f)/(1 - f)

    Length traveled along the current generic edge:
    j*mod(k, 1)/f*100cqh +
    i*(mod(k, 1) - f)/(1 - f)*100cqw

    Signed relative distance from middle of the current generic edge: p - .5

    We get the absolute value of this difference & its sign.

    #CSS #coding #web #dev #webDev #webDevelopment #frontend #cssMaths #code

  11. Progress along a vertical edge is:
    mod(k, 1)/f
    Progress along a horizontal one is:
    (mod(k, 1) - f)/(1 - f)

    Progress along a generic edge is:
    p = j*mod(k, 1)/f + i*(mod(k, 1) - f)/(1 - f)

    Length traveled along the current generic edge:
    j*mod(k, 1)/f*100cqh +
    i*(mod(k, 1) - f)/(1 - f)*100cqw

    Signed relative distance from middle of the current generic edge: p - .5

    We get the absolute value of this difference & its sign.

    #CSS #coding #web #dev #webDev #webDevelopment #frontend #cssMaths #code

  12. Progress along a vertical edge is:
    mod(k, 1)/f
    Progress along a horizontal one is:
    (mod(k, 1) - f)/(1 - f)

    Progress along a generic edge is:
    p = j*mod(k, 1)/f + i*(mod(k, 1) - f)/(1 - f)

    Length traveled along the current generic edge:
    j*mod(k, 1)/f*100cqh +
    i*(mod(k, 1) - f)/(1 - f)*100cqw

    Signed relative distance from middle of the current generic edge: p - .5

    We get the absolute value of this difference & its sign.

    #CSS #coding #web #dev #webDev #webDevelopment #frontend #cssMaths #code

  13. We also compute its complementary j = 1 - i.
    Idea css-tricks.com/logical-operati

    Basically, we have:
    i = max(0, sign(mod(k, 1) - f))
    j = 1 - i

    i = 0, j = 1 on vertical edge (incl. corner)
    i = 1, j = 0 on horizontal edge (after corner)

    Now we compute things for going along vertical & horizontal edges separately and use i & j to switch between them. That is, multiply vertical results with j and horizontal ones with i.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  14. We also compute its complementary j = 1 - i.
    Idea css-tricks.com/logical-operati

    Basically, we have:
    i = max(0, sign(mod(k, 1) - f))
    j = 1 - i

    i = 0, j = 1 on vertical edge (incl. corner)
    i = 1, j = 0 on horizontal edge (after corner)

    Now we compute things for going along vertical & horizontal edges separately and use i & j to switch between them. That is, multiply vertical results with j and horizontal ones with i.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  15. We also compute its complementary j = 1 - i.
    Idea css-tricks.com/logical-operati

    Basically, we have:
    i = max(0, sign(mod(k, 1) - f))
    j = 1 - i

    i = 0, j = 1 on vertical edge (incl. corner)
    i = 1, j = 0 on horizontal edge (after corner)

    Now we compute things for going along vertical & horizontal edges separately and use i & j to switch between them. That is, multiply vertical results with j and horizontal ones with i.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  16. We also compute its complementary j = 1 - i.
    Idea css-tricks.com/logical-operati

    Basically, we have:
    i = max(0, sign(mod(k, 1) - f))
    j = 1 - i

    i = 0, j = 1 on vertical edge (incl. corner)
    i = 1, j = 0 on horizontal edge (after corner)

    Now we compute things for going along vertical & horizontal edges separately and use i & j to switch between them. That is, multiply vertical results with j and horizontal ones with i.

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  17. Moving further, we'll be computing the progress of mod(k, 1). Starting from the top left corner, once we go across half a perimeter, the cycle of going along a vertical edge, then along a horizontal one repeats.

    There are 2 cases:
    mod(k, 1) <=f (going along a vertical edge)
    mod(k, 1) > 1 (going along a horizontal one)

    These two cases repeat once more after the halfway point (bottom left corner since we're starting from the top right).

    #CSS #code #coding #web #dev #frontend #Maths #cssMaths

  18. Moving further, we'll be computing the progress of mod(k, 1). Starting from the top left corner, once we go across half a perimeter, the cycle of going along a vertical edge, then along a horizontal one repeats.

    There are 2 cases:
    mod(k, 1) <=f (going along a vertical edge)
    mod(k, 1) > 1 (going along a horizontal one)

    These two cases repeat once more after the halfway point (bottom left corner since we're starting from the top right).

    #CSS #code #coding #web #dev #frontend #Maths #cssMaths

  19. Moving further, we'll be computing the progress of mod(k, 1). Starting from the top left corner, once we go across half a perimeter, the cycle of going along a vertical edge, then along a horizontal one repeats.

    There are 2 cases:
    mod(k, 1) <=f (going along a vertical edge)
    mod(k, 1) > 1 (going along a horizontal one)

    These two cases repeat once more after the halfway point (bottom left corner since we're starting from the top right).

    #CSS #code #coding #web #dev #frontend #Maths #cssMaths

  20. Moving further, we'll be computing the progress of mod(k, 1). Starting from the top left corner, once we go across half a perimeter, the cycle of going along a vertical edge, then along a horizontal one repeats.

    There are 2 cases:
    mod(k, 1) <=f (going along a vertical edge)
    mod(k, 1) > 1 (going along a horizontal one)

    These two cases repeat once more after the halfway point (bottom left corner since we're starting from the top right).

    #CSS #code #coding #web #dev #frontend #Maths #cssMaths

  21. If progress at the bottom left corner (= at half the perimeter starting from the top right corner) is 1, then progress at the bottom right corner is the height 100cqh over half the perimeter (one height 100cqh plus one width 100cqw):

    f = 100cqh/(100cqh + 100cqw)

    Dividing lengths is supported by Safari & Chrome + we have a Firefox fallback frontendmasters.com/blog/count

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  22. If progress at the bottom left corner (= at half the perimeter starting from the top right corner) is 1, then progress at the bottom right corner is the height 100cqh over half the perimeter (one height 100cqh plus one width 100cqw):

    f = 100cqh/(100cqh + 100cqw)

    Dividing lengths is supported by Safari & Chrome + we have a Firefox fallback frontendmasters.com/blog/count

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  23. If progress at the bottom left corner (= at half the perimeter starting from the top right corner) is 1, then progress at the bottom right corner is the height 100cqh over half the perimeter (one height 100cqh plus one width 100cqw):

    f = 100cqh/(100cqh + 100cqw)

    Dividing lengths is supported by Safari & Chrome + we have a Firefox fallback frontendmasters.com/blog/count

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  24. If progress at the bottom left corner (= at half the perimeter starting from the top right corner) is 1, then progress at the bottom right corner is the height 100cqh over half the perimeter (one height 100cqh plus one width 100cqw):

    f = 100cqh/(100cqh + 100cqw)

    Dividing lengths is supported by Safari & Chrome + we have a Firefox fallback frontendmasters.com/blog/count

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  25. Anyway, what we want to animate here linearly isn't a conic-gradient() angle, it's the progress around the perimeter.

    This is k, going from 0 to 2. When k is 0, we're at the top right corner. When it's 1, we're at the bottom left corner, having gone across half the perimeter.

    What about the progress value at the bottom right? We'll be calling that f, but how much is it?

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  26. Anyway, what we want to animate here linearly isn't a conic-gradient() angle, it's the progress around the perimeter.

    This is k, going from 0 to 2. When k is 0, we're at the top right corner. When it's 1, we're at the bottom left corner, having gone across half the perimeter.

    What about the progress value at the bottom right? We'll be calling that f, but how much is it?

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  27. Anyway, what we want to animate here linearly isn't a conic-gradient() angle, it's the progress around the perimeter.

    This is k, going from 0 to 2. When k is 0, we're at the top right corner. When it's 1, we're at the bottom left corner, having gone across half the perimeter.

    What about the progress value at the bottom right? We'll be calling that f, but how much is it?

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  28. Anyway, what we want to animate here linearly isn't a conic-gradient() angle, it's the progress around the perimeter.

    This is k, going from 0 to 2. When k is 0, we're at the top right corner. When it's 1, we're at the bottom left corner, having gone across half the perimeter.

    What about the progress value at the bottom right? We'll be calling that f, but how much is it?

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  29. We can also compute half the perimeter as:

    100cqh + 100cqw

    ---

    By the way, this container technique is also what I've used to compute the aspect ratio of images of unknown dimensions (and therefore aspect ratio) in order to determine along which edge they should get a blur extension to square - check out the article! frontendmasters.com/blog/non-s

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  30. We can also compute half the perimeter as:

    100cqh + 100cqw

    ---

    By the way, this container technique is also what I've used to compute the aspect ratio of images of unknown dimensions (and therefore aspect ratio) in order to determine along which edge they should get a blur extension to square - check out the article! frontendmasters.com/blog/non-s

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  31. We can also compute half the perimeter as:

    100cqh + 100cqw

    ---

    By the way, this container technique is also what I've used to compute the aspect ratio of images of unknown dimensions (and therefore aspect ratio) in order to determine along which edge they should get a blur extension to square - check out the article! frontendmasters.com/blog/non-s

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  32. We can also compute half the perimeter as:

    100cqh + 100cqw

    ---

    By the way, this container technique is also what I've used to compute the aspect ratio of images of unknown dimensions (and therefore aspect ratio) in order to determine along which edge they should get a blur extension to square - check out the article! frontendmasters.com/blog/non-s

    #CSS #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  33. Idea behind the mathy solution: card's dimensions are given by its text content. It has an absolutely positioned child .back covering its entire area, but placed behind. This .back is sized explicitly relative to its parent, so its pseudos know its dimensions if we make it a container: they're 100cqw and 100cqh. These allow us to compute the angles of the rectangle diagonal with the horizontal α_dx & with the vertical α_dy as:

    α_dx = atan2(100cqh, 100cqw)
    α_dy = 90° - α_dx

    #CSS #code #cssMaths

  34. On gradient borders & common issues with them reddit.com/r/css/comments/1tfm

    If you've ever wanted to create constant length/ speed border segments on non-square boxes, the how behind the mathy, less code + working with border-radius solution & the stacked children solution (no border-radius).

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  35. On gradient borders & common issues with them reddit.com/r/css/comments/1tfm

    If you've ever wanted to create constant length/ speed border segments on non-square boxes, the how behind the mathy, less code + working with border-radius solution & the stacked children solution (no border-radius).

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  36. On gradient borders & common issues with them reddit.com/r/css/comments/1tfm

    If you've ever wanted to create constant length/ speed border segments on non-square boxes, the how behind the mathy, less code + working with border-radius solution & the stacked children solution (no border-radius).

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  37. On gradient borders & common issues with them reddit.com/r/css/comments/1tfm

    If you've ever wanted to create constant length/ speed border segments on non-square boxes, the how behind the mathy, less code + working with border-radius solution & the stacked children solution (no border-radius).

    #CSS #cssGradient #code #coding #web #dev #webDev #webDevelopment #frontend #Maths #cssMaths

  38. #tinyCSStip

    Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.

    It just solved my own tiny misalignment problem that was driving me batty. 🦇

    #CSS #cssMaths #code #coding #frontend #web #dev #webDevelopment #webDev

  39. #tinyCSStip

    Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.

    It just solved my own tiny misalignment problem that was driving me batty. 🦇

    #CSS #cssMaths #code #coding #frontend #web #dev #webDevelopment #webDev

  40. #tinyCSStip

    Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.

    It just solved my own tiny misalignment problem that was driving me batty. 🦇

    #CSS #cssMaths #code #coding #frontend #web #dev #webDevelopment #webDev

  41. #tinyCSStip

    Sometimes, if you notice a teeny tiny misalignment and you cannot understand why because *nothing* in your CSS looks like it could have caused it... try using `round()` to round to an integer number of pixels.

    It just solved my own tiny misalignment problem that was driving me batty. 🦇

    #CSS #cssMaths #code #coding #frontend #web #dev #webDevelopment #webDev

  42. Missed this, made on the 1st of Jan on @codepen:

    ✨ Sliding border glow on hover for beveled cards, heavily commented codepen.io/thebabydino/pen/Eay

    Trivial if we have `corner-shape` support & even simpler with `border-area`. But here it's cross-browser.

    Detailed explanation of the Maths behind on Ko-fi/ Patreon. This way, you get to both become smarter and support my work so I can continue coding.

    #CSS #Maths #cssMaths #cssGradient #cssMask #code #coding #frontend #web #dev #webDev #webDevelopment

  43. Missed this, made on the 1st of Jan on @codepen:

    ✨ Sliding border glow on hover for beveled cards, heavily commented codepen.io/thebabydino/pen/Eay

    Trivial if we have `corner-shape` support & even simpler with `border-area`. But here it's cross-browser.

    Detailed explanation of the Maths behind on Ko-fi/ Patreon. This way, you get to both become smarter and support my work so I can continue coding.

    #CSS #Maths #cssMaths #cssGradient #cssMask #code #coding #frontend #web #dev #webDev #webDevelopment

  44. Missed this, made on the 1st of Jan on @codepen:

    ✨ Sliding border glow on hover for beveled cards, heavily commented codepen.io/thebabydino/pen/Eay

    Trivial if we have `corner-shape` support & even simpler with `border-area`. But here it's cross-browser.

    Detailed explanation of the Maths behind on Ko-fi/ Patreon. This way, you get to both become smarter and support my work so I can continue coding.

    #CSS #Maths #cssMaths #cssGradient #cssMask #code #coding #frontend #web #dev #webDev #webDevelopment

  45. Missed this, made on the 1st of Jan on @codepen:

    ✨ Sliding border glow on hover for beveled cards, heavily commented codepen.io/thebabydino/pen/Eay

    Trivial if we have `corner-shape` support & even simpler with `border-area`. But here it's cross-browser.

    Detailed explanation of the Maths behind on Ko-fi/ Patreon. This way, you get to both become smarter and support my work so I can continue coding.

    #CSS #Maths #cssMaths #cssGradient #cssMask #code #coding #frontend #web #dev #webDev #webDevelopment