# [Request] Golden Ratio Calculator

## Recommended Posts

I use golden ratios with considerable frequency when designing, and typically end up going to a website like this to calculate the two adjacent numbers (above and below). What would be fantastic is being able to type something like "golden 50" into Alfred and have results 1 and 2 be "81" and "31" respectively with "copy to clipboard" being the action.

I'm not super knowledgeable with scripts, so any help is much appreciated!

I use golden ratios with considerable frequency when designing, and typically end up going to a website like this to calculate the two adjacent numbers (above and below). What would be fantastic is being able to type something like "golden 50" into Alfred and have results 1 and 2 be "81" and "31" respectively with "copy to clipboard" being the action.

I'm not super knowledgeable with scripts, so any help is much appreciated!

Here you go http://bit.ly/1aG2hbb

Just tell me if you have any problems/modifications. My output may not be to your liking.

I included the "golden" keyword, as well as a "goldenD" keyword just incase you want the adjacent numbers with their decimal parts.

Hey forgetfulfellow,

Thanks for your reply! The example number, "50" was hardcoded in there as follows:

```divided = 50 / goldenRatio
multiplied = 50 * goldenRatio
```

So I just swapped it to "input" so that it would work dynamically:

```divided = input / goldenRatio
multiplied = input * goldenRatio
```

This works great!

However, what would be optimal is if the two answer numbers were visible upon typing "golden 50"(much like when you enter a basic math equation, such as "2+2", you see "4" immediately, with action to copy). This would be a lot more helpful as I could get a quick reference at a glance without having to copy to the clipboard if I don't need to.

My photoshop is better than my coding, so maybe this will help give an idea of what I'm thinking: If it would be difficult to get both to show up like that, then having just the larger number only would still be nice.

Actually, now that I think about it, entering "50" would produce 80.9... which, ideally would round up to "81" rather than truncate to "80". While I suppose it would be handy for some to have the number out to a couple decimal places, I'm really only needing the whole number for my purposes, as I'm dealing with pixels in my designs.

Thanks for your efforts thus far!

Edited by seanwes

Hey forgetfulfellow,

Thanks for your reply! The example number, "50" was hardcoded in there as follows:

```divided = 50 / goldenRatio
multiplied = 50 * goldenRatio
```

So I just swapped it to "input" so that it would work dynamically:

```divided = input / goldenRatio
multiplied = input * goldenRatio
```

This works great!

However, what would be optimal is if the two answer numbers were visible upon typing "golden 50"(much like when you enter a basic math equation, such as "2+2", you see "4" immediately, with action to copy). This would be a lot more helpful as I could get a quick reference at a glance without having to copy to the clipboard if I don't need to.

My photoshop is better than my coding, so maybe this will help give an idea of what I'm thinking: If it would be difficult to get both to show up like that, then having just the larger number only would still be nice.

Actually, now that I think about it, entering "50" would produce 80.9... which, ideally would round up to "81" rather than truncate to "80". While I suppose it would be handy for some to have the number out to a couple decimal places, I'm really only needing the whole number for my purposes, as I'm dealing with pixels in my designs.

Thanks for your efforts thus far!

See if you like this:

http://cl.ly/18280V3I2o2s

• Live Feedback (via Script Filter)
• Automatically detects integers and decimals and displays the appropriate results
• Error handling, so it should never return something Alfred can't parse (i.e. You should never see fallback results when you use this workflow)

Let me know what you think Edited by Tyler Eich

Hey forgetfulfellow,

Thanks for your reply! The example number, "50" was hardcoded in there as follows:

```divided = 50 / goldenRatio
multiplied = 50 * goldenRatio
```

So I just swapped it to "input" so that it would work dynamically:

```divided = input / goldenRatio
multiplied = input * goldenRatio
```

This works great!

However, what would be optimal is if the two answer numbers were visible upon typing "golden 50"(much like when you enter a basic math equation, such as "2+2", you see "4" immediately, with action to copy). This would be a lot more helpful as I could get a quick reference at a glance without having to copy to the clipboard if I don't need to.

My photoshop is better than my coding, so maybe this will help give an idea of what I'm thinking: If it would be difficult to get both to show up like that, then having just the larger number only would still be nice.

Actually, now that I think about it, entering "50" would produce 80.9... which, ideally would round up to "81" rather than truncate to "80". While I suppose it would be handy for some to have the number out to a couple decimal places, I'm really only needing the whole number for my purposes, as I'm dealing with pixels in my designs.

Thanks for your efforts thus far!

Seems like I shipped out my code too quickly! Sorry about that Also, Tyler's version is much more comprehensive than mine, so please use his

See if you like this:

http://cl.ly/18280V3I2o2s

• Live Feedback (via Script Filter)
• Automatically detects integers and decimals and displays the appropriate results
• Error handling, so it should never return something Alfred can't parse (i.e. You should never see fallback results when you use this workflow)

Let me know what you think This works brilliantly! Thank you both so much for your help. Seems like I shipped out my code too quickly! Sorry about that Also, Tyler's version is much more comprehensive than mine, so please use his

This works brilliantly! Thank you both so much for your help. Glad you like it! Edited by Tyler Eich