Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Dec 25, 2012, 03:21 PM   #1
TheMTtakeover
macrumors 6502
 
Join Date: Aug 2011
Use AppleScript to create a PPI Calculator?

I was wondering if someone has seen or has code or know's how to go about coding something like this. I essentially want the apple script to run numbers through the following equations.



I want it to come up and ask for the width resolution in pixels, the height resolution in pixels, and diagonal size in inches and then take those numbers and to calculate the diagonal resolution in pixel and then from there calculate the PPI.

Any help at all is greatly appreciated!
__________________
#TeamTaji
TheMTtakeover is offline   0 Reply With Quote
Old Dec 26, 2012, 10:11 AM   #2
Zeuzerian
macrumors newbie
 
Join Date: Dec 2012
Location: Denmark
Hey

Just wrote this, and gave it a try for my 13.3 inch (1440x900) pixels display, that gave me a ppi of 128, which is correct, as far as I know.

Code:
set diagInInches to text returned of (display dialog "Enter the Diagonal Screen Size in inches :" default answer "?")
set screenResX to text returned of (display dialog "Enter horizontal screen size in pixels (x)" default answer "?")
set screenResY to text returned of (display dialog "Enter vertical screen size in pixels (y)" default answer "?")

set dp to (screenResX * screenResX + screenResY * screenResY) ^ (1 / 2)
set ppi to dp / diagInInches

display dialog "PPI for a " & diagInInches & " inch screen, with a resolution of " & screenResX & "x" & screenResY & " pixels, is " & (round (ppi * 100) / 100)
Best regards
-Zeuz
Zeuzerian is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How to create sub-mailboxes with Applescript? torchy Mac Programming 14 May 29, 2014 04:21 PM
Applescript to create a smart folder for each tag? feijoada OS X Mavericks (10.9) 0 Mar 7, 2014 09:55 PM
create folders applescript joennie Mac Programming 3 Jul 30, 2013 06:43 PM
I want to make AppleScript Create Folder DavidBlack Mac Programming 27 Mar 15, 2013 06:18 PM
Applescript: How do I create custom data types? moonman239 Mac Programming 1 Jan 5, 2013 11:07 PM

Forum Jump

All times are GMT -5. The time now is 03:50 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC