Created
June 10, 2018 15:46
-
-
Save shaunhess/1ead236580eada592ee36d9fda918227 to your computer and use it in GitHub Desktop.
Generate Pixel Per Inches for Monitor size based on horizontal resolution, vertical resolution, and diagonal monitor size.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <# | |
| .Synopsis | |
| Generate Pixel Per Inches for Monitor size. | |
| .DESCRIPTION | |
| Generate Pixel Per Inches for Monitor size based on horizontal resolution, vertical resolution, and diagonal monitor size. | |
| .EXAMPLE | |
| Get-PixelDensity -HorizontalResolution 1920 -VerticalResolution 1080 -MonitorSize 24 | |
| #> | |
| function Get-PixelDensity | |
| { | |
| [CmdletBinding()] | |
| Param | |
| ( | |
| # Param1 help description | |
| [Parameter(Position=0)] | |
| [int]$HorizontalResolution=2560, | |
| # Param2 help description | |
| [Parameter(Position=1)] | |
| [int]$VerticalResolution = 1440, | |
| # Param2 help description | |
| [Parameter(Position=2)] | |
| [int]$MonitorSize = 27 | |
| ) | |
| Begin | |
| { | |
| $HorizontalResolutionPow = [math]::Pow($HorizontalResolution,2) | |
| $VerticalResolutionPow = [math]::Pow($VerticalResolution,2) | |
| } | |
| Process | |
| { | |
| $Diagonal_Resolution = [math]::Pow(($HorizontalResolutionPow + $VerticalResolutionPow),0.5) | |
| New-Object PSObject -Property @{ | |
| MonitorSize = $MonitorSize | |
| HorizontalResolution = $HorizontalResolution | |
| VerticalResolution = $VerticalResolution | |
| PixelsPerInch = $Diagonal_Resolution / $MonitorSize | |
| } | |
| } | |
| End | |
| { | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment