Tapas Adhikary | tapaScript Profile picture
Sep 14, 2021 β€’ 12 tweets β€’ 5 min read β€’ Read on X
Did you know you can use the CSS clip-path property to create any Shapes? Here is a thread to explain it most beginner-friendly way,

🧡 πŸ‘‡
The CSS clip-path helps to clip a region of an HTML element and show it. The outside of the clipped region is hidden.

See the image below. A circular region is clipped from a div of equal height and width. The circle is visible, and the rest is hidden.

πŸ‘‡ Image
There are 6 CSS functions to create shapes.

1. circle
2. inset
3. polygon
4. ellipse
5. A clip source using url()
6. path

You need an idea of the coordinate system to use the first 4 functions. It is easy. Just imagine an x and y-axis with an initial coordinate at (0,0).

πŸ‘‡ Image
1️⃣ circle() - Creates a circular shape.

We specify the position and radius of the circle using the circle() function.

clip-path: circle(70px at 70px 70px) creates a circle with a radius of 70px at the position coordinate (70, 70).

See, you get the full circular shape here
πŸ‘‡ Image
Alright, how do you get a quadrant of a circle now, say the bottom-left portion πŸ€”?

Here it is,

clip-path: circle(70px at 0 0)

Here we are creating a circle with a 70px radius at the (0, 0) coordinate. Hence only a portion is inside the visible clipped area. Bingo!!!

πŸ‘‡ Image
2️⃣ inset() - Creates a rectangular shape.

You can specify the top, right, bottom, and left offsets from the edges. Provide a border-radius value for curvy corners.

clip-path: inset(30px) creates a rectangular shape with 30px offset from the edges.

πŸ‘‡ Image
3️⃣ polygon() - Creates polygonal shape using a set of vertices.

You can go most creative with this function. Provide as many vertex positions as possible to create a shape of your choice.

A picture is worth of thousand words

πŸ‘‡ Image
4️⃣ ellipse() - Creates elliptical shapes using two radii and a position.

Here is an ellipse with 2 radii 70px and 100px respectively at the position (50%, 50%)

πŸ‘‡ Image
5️⃣ url() - provide the clip-path element’s ID as an argument to render an SVG shape.

Let's define a heart shape using SVG and clipPath. Now we can use the ID value of the clipPath element as an argument to the url() function to render this shape.

πŸ‘‡ Image
6️⃣ path() - We can use the path values directly in the path() to draw the shape.

M = moveto
L = lineto
H = horizontal lineto
V = vertical lineto
C = curveto
S = smooth curveto
Q = quadratic BΓ©zier curve
T = smooth quadratic BΓ©zier curveto
A = elliptical Arc
Z = closepath

πŸ‘‡ Image
Do you know, I've used the same knowledge to create something cool and open-sourced? Here is the story,

css-tricks.com/the-story-behi…

Learn more about CSS clip-path from here,

developer.mozilla.org/en-US/docs/Web…
Was it helpful? Would you please consider re-tweeting the thread πŸ™‚?

#CSS #DEVCommunity

β€’ β€’ β€’

Missing some Tweet in this thread? You can try to force a refresh
γ€€

Keep Current with Tapas Adhikary | tapaScript

Tapas Adhikary | tapaScript Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @tapasadhikary

Oct 1, 2022
Hacktoberfest is ON πŸš€

Here are 15 GitHub repositories for you to Contribute, Get Mentoring, and Learn Open Source

(A Thread) 🧡 ↓
βœ‹ Before we start, here are a few callouts:

- Intention is not to make these projects popular.
- The intention is to improve them with contributions.
- At the same time, contributors learn what they aspire to, get mentoring, and complete hactoberfest goals.

It's a WIN-WIN.

↓
1️⃣ ReactPlay

An app to learn ReactJS with the practice-based model.

Tech:
- ReactJS
- Next.js
- Tailwind CSS
- Plain CSS
- SaSS
- GitHub Actions
- GraphQL
- Nhost
- Cypress

Link: github.com/reactplay

↓
Read 19 tweets
Jul 26, 2022
Is Communication just about Speaking/Writing in English or any other language?

90% of Dev takes "Communication" for granted, which can be stressful in the long run.

10 tips to get better at it.

(A Thread) 🧡 ↓
Effective communication is NOT just about the language we speak or write. It's more than that.

Communication is also NOT about you. It's about others understanding you without any misunderstanding.

Here are 10 things I've been practising for years.

↓
1) Listen πŸ‘‚

- Communication is both ways. You need to listen to react and continue a discussion.
- The moment you stop listening, you are disconnected from the communication.
- Not listening to someone may make them feel low, break trust, and even damage the relationship.

↓
Read 14 tweets
Jul 11, 2022
Are you in the game of Opensource?

Here are 5 tools to know as the Project Maintainer.

(A THREAD) 🧡 ↓
First of all,

Open Source Software(OSS) project maintainers are folks who start the project, manage it, make decisions, brainstorm ideas, and work closely with contributors, users, and marketing platforms.

They need tools to automate many basic tasks.

↓
1️⃣ semantic-release

Automates the release workflow with the next version number, generating the release notes and publishing the package.

A much-needed tool to take away the headache of doing so much manual work on a project.

github.com/semantic-relea…

↓
Read 10 tweets
May 28, 2022
I've reviewed 100+ resumes in the last two days.

You don't want to make these 5 mistakes on your resume.

(A THREAD) ↓
Before we start,

- The intention here is to provide feedback, not to criticize.
- Making resumes and keeping them up-to-date is not easy.
- Reducing mistakes in resumes has higher chances of someone looking into it for a longer time, increasing the chance of getting the job.
1️⃣ Bad Formatting

- Make sure the alignments of columns are correct.
- You use a better/readable font.
- Readable texts, links.
- Proper headings.
- Bulleted points.
- People scan your resume at a go. Better formatting helps in doing that.
- Formatting reflects you.
Read 9 tweets
Oct 21, 2021
Do you find JavaScript PROMISES and Asynchronous Programming hard to grasp?

Here is a thread with a complete ROADMAP πŸ”₯ and curated RESOURCES πŸ“š to make you comfortable with it.

A Mega Thread 🧡 πŸ‘‡
As a beginner, DO NOT jump into Promises directly. Start with an understanding of,

βœ”οΈ Functions
βœ”οΈ Give special attention to Callback Functions and their various usages.
βœ”οΈ Understand the differences between Synchronous and Asynchronous Programming in JavaScript.

[...]
Functions

- A function is a block of code, a self-contained, isolated piece that performs some task.
- With functions, you gain reusability of functionality.
- You can declare, invoke, use it as an argument, return it from another function, and assign it to a variable.

[...]
Read 15 tweets
Oct 19, 2021
5 Reactjs based CHARTING LIBRARIES I have analyzed last week. Here is my LEARNING from it.

A Thread 🧡 πŸ‘‡
Using charts to do Data Visualization may be a typical ask for your web project. I had a similar requirement for a Reactjs project.

I was looking for an Opensource Data Visualization library built with D3.js, and that's when I came across these five.

πŸ‘‡
1️⃣ Recharts

- Popular with examples, documentation
- Customizable
- Responsive charts
- Utilities like tool-tips, axes, labels are very useful.
- Plenty of OOTB Charts support
- Goes well with React apps using TypeScript Image
Read 10 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Don't want to be a Premium member but still want to support us?

Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us!

:(