5 ms·
Not sure why make a whole website of this w := 1900 h := 1200 divisor := gcd(w, h) aspect := fmt.Sprintf("%d:%d", w/divisor, h/divisor) fu
by sd8dgf8ds8g8dsg 9y ago
Not sure why make a whole website of this
w := 1900
h := 1200
divisor := gcd(w, h)
aspect := fmt.Sprintf("%d:%d", w/divisor, h/divisor)
func gcd(x, y int64) int64 {
for y != 0 {
x, y = y, x%y
}
return x
}
- stephenr 9y agoHave an upvote. The limit on ridiculous things people will somehow make into a "web service" knows no bounds.
- ryanhefner 9y agoThanks. Yeah, not really a "web service", just a reference tool, along with an NPM module you can use. Also, I’ll be extending the device/resolutions listing, so hopefully it can be a handy reference for designers/developers.
- stephenr 9y agoThe upvote was for `sd8dgf8ds8g8dsg` > just a reference tool, along with an NPM module you can use. Why does ~6 lines of basic logic need an NPM module?
- ryanhefner 9y agoYeah, probably doesn't. I just found myself using it across a couple different projects and seemed like it would be easier than having to copy and paste it everywhere. Also, it has a command line tool that you can use to get the aspect ratio from width/height. So, not just the code.
- nottorp 9y agoHe/she/it hasn't heard of 1920x1200 :) All those devices are 16:9 i think?
- ryanhefner 9y agoYeah, I need to beef up the devices/resolutions listing. What device(s) have 1920x1200?
- sp332 9y agoMy 2008 Dell Studio 15 laptop :)
- ryanhefner 9y agoI'll be sure to add that as I expand the listing of devices/resolutions.
- ryanhefner 9y agoAlso, I thinking that it could be handy to maybe default to the resolution/aspect ratio of the device visiting the page. Would that be handy?
- sp332 9y agoYeah, I like this idea. It's kind of what I was expecting before I visited the page.
- suprfnk 9y agoThe maximum scaling option in macOS for 15" retina MacBook Pro's (all 15" retina models since 2012) is 1920x1200. So it's probably used quite a lot. https://www.apple.com/macbook-pro/specs/ https://www.apple.com/macbook-pro/specs/ Select 15" and scroll to Display section.
- schemathings 9y agoMight be nifty to just match the list of devices in Chrome Inspector ..?
- schemathings 9y ago
- suprfnk 9y agoBecause my non-programmer friend can use a website, but not write a program.
- ryanhefner 9y agoExactly.
- 52-6F-62 9y agoThis. I work in media. Just passed this along to a few designer friends, and even non-designers who work with magazine design teams and regularly have to translate images and resize/crop them for mobile and web. edit: They're already happy to have it in their back pocket.
- ryanhefner 9y agoYeah, this is really more of a reference and a tool when you’re comparing sizes and confirming they are the same aspect ratio without having to use code. There’s also an NPM module that will do the code part if you need to go that route.
- johnhenry 9y agoWorth mentioning that the page makes it explicit that it uses this library: https://github.com/ryanhefner/calculate-aspect-ratio/blob/master/src/index.js https://github.com/ryanhefner/calculate-aspect-ratio/blob/ma...