<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Aditya Raju on Medium]]></title>
        <description><![CDATA[Stories by Aditya Raju on Medium]]></description>
        <link>https://medium.com/@adityarkj?source=rss-fcc0d1f775d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*VKufq1rPOMWDzjCylD-jCg.jpeg</url>
            <title>Stories by Aditya Raju on Medium</title>
            <link>https://medium.com/@adityarkj?source=rss-fcc0d1f775d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 13:41:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adityarkj/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Viewport Sizing & Resolutions — How it works for the iPhone lineup]]></title>
            <link>https://medium.com/@adityarkj/viewport-sizing-resolutions-how-it-works-for-the-iphone-lineup-7f920d131f85?source=rss-fcc0d1f775d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f920d131f85</guid>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[apple]]></category>
            <dc:creator><![CDATA[Aditya Raju]]></dc:creator>
            <pubDate>Mon, 18 Oct 2021 06:30:32 GMT</pubDate>
            <atom:updated>2021-10-18T06:30:32.799Z</atom:updated>
            <content:encoded><![CDATA[<h3>Viewport Sizing &amp; Resolutions — How it works for the iPhone lineup</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fcbeQOgkfwRow3apVDhHRQ.png" /></figure><p>At the start of this year, I decided to bite the bullet and upgrade my beaten up iPhone 7 to a shiny new iPhone 12. I went to the apple website and just ordered the iPhone 12 without really checking out the other models available and when I finally got it in my hands, the size difference was quite clear — the iPhone 12 is actually quite a bit bigger than the 7. On top of this, I visited the store and tried out an iPhone 12 Mini and realized that this size may have worked better for my mostly light phone usage.</p><p>I realized that having something just to compare keyboard and screen sizes to from your current phone could be useful and so I wrote <a href="https://compare-my-iphone.com/">https://compare-my-iphone.com/</a>. At a high level, <strong>it works by resizing the viewport of any iPhone in the current lineup relative to the iPhone you’re using</strong>. However, it is hard to trust a random website on the internet for such a critical decision as buying a device that you will use for years — so I decided to write an article to delve more deeply into the methodology behind how the sizing works on the iPhone Size Comparison Webapp.</p><h3>Screen Resolution, Viewport Size and Pixel Ratios</h3><p>There are a few different concepts to talk about when we talk about displays. Everyone’s heard of <strong>resolution </strong>— Full HD or 4K and all of that goodness — which is usually represented as the number of pixels spanning the width and height of the screen. Then there is <strong>PPI or pixels per inch </strong>— an indication of how many pixels are packed per an inch of screen. Usually, a higher PPI translates to a sharper image. However, when developing web applications (or iOS applications), this is converted into a standardized set of numbers that form the <strong>viewport size</strong>. When you view a webpage, the display is represented in relation to the viewport size which is defined through the webpage’s CSS and HTML. Here’s an example of how the three units work for an iPhone 13:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ttd0yliVXxL92AVE145svw.png" /></figure><p>Why do we need viewport sizes? Developers find it much easier to deal with viewport sizes — which are much more standardized compared to all the resolutions that are out there for multiple devices. For example, the viewport sizes for the iPhone 13 and the iPhone 11 are similar despite having different resolutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e5N_vRojjC6buRkIfJ82UA.png" /></figure><p>From the above two diagrams, one more relationship here that we could draw out is between screen resolution and viewport size. If you notice, for the iPhone 13, that turns out to be 3 and this is called the pixel ratio — basically 3 pixels form a single viewport pixel — which ends up being a much smaller screen that a developer has to work with.</p><p>The main conundrum that one has to deal with on the web is that displays are represented in CSS with viewport pixels and <strong>this usually isn’t directly related to the actual physical size of a phone </strong>— like how the iPhone 11 viewport is slightly bigger despite its screen being slightly smaller than the iPhone 13.</p><h3>How iPhone Size Comparison uses this to show you accurate phone sizes</h3><p>Now that we’ve laid down all the different measurements it takes to get from physical dimensions to viewport size, we can leverage this relationship to accurately display different phone sizes to a particular phone.</p><p>As long as we have the PPI and the pixel ratio of the current viewing device, we can compute that together with the device we want to compare it to and arrive at a number we can then multiply with the current devices viewport size. The equation looks something like this,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rDWxQACjbE9WRuDOrs8c0w.png" /></figure><p>Once we have the dimension multiplier (not the best name), we can multiply this coefficient against the viewport dimensions of our current device to represent the selected device on the current device’s screen.</p><p>Now, let’s run through an example. Prepare yourself for a lot of math. We’ll keep talking about the iPhone 11 and the iPhone 13.</p><p>Imagine you’re using the iPhone 11 and would like to compare it to the iPhone 13. The difference in the resolutions would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QhYjIoqM3KwLJ2tKPYPnVw.png" /><figcaption>The iPhone 11 is lower resolution than the iPhone 13</figcaption></figure><p>Now, also knowing the PPI for both of these devices — 460ppi for the iPhone 13 and 326ppi for the iPhone 11, we can divide the resolution by the PPI to get their physical screen sizes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zgUfxTTCdq6ITTXIk44crg.png" /><figcaption>The iPhone 13’s screen is the very slightly bigger than the iPhone 11</figcaption></figure><p>You’ll notice that the iPhone 13 physical screen is very slightly bigger than the iPhone 11 screen. <strong>Our task now is to find a multiplier on the iPhone 11 viewport size that will accurately portray this difference</strong>.</p><p>Let’s start by calculating the viewport sizes for both of these devices. To do this, we divide the resolutions by the pixel ratios — 3 for the iPhone 13 and 2 for the iPhone 11:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wiWM3jZRMTbSVQuArcg4qg.png" /></figure><p>We’re expecting to find a dimension multiplier, that when multiplied with the iPhone 13’s viewport size, will result in a viewport size slightly higher than the viewport size of the iPhone 11 (around 0.13-0.14% as we saw from the screen size comparison earlier). Math time!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vt0htW2-nzyiQGjVVIkQCA@2x.jpeg" /><figcaption>We now have the coefficient to multiply our phone dimensions with.</figcaption></figure><p>We can get the pixel ratio and the DPI for these two phones from a website like <a href="https://www.ios-resolution.com/">https://www.ios-resolution.com/</a>.</p><p>We now have our dimension multiplier of 1.063 that we can then apply to our iPhone 11’s viewport so that we can accurately render an iPhone 13.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJeEEYAjq2izI9Y507UZKg.png" /><figcaption>Math to arrive at physical size differences between the two iPhones.</figcaption></figure><p>Multiplying the number together with the viewport size leads us to a result that is just about 0.14% wider and 0.134% wider, just as we expected from comparing the physical dimensions with each other. Some of the math has been rounded in the above image, so the results are slightly different if you try to do it yourself using the above numbers — plug in the DPIs and pixel ratios instead.</p><p>Why does this method work? We’re mostly leveraging the direct correlation between viewport sizes, the phone resolution and PPI and using our equation to “replicate” the same conditions as a physical comparison.</p><p>The above example applies to most of the iPhone lineup, however there are some exceptions.</p><h3>The Exceptions</h3><p>The big exceptions to this relationship are the iPhone 13 Mini, iPhone 12 Mini and the 6+/7+/8+. For the 12 mini, dividing the the resolution (2340x1080) by 3, we end up with (780x360). However, the actual viewport size is 812x375 (which I only realized when testing the website in the store) — sharing its height with the iPhone 11 Pro’s, XS’s and X’s viewport. This is because Apple does a sort of up sampling for the viewports of these phones — I’m guessing to help standardize these viewports with other iPhones — and so we end up with the following situation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GSVHl-S9xdK2-xifkE_Lgg.png" /></figure><p>For the size comparison website, this means also capturing the up sampling ratios so that they can be applied when a user with a iPhone 13 mini or a similar device tries the page.</p><h3>Conclusion</h3><p>I know there are quite a few different terms to think about here, but actually the math is pretty simple, but perhaps long. We can then leverage that to allow a comparison between different devices within the iPhone lineup, hopefully pretty accurately — although not pixel perfect. There are a few additional things I’d like to work, like making sure the bezels are also accurate for each iPhone, but for now — I’d love to hear your thoughts or feedback on it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f920d131f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Lottie made our animation handoffs a lot simpler]]></title>
            <link>https://medium.com/synthesis-partners/how-lottie-made-our-animation-handoffs-a-lot-simpler-5ac9a399824a?source=rss-fcc0d1f775d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5ac9a399824a</guid>
            <category><![CDATA[lottie]]></category>
            <category><![CDATA[dataviz]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[animation]]></category>
            <dc:creator><![CDATA[Aditya Raju]]></dc:creator>
            <pubDate>Fri, 04 Sep 2020 06:45:27 GMT</pubDate>
            <atom:updated>2020-09-04T07:02:29.249Z</atom:updated>
            <content:encoded><![CDATA[<p>Our brand refresh last December ushered in a completely new set of colours, illustration guidelines, and a brand new fully animated logo. The re-design captured Synthesis’ human-centred approach to data science, as represented by the animated logo combining an organic, handwriting-like typeface with a more geometric font.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*kCsOkey752kSzPCzdtgDVw.gif" /></figure><p>I was applauding these welcome changes until I realised that we’d need to put that fancy new logo on our website. While I’ve done numerous animations in the past (including this piece on <a href="https://synthesis.partners/content/unboxing-sneaker-hype/">the most-hyped sneakers of 2019</a>) translating an animated logo from a gif to a smooth, scalable animation was a new challenge for me.</p><p>This article explains our process of choosing Lottie for displaying our logo and other illustrations, and how we eventually used it on the site.</p><h3>The rejected solutions</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/903/1*IeG8KMIksTP0o5czJbg7ZQ.png" /><figcaption>Snippets of some of other visualisations written in D3 that leverage SVG &amp; other code-first approaches</figcaption></figure><p>We considered a few obvious solutions for displaying our new animated logo.</p><p>First, we could use a gif to represent the entire animation, which we could then load as an image on our website.</p><p>However, a gif is a rasterised image, meaning it loses quality as you blow up the resolution of display. This would make displaying a gif difficult at the different resolutions and screen sizes that our website supports.</p><p>The second idea was at the other end of the spectrum. What if we wrote a full, custom animation in SVG? HTML supports SVG (Scalable Vector Graphics) layouts that, as a vector form of image representation, would not lose quality at different scales. However, this would be incredibly tedious and require lots of code to manually interpolate between all the different states of the animation.</p><h3>Enter Lottie</h3><p><a href="https://airbnb.design/lottie/">Lottie</a> was an option suggested by our product designer, Haiying. I initially met it with skepticism. I was worried about introducing a new library so late into development as it could have a steep learning curve, or cause unintended side effects.</p><figure><img alt="Animated Lottie logo from the Airbnb website" src="https://cdn-images-1.medium.com/max/800/1*lfAAWqjT3k63J14ggZlpvw.gif" /><figcaption>The Lottie cover animation</figcaption></figure><p>However, given the lack of other options and after taking a quick look at the creator of the library — Airbnb, known for creating other great tools such as <a href="https://airbnb.io/projects/enzyme/">Enzyme</a> and the <a href="https://github.com/airbnb/javascript">Airbnb JS Style Guide </a>— I decided it was worth a try.</p><p>Lottie works by taking an Adobe After Effects JSON snippet of a particular animation and converting it into an SVG or canvas based HTML animation. It takes care of all the specific animation code &amp; conversions, so all the developer has to do is master its relatively simple API.</p><p>Lottie requires the Bodymovin plugin for Adobe After Effects, which does most of the heavy lifting by transpiling After Effects’ animation encoding into a JSON format. Haiying loaded up our logo animation, installed the Bodymovin plugin, exported the animation as a JSON, and handed me a sizeable 3MB file to work with.</p><p>The Lottie library itself is a simple NPM install that is immediately usable with a simple &amp; well documented API.</p><pre>$ npm install lottie-web</pre><p>Lottie can then be imported with the following line in any JS file</p><pre>// exampleComponent.jsx</pre><pre>import Lottie from ‘lottie-web’<br>import animation from ‘animation.json’ // Handed off from designer</pre><p>You can load the animation as JSON into Lottie, which then targets a particular DOM node (in this case, we have a div with an id ‘animation-target’) to insert the animation. For React (Hooks), this would look like,</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b180d0fa3e45eb24952e657004a9453f/href">https://medium.com/media/b180d0fa3e45eb24952e657004a9453f/href</a></iframe><p>Lo and behold, I couldn’t believe what I was seeing on my localhost: our fully animated logo rendered as an SVG element in the browser! I waited the entire 13 seconds for the animation to loop to make sure that it wasn’t just a gimmick.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/0*CXhHWGEywwAntu54" /></figure><p>Not only does Lottie let you animate whatever you want in SVG or canvas form, it also provides some neat animation lifecycle methods to give more control over how to display an animation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*7h52TKtlGNFLezY2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*hq_1bykuriunhtJz" /></figure><pre>const animation = Lottie.loadAnimation({…})<br>...<br>animation.play() // Play animation<br>animation.stop() // Stop animation<br>animation.playAnimationSegment(15,25) // Play a segment</pre><p>We quickly moved more of our animations into Lottie, including our multilingual welcome message that shows on clicking the “Get In Touch” button. The playAnimationSegment() API became super useful for the infographic on the left, from our piece on <a href="https://synthesis.partners/content/analysing-indian-beauty/">Beauty in India.</a></p><h3>Conclusion</h3><p>Lottie seems like a great option if you have animations (whether repeatable or sequential) that you need to put on a website of a frontend application. The handoff from animation to code is super simple and eliminates a lot of the custom code that otherwise needs to be written to animate things in SVG.</p><p>While we began using Lottie for the logo, we’ve since used it for scrolly-telling in our <a href="https://synthesis.partners/content/analysing-indian-beauty/">analysis of the rise of organic beauty in India</a>. There’s certainly more things to do with Lottie, particularly when it comes to experimental data storytelling, that we hope to explore.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5ac9a399824a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/synthesis-partners/how-lottie-made-our-animation-handoffs-a-lot-simpler-5ac9a399824a">How Lottie made our animation handoffs a lot simpler</a> was originally published in <a href="https://medium.com/synthesis-partners">Synthesis Partners</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>