Skip to content

percentages are rounded down causing pixel offsets #14

@NuclearCookie

Description

@NuclearCookie

The calc_percent( int width ) function in css_length.h casts percentages down to integers. In a way this is fine ( for rendering ) but it looks like these integer values are being used in calculations for relative positioned divs. Here's an example:

______________________________________________________
|     ___________           __________               |
|     | div 1   |           | div 2  |         ...   |
|     -----------           ----------               |
|                                                    |
|                                                    |
------------------------------------------------------

Imagine div 1 is positioned at 33,3px from the left side of the screen. it has a width of 56,9px, div 2 is positioned 60,8px from div1.
If you keep the fractions, you get a final position for div 2 of : 33.3 + 56.9 + 60.8 = 151
If you round down each value however, you get a final position of 33 + 56 + 60 = 149

This is already a difference of 2 pixels..

_Possible solutions:_

  • keep the fraction during the position calculations and round them down when rendering
  • Use integers but use 32 units to represent 1 pixel. then you can divide by 32 ( or shift ) when you render, to use the rounded position.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy