W3C home > Mailing lists > Public > www-style@w3.org > January 2012

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

From: Christoph Päper <christoph.paeper@crissov.de>
Date: Sat, 21 Jan 2012 11:26:52 +0100
Message-Id: <49ABB802-1335-44BE-B9ED-9897464F3610@crissov.de>
To: www-style list <www-style@w3.org>
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

This archive was generated by hypermail 2.4.0 : Monday, 23 January 2023 02:14:09 UTC