Re: [csswg-drafts] [css-values] Proposal: `round()` to a finite scale (#11067)

A separate function could work as well, yes.

Another thing that I forgot to mention, but about which I was thinking when initially coming up with this proposal: two other proposals by @LeaVerou :

-  https://github.com/w3c/csswg-drafts/issues/10034 — also talking about a _scale_, but with differences (it is continuous, from what I understood, and for colors the order for sure matters, as we can't really sort them).

- https://github.com/w3c/csswg-drafts/issues/9992 — I can imagine these work ~similar to what I propose (when the `default` is not specified, and we try to access by unknown key, choose the closest). The main difference is that in 9992 there are keys with their associated values, where we match by key and then take a value; I guess the scale I'm talking here about could be expressed as `{ 1: 1; 2: 2; 3: 3; 5: 5; 7: 7; 11: 11;  }` and so on, but that's rather cumbersome.

And another thought that I had: I can see similarities with type grinding, where a registered custom property for an `<integer>`, with a `<number>` assigned, converts it into an acceptable value. The current `@property` does not allow defining the rounding strategy in this case, but I wonder if what I want could've been expressed as a custom _type_: define a subtype of a `<number>` or `<dimension>`, but with a limited possible values, so when assigning to it, it would “choose” the closest. But, I guess, working with a type like that would be rather cumbersome as well: need to register another property, and use as an intermediate step between the value you want to round and where you want to use it.

-- 
GitHub Notification of comment by kizu
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/11067#issuecomment-2431236564 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 23 October 2024 08:08:35 UTC