I need to write a function for DPI screen scaling with parameters

  • #1
chubbychub
5
0
i need to write a function for DPI screen scaling,

so the parameters is from 100 (percentage) to 350 (percentage) and increases at 25 (percentage) increase, it will subtract additional 1 DPI
so for example:

100% = 96 DPI which is -4
125% =120 DPI which is -5
150% =144 DPI which is -6
175% = 168 DPI which is -7
200% =192 DPI which is -8
225% = 216 DPI which is -9
250% = 240 DPI which is -10
275% = 264 DPI which is -11
300% = 288 DPI which is -12
325% = 312 DPI which is -13
350% = 336 DPi which is -14

if someone can help me solve this math problem please
 
Mathematics news on Phys.org
  • #2
I do not know the abbreviation DPI but it seems
1 per cent = 0.96 DPI
 
  • #3
but how can i write that into a function? that at every 25% increase, it should add 1 to subtract from?
 
  • #4
Isn't it a homework?
 
  • #5
anuttarasammyak said:
I do not know the abbreviation DPI but it seems.
1 per cent = 0.96 DPI
Pretty standard acronym for dots per inch, as used for printers.

The relationship is close to being linear, but a little bit messy. Each 25% increase corresponds to an increase of 24 DPI. A function's formula might have to do some rounding so as to map the percentage and DPI values onto the integers from 4 to 14.

Hill said:
Isn't it a homework?
Maybe, or maybe not.
 
  • #6
no its not homework, i am trying to simplify a small script for macros, to detect screen size at different resolutions, using a function instead so that the script will work all the different monitor size and at different DPI scale for windows 11, if someone can help me write it please
 
  • #7
chubbychub said:
no its not homework, i am trying to simplify a small script for macros, to detect screen size at different resolutions, using a function instead so that the script will work all the different monitor size and at different DPI scale for windows 11, if someone can help me write it please
The straightforward one is ##Y=\frac {25} {24} X##, where ##Y## is % and ##X## is DPI.
 
  • #8
what about the limitations of 100 lowest bound and 350 highest bound?
 
  • #9
Hill said:
The straightforward one is ##Y=\frac {25} {24} X##, where ##Y## is % and ##X## is DPI.
This provides only the relationship between dots per inch and percentages. The function also needs to map the DPI to the integers 4 through 14. This is similar to how Fahrenheit temps in the range 32 to 212 map to Celsius temps in the range 0 to 100.
 
  • #10
chubbychub said:
what about the limitations of 100 lowest bound and 350 highest bound?
##Y=max(100,min(350,int(\frac {25} {24} X +.5)))##
or
##X=max(96,min(336,int(\frac {24} {25} Y + .5)))##
 
  • #11
why is the .5 added on either equation? what does this means? its increments of 25% at a time, starting at 100% all the way to 350%
 
  • #12
chubbychub said:
why is the .5 added on either equation? what does this means? its increments of 25% at a time, starting at 100% all the way to 350%
It is there for rounding if the input is an arbitrary number.
 

1. How do I write a function for DPI screen scaling?

To write a function for DPI screen scaling, you can start by defining the parameters that will be passed to the function, such as the screen resolution and the DPI value. Then, you can use these parameters to calculate the scaling factor needed to adjust the size of elements on the screen based on the DPI.

2. What parameters should be included in the function for DPI screen scaling?

The parameters that should be included in the function for DPI screen scaling typically include the screen resolution (width and height) and the DPI value of the screen. These parameters will be used to calculate the scaling factor needed to adjust the size of elements on the screen.

3. How can I calculate the scaling factor for DPI screen scaling?

To calculate the scaling factor for DPI screen scaling, you can use the formula: scaling factor = DPI / standard DPI. The standard DPI value is typically 96, so by dividing the DPI value of the screen by 96, you can determine the scaling factor needed to adjust the size of elements based on the screen's DPI.

4. Can you provide an example of a function for DPI screen scaling with parameters?

Here is an example of a function for DPI screen scaling with parameters in JavaScript:function scaleElements(screenWidth, screenHeight, screenDPI) { let standardDPI = 96; let scalingFactor = screenDPI / standardDPI; // Use the scaling factor to adjust the size of elements on the screen}

5. How can I test the function for DPI screen scaling with parameters?

To test the function for DPI screen scaling with parameters, you can pass different screen resolutions and DPI values to the function and observe the resulting scaling factor. You can then use this scaling factor to adjust the size of elements on the screen and verify that they are displayed correctly based on the screen's DPI.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
3K
  • Programming and Computer Science
2
Replies
41
Views
4K
  • Science and Math Textbooks
Replies
19
Views
17K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
14K
Back
Top