<img src="https://picsum.photos/id/1015/300/300" class="flower">
@property --a {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
@property --o {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
$n: 8; /* the number of circles/petals */
.flower {
--s: 350px; /* image size */
--a: 28deg; /* this will control the curvature */
--r: calc(var(--s)/(2 + 2*sin(90deg/#{$n})));
width: var(--s);
padding: calc(.4*var(--r));
border-radius: 50%;
clip-path: circle(49%);
background: linear-gradient(60deg,#2d576d,#e0236f);
aspect-ratio: 1;
box-sizing: border-box;
--R: calc(var(--r)*(sin(180deg/#{$n})/2)*(1/cos(90deg/#{$n} - var(--a)) + 1/cos(90deg/#{$n} + var(--a))));
--g:/var(--R) var(--R) radial-gradient(50% 50%,#000 calc(100% - 1px),#0000) no-repeat;
$m1: ();
$m2: ();
@for $i from 1 through $n {
$m1: append($m1,
calc(50% + var(--r)*(1 - (sin(90deg/#{$n})*sin(var(--a)))/cos(90deg/#{$n} - var(--a)))*cos(360deg*#{$i/$n} + var(--o)) )
calc(50% + var(--r)*(1 - (sin(90deg/#{$n})*sin(var(--a)))/cos(90deg/#{$n} - var(--a)))*sin(360deg*#{$i/$n} + var(--o)) )
var(--g),
comma);
$m2: append($m2,
calc(50% + var(--r)*(1 + (sin(90deg/#{$n})*sin(var(--a)))/cos(var(--a) + 90deg/#{$n}))*cos((360deg*#{$i} + 180deg)/#{$n} + var(--o)) )
calc(50% + var(--r)*(1 + (sin(90deg/#{$n})*sin(var(--a)))/cos(var(--a) + 90deg/#{$n}))*sin((360deg*#{$i} + 180deg)/#{$n} + var(--o)) )
var(--g),
comma);
}
mask:
#{$m1},
radial-gradient(calc(var(--r)*sqrt(sin(2*var(--a))*sin(2*var(--a)) + pow(cos(2*var(--a)) + cos(180deg/#{$n}),2))*(1/cos(90deg/#{$n} - var(--a)) + 1/cos(90deg/#{$n} + var(--a)))*.25),#000 99%,#0000 101%) subtract,
#{$m2};
transition: --a .3s;
cursor: pointer;
animation:
rotate 15s infinite linear,
rotate 30s infinite linear reverse paused;
animation-composition: add;
}
img:hover {
--a: 10deg;
animation-play-state: running;
}
@keyframes rotate {
to{--o:360deg}
}
body {
margin: 0;
min-height: 100vh;
display: grid;
place-content: center;
place-items: center;
grid-auto-flow: column;
background: #E0E4CC;
}
View Compiled
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.