Re: [css3-*] Review of functional syntax in CSS

Tab Atkins Jr. (2012-01-20 03:01):
> Rounding Functions
> ==================
> 
>    ''roundup(<css-value>, <modulus>)''
>  Rationale
>    Generalizing the round functions seems useful for calc() and other
>    places.  The order "value then modulus" matches basically every
>    programming language.  However, you need 1-token lookahead if you
>    omit the comma, because the <css-value> could be any number of
>    arbitrary tokens.  Also, the common representation of this in math
>    uses commas.

What about

  <rounding> := [‘up’ | ‘down’ | ‘even’ | ‘odd’]

  ‘round(’ <css-value> <rounding>? <modulus>? ‘)’
or
  ‘round(’ <css-value> <rounding>? [, <modulus>]? ‘)’

with <modulus> defaulting to 1 of the unit specified for <css-value>? Alternatively:

  ‘round(’ <css-value> [[<rounding>? <modulus>] | [‘floor’ | ‘ceil’]]? ‘)’

  round(1.5em 1em)      = 2em     round(2.5em 1em)      = 3em
  round(1.5em up 1em)   = 2em     round(2.5em up 1em)   = 3em
  round(1.5em down 1em) = 1em     round(2.5em down 1em) = 2em
  round(1.5em even 1em) = 2em     round(2.5em even 1em) = 2em
  round(1.5em odd 1em)  = 1em     round(2.5em odd 1em)  = 3em
and either
  round(1.5em)          = 2em     round(2.5em)          = 3em
  round(1.5em up)       = 2em     round(2.5em up)       = 3em
  round(1.5em down)     = 1em     round(2.5em down)     = 2em
  round(1.5em even)     = 2em     round(2.5em even)     = 2em
  round(1.5em odd)      = 1em     round(2.5em odd)      = 3em
or
  round(1.5em)          = 2em     round(2.5em)          = 3em
  round(1.5em ceil)     = 2em     round(2.5em ceil)     = 3em
  round(1.5em floor)    = 1em     round(2.5em floor)    = 2em

Received on Saturday, 21 January 2012 10:27:21 UTC