E3 Tips: Creating screen objects that will not get “deformed”.

Issue:
 
“The problem is that, according to their position on screen, some objects get “deformed”. For example, a test was made with a 150 X 150 circle. When the circle’s position on screen changes, it sometimes looks visibly smaller than its initial size, yet its properties are still 150 X 150. How can I fix this? This also happens when it is necessary to zoom the screen to fit it to the Viewer’s or Frame’s size due to resolution changes, for example.”
 
Cause:
 
This happens because of the rounding off (truncating) occurring when HIMETRIC coordinates are converted into pixels. In the example, there are two circles with the same HIMETRIC size, 150 X 150:

  • Circle1:  X=0  Y=0  Coordinates = (0, 0, 150, 150)
  • Circle2:  X=1000  Y=1000  Coordinates = (1000, 1000, 1150, 1150)

Suppose Zoom is 100%, and the computer’s resolution is an average 96 DPI. To convert HIMETRIC units into pixels, use the following:

      PIXEL = (HIMETRIC * 96) / 2540

With this formula, the objects’ coordinates in pixels are:

  • Circle1:  GrossCoordinatesInPixel = (0, 0, 5.67, 5.67)
  • Circle2:  GrossCoordinatesInPixel = (37.8, 37.8, 43.46, 43.46)

However, since there are no “half-pixels”, these values are truncated:

  • Circle1:  TruncatedCoordinatesInPixel = (0, 0, 5, 5), diameter = 5 pixels
  • Circle2:  TruncatedCoordinatesInPixel = (37, 37, 43, 43), diameter = 6 pixels

Notice that Circle2 is 1 pixel larger than Circle1!
 
 
Solution:
 
To fix (or at least minimize) this problem, we have to set the circle’s size as a multiple of a pixel’s exact size. To do so, we must find out a pixel’s size in HIMETRIC:

     HIMETRIC = (PIXEL * 2540) / 96

Therefore, 1 pixel = 26,4583333333… HIMETRIC. Since this number is a repeating decimal (3333333…), the circle should be set in multiples of 3 pixels. For example, to have a circle whose “stable size” is a 6-pixel diameter, set the object’s Height = 158,75 and Width = 158,75. Whenever this object moves on screen, its size in pixels will tend to be “stable”:

      Circle1:  X=0  Y=0  Width=158.75  Height=158.75
      HIMETRICCoordinates = (0, 0, 158.75, 158.75)
      GrossCoordinatesInPixel = (0, 0, 6, 6)
      TruncatedCoordinatesInPixel = (0, 0, 6, 6)
      Diameter = 6 pixels

      Circle2:  X=1000  Y=1000  Width=158.75  Height=158.75
      HIMETRICCoordinates = (1000, 1000, 1158.75, 1158.75)
      GrossCoordinatesInPixel = (37.7953…, 37.7953…, 43.7953…, 43.7953…)
      TruncatedCoordinatesInPixel = (37, 37, 43, 43)
      Diameter = 6 pixels
 
Tip:
 
E3’s own screen editor allows you to created objects with a “stable” size, with no need for all these calculations.
 
When you need a “stable-sized” object (usually, objects that need to be copied several times on screen, such as an XControl, for example), just turn off the screen editor’s grid and set Zoom in 100% while you create the object with your mouse. The size of objects created with these procedures will always be multiple of one pixel.
 
PLEASE NOTICE: even if you do follow the tip above and create objects whose size is “stable”, some distortions can still occur due to imprecisions when representing numbers in a float point (minimal precision losses can occur and therefore cause differences in more or less one pixel at the end).

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Deixe seu Comentário

Seu endereço de e-mail não será publicado. Campos marcados com asterisco são obrigatórios *