<?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 Olga Nikolskaya on Medium]]></title>
        <description><![CDATA[Stories by Olga Nikolskaya on Medium]]></description>
        <link>https://medium.com/@nikolskayaolia?source=rss-601e105931ba------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hKRm6B0oHfSFOi4taAU34A.jpeg</url>
            <title>Stories by Olga Nikolskaya on Medium</title>
            <link>https://medium.com/@nikolskayaolia?source=rss-601e105931ba------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 17:37:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nikolskayaolia/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[An easy way to implement smooth shapes (such as Superellipse and Squircle) into a user interface.]]></title>
            <link>https://medium.com/@nikolskayaolia/an-easy-way-to-implement-smooth-shapes-such-as-superellipse-and-squircle-into-a-user-interface-a5ba4e1139ed?source=rss-601e105931ba------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5ba4e1139ed</guid>
            <category><![CDATA[svg]]></category>
            <category><![CDATA[design]]></category>
            <category><![CDATA[squircle]]></category>
            <category><![CDATA[frontend-development]]></category>
            <category><![CDATA[superellipse]]></category>
            <dc:creator><![CDATA[Olga Nikolskaya]]></dc:creator>
            <pubDate>Fri, 13 Apr 2018 07:35:57 GMT</pubDate>
            <atom:updated>2018-04-14T08:39:05.054Z</atom:updated>
            <content:encoded><![CDATA[<p>Solution for all sizes and colors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZURTDuPUirYNpizhD9m_Q.png" /></figure><p>Every time you see a rectangle with rounded corners in the web, your eye gets stuck at the point where the edge and the corner of the shape meets. <br>This is not the way it should be, so I decided to find a different way to stylize web elements!</p><p>All that massive corner rounding is compounded by the fact that there exists an ideal shape — Superellipse, absolutely slight, without any points of intersection and sharpness.</p><blockquote>The Superellipse is the name given to a family of shapes and the most popular of them is Squircle, the shape intermediate between circle and square. The appearance of squircle seems optically balanced: no sharpness, no angles…</blockquote><p>Is there a way to implement these Super shapes into your interface?</p><p>Let’s figure it out!</p><p>All the shapes obtained in this article are named something like this: similar to Superellipse, similar to Squircle and so on… It’s because they were created without exact calculations with <a href="https://en.wikipedia.org/wiki/Superformula">Superformula</a>.</p><p>The purpose of this article is to find a better way to stylize web interface with optically pleasant forms.</p><p>But I will give the comparison of the true Superellipse and obtained Similar to Superellipse form. Will you find the difference? 😏</p><p>I highly recommend you to read this article, which explains a lot of how we see things and about our perception of forms, why Superellipse is so pretty to look at:</p><p><a href="https://medium.muz.li/optical-effects-9fca82b4cd9a">Optical Effects in User Interfaces</a></p><h4>What’s wrong with border-radius?</h4><p>To create a new way of styling elements, let’s first figure out what’s wrong with the existing method…</p><p>Among all the CSS properties we can use for trying to make rectangles smoother the most obvious decision is to use border-radius.</p><p>The result of setting this property to one single value is predictable — an old plain rectangle with rounded corners.</p><p>This way is very common, it produces a circular curvature and styles all four corners the same way.</p><p>You can create elliptical corners by rounding them independently with shorthand property defining values for each corner separately.</p><pre>border-radius: 5px 10px 5px 10px / 10px 5px 10px 5px;</pre><p>The first set is for horizontal radii, second for vertical.</p><p>When you set horizontal and vertical radii to not equal values, the outcome will be an elliptical curve.</p><p>But the result is always the same — you still see these junction points.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*UDjLurRxKGziBXuunAJmCw.png" /><figcaption>Horizontal radius set for the half of width, vertical smaller than height.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*w5dJ22v9DSjN14ZcRa_9Nw.png" /><figcaption>Horizontal radius — half of width, vertical — half of height.</figcaption></figure><p>As you can see that the best result with border-radius, which you can achieve without any junction points visible is an ellipse and it’s not the way we want to see our rectangle.</p><h4>Missing element</h4><p>I propose to look at the problem from a different perspective.</p><p>Let’s move on to the graphic design software (I’m working in Affinity Designer).</p><p>If you create simple circle shape and then convert it to a curve you see that now it has four anchor points and eight handles.</p><p>Paired opposite handles result in a smooth curve representing our circle.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*-R-1-cnNmBOcJ5z1YW06KA.png" /></figure><p>What if we try to make the handles longer?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*ajSTH1Hxky-4MpHfW6tT5w.png" /></figure><p>Longer…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*wCp6JIwSBOhKCphx4KDNlw.png" /></figure><p>As you can see anchor points are centered at the edges, and when the width of handles increases, our shape becomes more rectangular, saving its smoothness.</p><p>The outcoming form is very similar to Superellipse. Probably we have to work with handles, not with border-radius…<br>But how to use handles through HTML and CSS?</p><p><strong>SVG!</strong></p><h4>The Path</h4><p>There is no better element in SVG to manipulate curves than the Path. It has five commands to produce the exact curvature you want:</p><ul><li>C — cubic Bézier curve</li><li>S — smooth cubic Bezier (shorthand for C)</li><li>Q — quadratic bezier curve</li><li>T — smooth quadratic Bezier curve (shorthand for Q)</li><li>A — elliptical arc</li></ul><p>If you want to learn more about how path commands work, I can recommend you to read this article:</p><p><a href="https://css-tricks.com/svg-path-syntax-illustrated-guide/">The SVG `path` Syntax: An Illustrated Guide | CSS-Tricks</a></p><p>Elliptical arc command (A) takes much more parameters in comparison with the other four commands. So in order to provide well-balanced and optimized code, only first four commands will be examined.</p><p>Only four numbers needed to construct SVGs with the desired shape:</p><ul><li><strong>Width (500px)</strong></li><li><strong>Height (300px)</strong></li><li><strong>Half of Width (250px)</strong></li><li><strong>Half of Height (150px)</strong></li></ul><p>All examples assume that handles are parallel to the edges they belong to and are equal to the half of edge’s length.</p><ol><li>Starting with C command:</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fac622905b9ba4b93f6ddf41cb37ca4c/href">https://medium.com/media/fac622905b9ba4b93f6ddf41cb37ca4c/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*C3FseScUfjhjCf1Pb35bQA.png" /><figcaption>Path C command smooth result</figcaption></figure><p>2. S command try:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9fa16a13ea55f0faf82fe1e31ef7522f/href">https://medium.com/media/9fa16a13ea55f0faf82fe1e31ef7522f/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*MGcAv7uTD3nZzjPJb3gPxA.png" /><figcaption>Not the result expected</figcaption></figure><p>What’s wrong with the left top corner?</p><p>There is one trick. When you use the S command, the first control point that the curve is attached to is always a reflection of the final control point of the first Bezier curve.</p><p>To fix this, it’s better to start with C command and then use S command.</p><p>Cooperation of two commands:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3e330756b3f2d253af9a38d2a7a602e/href">https://medium.com/media/d3e330756b3f2d253af9a38d2a7a602e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*C3FseScUfjhjCf1Pb35bQA.png" /><figcaption>The same smooth rectangle with C+S commands</figcaption></figure><p>Command Q:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/89dee108b5ecd3a4a65a03ef20e07eab/href">https://medium.com/media/89dee108b5ecd3a4a65a03ef20e07eab/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*7MEokk_cULBPXX7RMSqotQ.png" /><figcaption>Seems like Super Egg…</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*M5ZaZ6le0g3AUMhgGksgZw.png" /><figcaption>Similar to Super Egg form vs ellipse</figcaption></figure><p>The difference between C and Q commands is that first draws a curve based on two control points, the second requires a single control point.</p><p>Well, T command acts like S for C, it smoothes the connection between curves, by using the reflection of a control point.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70cb9027455df12f72a15a6e7dfbec8b/href">https://medium.com/media/70cb9027455df12f72a15a6e7dfbec8b/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*7MEokk_cULBPXX7RMSqotQ.png" /><figcaption>Shorthand with T command</figcaption></figure><p>Actually, I find both shapes beautiful and smooth. Much better than rectangles styled with border-radius!</p><h4>Compare to Superellipse</h4><p>To compare created SVGs with True Superellipse we need a resource to generate the last.</p><p>Searching for Superellipse generator I’ve found one, which I like more. It allows enter necessary properties and let download generated shape as SVG, here is the reference:</p><p><a href="http://www.procato.com/superellipse/">Super Circle | Lamé curve | Super-ellipse Calculator &amp; Plotter</a></p><p>Additional parameters for this calculator are left as default, width and height values are from the examlpes above, I still needed one extra value for the <strong>n </strong>parameter… I’ve tried several values for this property and discovered one interesting thing: C+S example has <strong>n </strong>about <strong>5</strong>, Q+T example has <strong>n </strong>about<strong> 2.37</strong>!</p><p>Final calculator result for C+S example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/1*mjA-Huuf4iIuqJvTRLNALQ.jpeg" /></figure><p>Final calculator result for Q+T example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*MNTWsQtqJLEm0ZGXHeo6tQ.jpeg" /></figure><p>Generated Superellipse’s SVG were overlapped with SVGs produced in this article, they are the same! You shouldn’t believe me, just try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*3g6Hi_E2oadxRktFQqD9RQ.png" /><figcaption>Blue — Generated true Superellipse</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*OqRDguSEc6mTHKYF_GgNYw.png" /><figcaption>Blue — Generated true Superellipse</figcaption></figure><p>But wait, we have these SVGs, what else? Feels like we can’t do much with it within our interface…</p><p>Now it’s time to think about implementation.</p><h4>Background SVG with Data URI</h4><p>We will implement it through the style sheet to have access to all our elements in the DOM.</p><blockquote>The data URI scheme is a uniform resource identifier (URI) scheme that provides a way to include data in-line in web pages as if they were external resources.</blockquote><p>There are several advantages using such way of implementation:</p><ul><li>No DOM weighting. (Versus inline SVG) Only elements you really need to structure your page. Styles and structure apart.</li><li>No extra HTTP requests. (Versus background with a link to file).</li><li>Easy styling desired set of elements by adding a class.</li></ul><p>Here is the example of embedding SVG with data URI:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb59ca934eca2e00fd9037629517d7ad/href">https://medium.com/media/cb59ca934eca2e00fd9037629517d7ad/href</a></iframe><p>Not bad… We can do it even better!</p><h4>Imagine all the elements…</h4><p>…into you interface are different, have various sizes, colors, sometimes gradients, but they are all styled with the same smoothness.</p><p>Imagine super mixin, which you can add to different classes. It can take different variables to deal with properties, that gives a great flexibility to style your interface. It is supported even in IE9…</p><p>Here it goes!</p><h4>Super mixins for Super Shapes</h4><p>To create super mixins I’ve chosen two variations of SVG, with C+S commands and Q+T. Let name them super-rectangle and super-circle.</p><p>As you can see from the above example, we need only four parameters to measure our shape: width, height, half of the width, half of the height;<br>For styling let’s first take one parameter — color.</p><p>There are few rules to make our background SVG IE9+ friendly and allow us to add variables.</p><ul><li>Replace ‘&lt;’ with ‘%3C’ and ‘&gt;’ with ‘%3E’ (%3Cpath%3E similar to &lt;path&gt;)</li><li>Replace ‘#’ with ‘%23’ (%23f9ed32 similar to #f9ed32)</li><li>Wrap url content with double quotes, while using inner attribute values’ with single quotes, except variables.</li></ul><p>That would be enough to understand the example.</p><p>Needed parameters:</p><pre>background: url(https://medium.com/&quot;data:image/svg+xml;charset=US-ASCII,&lt;svg%20version=&#39;1.1&#39;%20id=&#39;shape-1&#39;%20xmlns=&#39;http://www.w3.org/2000/svg&#39;%20xmlns:xlink=&#39;http://www.w3.org/1999/xlink&#39;%20x=&#39;0px&#39;%20y=&#39;0px&#39;%20width=&#39;%3Cstrong%3E500%3C/strong%3E&#39;%20height=&#39;%3Cstrong%3E300%3C/strong%3E&#39;%20viewBox=&#39;0%200%20%3Cstrong%3E500%3C/strong%3E%20%3Cstrong%3E300%3C/strong%3E&#39;%20enable-background=&#39;new%200%200%20%3Cstrong%3E500%3C/strong%3E%20%3Cstrong%3E300%3C/strong%3E&#39;%20xml:space=&#39;preserve&#39;&gt;&lt;path%20fill=&#39;%3Cstrong%3E#ED2F5B%3C/strong%3E&#39;%20stroke=&#39;none&#39;%20d=&#39;%3Cstrong%3EM%200,150%20C%200,0%200,0%20250,0%20S%20500,0%20500,150%20500,300%20250,300%200,300%200,150%3C/strong%3E&#39;&gt;&lt;/path&gt;&lt;/svg&gt;&quot;) left top no-repeat;</pre><p>Replace our parameters with variables:</p><pre>background: url(https://medium.com/&quot;data:image/svg+xml;charset=US-ASCII,%3Csvg%20version=&#39;1.1&#39;%20id=&#39;shape-1&#39;%20xmlns=&#39;%3Ca%20href=%22/service/http://www.w3.org/2000/svg&#39;%22%3Ehttp://www.w3.org/2000/svg&#39;%3C/a%3E%20xmlns:xlink=&#39;%3Ca%20href=%22/service/http://www.w3.org/1999/xlink&#39;%22%3Ehttp://www.w3.org/1999/xlink&#39;%3C/a%3E%20x=&#39;0px&#39;%20y=&#39;0px&#39;%20width=&#39;%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E&#39;%20height=&#39;%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E&#39;%20viewBox=&#39;0%200%20%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E%20%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E&#39;%20enable-background=&#39;new%200%200%20%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E%20%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E&#39;%20xml:space=&#39;preserve&#39;%3E%3Cpath%20fill=&#39;%3Cstrong%3E&quot;+$color+&quot;%3C/strong%3E&#39;%20stroke=&#39;none&#39;%20d=&#39;M%200,%3Cstrong%3E&quot;+$halfHeight+&quot;%3C/strong%3E%20C%200,0%200,0%20%3Cstrong%3E&quot;+$halfWidth+&quot;%3C/strong%3E,0%20S%20%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E,0%20%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E,%3Cstrong%3E&quot;+$halfHeight+&quot;%3C/strong%3E%20%3Cstrong%3E&quot;+$width+&quot;%3C/strong%3E,%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E%20%3Cstrong%3E&quot;+$halfWidth+&quot;%3C/strong%3E,%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E%200,%3Cstrong%3E&quot;+$height+&quot;%3C/strong%3E%200,%3Cstrong%3E&quot;+$halfHeight+&quot;%3C/strong%3E&#39;%3E%3C/path%3E%3C/svg%3E&quot;);</pre><p>To highlight brackets replacement:</p><pre>background: url(https://medium.com/&quot;data:image/svg+xml;charset=US-ASCII,%3Cstrong%3E%3C%3C/strong%3Esvg%20version=&#39;1.1&#39;%20id=&#39;shape-1&#39;%20xmlns=&#39;%3Ca%20href=%22/service/http://www.w3.org/2000/svg&#39;%22%3Ehttp://www.w3.org/2000/svg&#39;%3C/a%3E%20xmlns:xlink=&#39;%3Ca%20href=%22/service/http://www.w3.org/1999/xlink&#39;%22%3Ehttp://www.w3.org/1999/xlink&#39;%3C/a%3E%20x=&#39;0px&#39;%20y=&#39;0px&#39;%20width=&#39;&quot;+$width+&quot;&#39;%20height=&#39;&quot;+$height+&quot;&#39;%20viewBox=&#39;0%200%20&quot;+$width+&quot;%20&quot;+$height+&quot;&#39;%20enable-background=&#39;new%200%200%20&quot;+$width+&quot;%20&quot;+$height+&quot;&#39;%20xml:space=&#39;preserve&#39;%3Cstrong%3E%3E%3C%3C/strong%3Epath%20fill=&#39;&quot;+$color+&quot;&#39;%20stroke=&#39;none&#39;%20d=&#39;M%200,&quot;+$halfHeight+&quot;%20C%200,0%200,0%20&quot;+$halfWidth+&quot;,0%20S%20&quot;+$width+&quot;,0%20&quot;+$width+&quot;,&quot;+$halfHeight+&quot;%20&quot;+$width+&quot;,&quot;+$height+&quot;%20&quot;+$halfWidth+&quot;,&quot;+$height+&quot;%200,&quot;+$height+&quot;%200,&quot;+$halfHeight+&quot;&#39;%3Cstrong%3E%3E%3C%3C/strong%3E/path%3Cstrong%3E%3E%3C%3C/strong%3E/svg%3Cstrong%3E%3E%3C/strong%3E&quot;);</pre><p>For this working properly we need extra functions:</p><ul><li>To replace ‘#’ in color code</li><li>To cut units like ‘px’</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c8b8baeb0c0c39a4ad48f77f6d91e222/href">https://medium.com/media/c8b8baeb0c0c39a4ad48f77f6d91e222/href</a></iframe><p>I included several examples in CodePen (gradients, clip-path, background, and shadows). The form itself works well in any modern browser, shadows and gradients are more specific.</p><p>Feel free to play with Super shapes here:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcodepen.io%2FOlaNikola%2Fembed%2Fpreview%2FLdMEoz%3Fheight%3D600%26slug-hash%3DLdMEoz%26default-tabs%3Dcss%2Cresult%26host%3Dhttps%3A%2F%2Fcodepen.io%26embed-version%3D2&amp;url=https%3A%2F%2Fcodepen.io%2FOlaNikola%2Fpen%2FLdMEoz&amp;image=https%3A%2F%2Fs3-us-west-2.amazonaws.com%2Fi.cdpn.io%2F1835802.LdMEoz.small.cbff4583-d305-4254-8d99-9e5c8f8c8acd.png&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=codepen" width="800" height="600" frameborder="0" scrolling="no"><a href="https://medium.com/media/e7f7887daafeca7cf2a9b75ac6950906/href">https://medium.com/media/e7f7887daafeca7cf2a9b75ac6950906/href</a></iframe><p>You can do interesting things with hover just adding other parameters in the mixins, style it different ways, you can even change the curvature by decreasing handle’s width, I just provide you few examples…</p><p>I hope this article will help you create beautiful things and inspire you to develop new interesting forms.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5ba4e1139ed" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>