DEV Community

Cover image for The Orange
Alex
Alex

Posted on

3 1 1 1 1

The Orange

This is a submission for DEV Challenge v24.03.20, CSS Art: Favorite Snack.

Inspiration

I find an Orange a nice and refreshing snack. To statisfy the requirements of this challenge I could have just done an orange with some gradients for a bit of depth and called it a day... but where's the fun in that 😉

Demo

The orange itself is made purely with CSS, utilising radial gradients to smooth out the jump between the orange peel and the pith. The orange segments themselves are created using a clip path, along with the stem and the leaf. Each segment is a repeat rotating around the center of the orange and another radial gradient is used to create a slight reflection effect on the outside of the orange.

Now this part could be considered a bit of a cheat given that there is the smallest amount of JS present directly in my demo (one could consider it bleeding edge, whatever works for you). However this is enabling the use of the CSS paint api feature (that you'll likely only be able to see work properly/at all in Chrome at the moment). I'm using a CSS Houdini Paint Worklet that creates a Voronoi diagram that I felt could give a slightly more interesting/fun representation of the cell structure that appear in the segments of an orange.

This probably only works in Chrome based browsers...

Header image generated using Microsoft Copilot.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay