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

  • Context: Undergrad 
  • Thread starter Thread starter chubbychub
  • Start date Start date
  • Tags Tags
    Function Parameters
Click For Summary

Discussion Overview

The discussion revolves around creating a function for DPI (dots per inch) screen scaling, specifically addressing how to map percentage values from 100% to 350% to corresponding DPI values. The conversation includes mathematical reasoning, proposed formulas, and considerations for implementing the function in a script.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested
  • Homework-related

Main Points Raised

  • One participant outlines a need for a function that adjusts DPI based on percentage increases from 100% to 350%, detailing specific DPI values associated with each percentage.
  • Another participant questions the meaning of DPI, suggesting a linear relationship where 1% corresponds to 0.96 DPI.
  • A participant proposes a formula, ##Y=\frac {25} {24} X##, where ##Y## is the percentage and ##X## is the DPI, but notes that the function must also account for rounding and mapping to integer values.
  • Concerns are raised about the limitations of the percentage range (100 to 350) and how this affects the function's output.
  • Further discussion includes the addition of .5 in the equations for rounding purposes, particularly when dealing with arbitrary input values.

Areas of Agreement / Disagreement

Participants express differing views on whether the original request constitutes homework. There is no consensus on the best approach to formulate the function, as multiple perspectives on the mathematical relationships and limitations are presented.

Contextual Notes

Participants discuss the need for the function to handle specific bounds (100% to 350%) and the implications of rounding in the calculations. The conversation reflects uncertainty about the best way to implement the function while adhering to these constraints.

chubbychub
Messages
5
Reaction score
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
I do not know the abbreviation DPI but it seems
1 per cent = 0.96 DPI
 
but how can i write that into a function? that at every 25% increase, it should add 1 to subtract from?
 
Isn't it a homework?
 
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.
 
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
 
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.
 
what about the limitations of 100 lowest bound and 350 highest bound?
 
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.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 52 ·
2
Replies
52
Views
8K
Replies
5
Views
3K
  • · Replies 41 ·
2
Replies
41
Views
6K
  • · Replies 19 ·
Replies
19
Views
18K
  • · Replies 1 ·
Replies
1
Views
15K