


The wonderful company I work for, Payoneer, has a new logo, and my job was to recreate it and animate it for a loader component in our app. I’ll explain exactly how I did it, share the problems I had, and walk you through the solution I came up with. And, as a bonus, we’ll look at animating it!
But first, I guess some of you are asking yourselves… Recreate it? Why?
The branding agency that designed our logo sent us a full set of assets categorized by themes. They came in all sizes and in every available format. We had everything, including SVGs, for the logo and the loader animation. But we couldn’t use them.
Here’s why. Let’s take a look at the logo:
The logo is a ring with a conic gradient that consists of five colors, and… that’s it. The problem is that SVG doesn’t support angled gradients (for now, at least), so when we export a design that has a conic gradient as an SVG, we need some sort of hack to get the desired result.
Now, I’m no expert when it comes to working with vector graphic software, so there might be a different (and perhaps better) way to do this, but I know that the most common way to export conic gradients to SVG is to convert the gradient element to an image and insert that image into the SVG as a base64 string. That’s also what we got from the branding agency, and I trust them to know the best way to export an SVG.
But, since the final SVG file now contains a PNG base64 string, the file size jumped to nearly 1MB, which might not be a total disaster, but it’s much higher than the 2KB that it should be. Multiply that difference by three themes (no text, light text, and dark text variations), and we’re looking at 3MB worth of images instead of 3KB worth of code. That’s a big difference, so we’ve decided to recreate the logo with SVG.
But how?!
Even though CSS fully supports conic gradients, SVG does not. So the first question I asked myself was how to create a conic gradient in SVG. Actually, I asked Google. And what I found was a lot of cool, unique, creative ways to add a conic gradients to SVG, most of them relying on some sort of clip-path implementation. I first created a short
Next, I needed to fill the
div.gradient { background-image: conic-gradient(from 270deg, #ff4800 10%, #dfd902 35%, #20dc68, #0092f4, #da54d8 72% 75%, #ff4800 95%); }
The last step was to replace the So, that’s how I used a conic gradient in an SVG to keep the design fully vector and scalable with less than 20 lines of code, and less than 2KB in file size. But that was the easy part. Now let’s talk animation. Our app shows a loading animation every time a user logs in. We had been using a GIF file for it, but I had been meaning to update it to a pure CSS/SVG animation for months. The benefits are obvious: faster render means a more seamless loading experience, and a smaller file size means even faster loading. We simply get more for less, which is especially ideal for a loading animation. Here’s the animation I was aiming for: This type of animation is actually fairly easy with SVG. All we really need is a trick using stroke-dasharray and stroke-dashoffset. That was my starting point. I created a new It took me some playing around to get the movement just like the designers wanted it. I ended up using two animations, actually: one controls the stroke-dashoffset, and the second rotates the entire But, since the clip-path property refers to the fill of the shape, animating the stroke meant I had to solve one of two problems: I could either find a different way to animate the movement, or find a different way to add the colors to the stroke. So I went back to Google and all of the creative ideas I found before, but most of them were pretty much un-animatable, so I started looking for a good non-clip-path way to add colors to the stroke. I looked at a few “out-of-the-box” solutions, checked out masking, and ended up with the simplest perfect solution: A lighten blend mode looks at the RGB colors of each pixel of the rendered element, compares it to the RGB value of the background pixel that’s behind it, and keeps whichever is highest. That means that the parts of the element that are white will remain white, and the dark parts will get the values of the background pixel. By adding a white Note that the end result of this method will have a white background, not transparent like the static logo, but I was fine with that. If you need to, you can flip it around, use black background, and hide the light parts of your element by setting the blend mode to darken. I was pretty much done at this point, and quite happy with the end result. But a couple of days later, I got a Lottie-based JSON file from the branding agency with the exact same animation. In retrospect, maybe I could spare my work and use their file, it would have worked just fine. Even the file size was surprisingly small, but it was still 8✕ bigger than the SVG, so we ended up using my animation anyway. But, that meant I had one last thing to do. The Lottie animation had a “start animation” where the small orange dot grows into view, and I had to add it to my animation as well. I added a short 0.5s delay to all three animations as well as a scaling animation in the beginning. Click on “Rerun” on the Pen to see the animation again from the initial dot. That’s it! Now my company has a new logo and a set of lightweight, fully scalable assets to use across our web platforms. And for those of you wondering, yes, I did end up creating a nice little Logo component in React since we’re using it. It even renders the SVG according to a theme passed to it as a prop, making the implementation easier, and keeping all future changes in a single location. Do you think there’s a better way to get the same result? Share your thoughts in the comments! And thank you for reading.The loader
.logoBlend {
mix-blend-mode: lighten;
}
Final touches
What about you?
Atas ialah kandungan terperinci Perjuangan saya untuk menggunakan dan menghidupkan kecerunan konik di SVG. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Sekiranya anda pernah memaparkan animasi interaktif semasa ceramah langsung atau kelas, maka anda mungkin tahu bahawa ia tidak selalu mudah untuk berinteraksi dengan slaid anda

Dengan Astro, kami dapat menjana sebahagian besar laman web kami semasa membina kami, tetapi mempunyai sedikit kod pelayan yang dapat mengendalikan fungsi carian menggunakan sesuatu seperti fuse.js. Dalam demo ini, kami akan menggunakan fius untuk mencari melalui satu set "penanda buku" peribadi

Saya ingin melaksanakan mesej pemberitahuan dalam salah satu projek saya, sama seperti apa yang anda lihat dalam Dokumen Google semasa dokumen menyimpan. Dengan kata lain, a

Beberapa bulan yang lalu, saya berada di berita penggodam (seperti yang dilakukan) dan saya berlari melintasi artikel (kini dipadam) tentang tidak menggunakan jika kenyataan. Sekiranya anda baru dengan idea ini (seperti saya

Sejak awal fiksyen sains, kami telah fantasized tentang mesin yang bercakap dengan kami. Hari ini adalah perkara biasa. Walaupun begitu, teknologi untuk membuat

Saya masih ingat ketika Gutenberg dibebaskan ke teras, kerana saya berada di Wordcamp kami pada hari itu. Beberapa bulan telah berlalu sekarang, jadi saya bayangkan semakin banyak kita

Idea di sebalik kebanyakan aplikasi web adalah untuk mengambil data dari pangkalan data dan membentangkannya kepada pengguna dengan cara yang terbaik. Apabila kita berurusan dengan data di sana

Let ' s melakukan sedikit langkah demi langkah keadaan di mana anda tidak boleh melakukan apa yang kelihatannya masuk akal, tetapi anda masih boleh melakukannya dengan penipuan CSS. Dalam ini


Alat AI Hot

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Undress AI Tool
Gambar buka pakaian secara percuma

Clothoff.io
Penyingkiran pakaian AI

Video Face Swap
Tukar muka dalam mana-mana video dengan mudah menggunakan alat tukar muka AI percuma kami!

Artikel Panas

Alat panas

MantisBT
Mantis ialah alat pengesan kecacatan berasaskan web yang mudah digunakan yang direka untuk membantu dalam pengesanan kecacatan produk. Ia memerlukan PHP, MySQL dan pelayan web. Lihat perkhidmatan demo dan pengehosan kami.

Penyesuai Pelayan SAP NetWeaver untuk Eclipse
Integrasikan Eclipse dengan pelayan aplikasi SAP NetWeaver.

ZendStudio 13.5.1 Mac
Persekitaran pembangunan bersepadu PHP yang berkuasa

VSCode Windows 64-bit Muat Turun
Editor IDE percuma dan berkuasa yang dilancarkan oleh Microsoft

SublimeText3 Linux versi baharu
SublimeText3 Linux versi terkini