Creating a Delicious Earth Progress Pie

I'm looking to incorporate a unique progress bar design on my website, similar to this one:

The progress pie

Can anyone guide me on how to create a progress pie with an image inside it that changes color as it moves?

Answer №1

To create a unique effect, you can utilize two images - one greyscale and the other colored - along with the CSS property clip-path and a script.

  1. Start by layering the greyscale image underneath the colored image.
  2. Apply the clip-path property to reveal only a specific section of the colored image.
  3. Adjust the clip-path values dynamically using either a JavaScript loop or a CSS keyframes animation.

Below is a simplified example using keyframes:

.greyscale {
  filter: grayscale(1);
}

.color {
  overflow: hidden;
  animation: clippy 2s infinite;
}

@keyframes clippy {
  0%    { clip-path: polygon(50% 50%, 50% 0,  50% 0,  50%    0,  50%    0,  50%    0,  50%    0); }
  12.5% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100%    0, 100%    0, 100%    0, 100%    0); }
  25%   { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 100%  50%, 100%  50%, 100%  50%); }
  37.5% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%, 100% 100%, 100% 100%, 100% 100%); }  
  50%   { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%,  50% 100%,  50% 100%,  50% 100%); }
  62.5% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%,    0 100%,   0  100%,    0 100%); }  
  75%   { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%,    0 100%,   0   50%,    0  50%); }  
  87.5% { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%,    0 100%,   0     0,    0    0); }
  100%  { clip-path: polygon(50% 50%, 50% 0, 100% 0, 100% 100%,    0 100%,   0     0,  50%    0); }
}

div {
  border-radius: 50%;
  height: 200px;
  overflow: hidden;
  position: relative;
  width: 200px;  
}

img {
  height: 100%;
  width: 100%;
  object-fit: cover;
  position: absolute;
}
<div>
  <img class="greyscale" src="https://interactive-examples.mdn.mozilla.net/media/examples/balloon-small.jpg">
  <img class="color" src="https://interactive-examples.mdn.mozilla.net/media/examples/balloon-small.jpg">
</div>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

step-by-step guide to replacing an item in an array using javascript

I am working with some HTML codes : <p class="Chords">[A] [B] [C]</p> <p> Some Text Goes Here </p> <p class="Chords">[D] [E] [F]</p> <p> Some Text Goes Here </p> <p class="Chords">[G] ...

Utilizing checkboxes for toggling the visibility of buttons in Angular

I want to dynamically show or hide buttons based on a checkbox. Here is the HTML code I am using: <input class="form-check-input" [(ngModel)]="switchCase" type="checkbox" id="flexSwitchCheckChecked" (change)=" ...

Attempting to include two runat=server forms within a single ASP.NET web form

As part of a course project in Web forms asp.net, I have created a master page for my website. One feature I am trying to implement is a search text box that needs to be included in the following code: <form runat="server"> This is the master code: ...

Having difficulty with the useState hook in a material ui functional component that integrates with Firebase

Currently, I am endeavoring to create a sign-up form utilizing a Material UI functional component. Within this form, I am aiming to trigger a signup event by using the "onClick" attribute attached to the sign-up button. My approach involves passing the ema ...

If an Angular reactive form component has a particular value

I am working with a group of radio buttons. When a user chooses the option "yes," I would like to display an additional input box on the form. Link to Code Example HTML.component <div formGroupName="radioButtonsGroup" class="form-group col-6 pl-0 pt- ...

Insert a JSX element into the body of a webpage using React JSX

Is there a way to dynamically add elements to the end of the body using vanilla JavaScript? const newRecipe = <div id = "container"> <div className="recipe App" id="four" onClick={this.toggleRecipeList.bind(this)}>{this.state.recipeName} < ...

Using `this` within an object declaration

I am encountering an issue with the following code snippet: const myObj = { reply(text: string, options?: Bot.SendMessageOptions) { return bot.sendMessage(msg.chat.id, text, { reply_to_message_id: msg.message_id, ...options }) ...

Using scrollIntoView() in combination with Angular Material's Mat-Menu-Item does not produce the desired result

I am facing an issue with angular material and scrollIntoView({ behavior: 'smooth', block: 'start' }). My goal is to click on a mat-menu-item, which is inside an item in a mat-table, and scroll to a specific HTML tag This is my target ...

Performing an Ajax POST request using jQuery

I am currently working on modifying my code to use POST instead of GET to send variables to a PHP page. The current code sends data via GET and receives it in JSON format. What changes should I make in order to pass the variables to process_parts.php usi ...

can you explain which documents outline the parameters that are passed into the express app.METHOD callback function?

As a beginner in javascript and nodejs, I often struggle with understanding callback functions. One thing that particularly confuses me is determining what arguments are passed into a callback function. Let's consider the following example: app.get( ...

Is it necessary to reset (local storage, session storage) once the countdown timer reaches zero?

I have successfully implemented a countdown timer using session storage in my code. However, I am looking to enhance its functionality further by: Clearing the local session if the user leaves the site before the countdown timer finishes. Automatically c ...

Node.js: Extracting parameters from the URL

When working with Rails, I make a POST request to my server: response = Typhoeus::Request.post("http://url.localtunnel.com/request?from=ola&to=ole") result = JSON.parse(response.body) Now in my Node.js application, I need to retrieve values for From ...

jQuery show/hide functionality allows you to toggle the visibility of elements

I am looking to create a toggle button that expands the menu-wrapper width and hides the sidebar when clicked. Here is the initial CSS styling: #my-wrapper { Width:500px; } #sidebar-wrapper { width:200px; } Upon clicking the button, the CSS will update ...

Tips for avoiding anti-aliasing of bitmap font on Internet Explorer and Firefox

I am currently experiencing issues with font smoothing when using a basic bitmap font for icons. While the font appears crisp in Chrome, it appears blurry in IE and FF. Do you have any recommendations on how to resolve this problem? You can view a screen ...

Is there a way for us to determine the time at which the user last took a screenshot or photo?

I am currently developing a website using Django and I have a unique requirement. I need to access the last image that a user has taken on their phone, without the image being shared by anyone else. The photo must be captured by the user's device itse ...

Ways to stop users from accidentally changing routes in react router v3

Currently, I am working on creating a custom hook to block users from making unintended route changes like using the back button or refreshing the page. Since I am using react-router v3, the <Prompt /> component in react router v4 is not an option fo ...

Using JQuery to Refresh a Div and Trigger an API Call with a Click Event

Currently, I am working on developing a web application that generates random quotes dynamically. Using JQuery, I can successfully make an API call and retrieve JSON data to display a quote. To allow users to fetch new quotes with the click of a button, I ...

Validating group radio buttons that have been checked

I possess: <div class="group"> <input type="radio" name="myradio" value="1">a <input type="radio" name="myradio" value="2">b </div> <div class="group"> <input type="radio" name="two" value="3">a <input ty ...

What is the best way to exclude the bottom four rows when sorting with MatSort?

Is there a way for me to keep the last four rows fixed when sorting the table based on the column header? Here is an image of the table: table image <table mat-table [dataSource]="dataSourceMD" matSort (matSortChange)="getRowMaximoTable( ...

A server-side rendered page in Next.js that functions without the need

Hey everyone, I'm curious about the best way to serve an HTML page in a Next Js application without relying on additional JavaScript. I need this because I want to make sure my webpage can be accessed by users who have older phones like Symbian or oth ...