Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think I found a solution for Firefox anyways, thought you might like a follow up:</p> <p>Looking through the source code I found a file:</p> <p>nsCSSParser.cpp</p> <p>For each rgb percentages it does the following:</p> <ol> <li>It takes the percentage component multiplies it by 255.0f</li> <li>Stores it in a float</li> <li>Passes it into a function NSToIntRound</li> <li>The result of NSToIntRound is stored into an 8 bit integer datatype, before it is combined with the other 2 components and an alpha channel</li> </ol> <p>Looking for more detail on NSToIntRound:</p> <pre><code>nsCoord.h inline PRInt32 NSToIntRound(float aValue) { return NS_lroundf(aValue); } </code></pre> <p>NSToIntRound is a wrapper function for NS_lroundf</p> <pre><code>nsMathUtils.h inline NS_HIDDEN_(PRInt32) NS_lroundf(float x) { return x &gt;= 0.0f ? PRInt32(x + 0.5f) : PRInt32(x - 0.5f); } </code></pre> <p>This function is actually very clever, took me a while to decipher (I don't really have a good C++ background).</p> <p>Assuming x is positive</p> <p>It adds 0.5f to x and then casts to an integer</p> <p>If the fractional part of x was less than 0.5, adding 0.5 won't change the integer and the fractional part is truncated, </p> <p>Otherwise the integer value is bumped by 1 and the fractional part is truncated.</p> <ol> <li>So each component's percentage is first multiplied by 255.0f</li> <li>Then Rounded and cast into a 32bit Integer</li> <li>And then Cast again into an 8 bit Integer</li> </ol> <p>I agree with most of you that say this appears to be a browser dependent issue, so I will do some further research on other browsers.</p> <p>Thanks a bunch!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload