I have this so far on codepen
https://codepen.io/phfilly/pen/gXbmmO?editors=1100
<div class="container">
<svg viewBox="-5 0 62.772 74.316" class="logo">
<path d="M43.034,33.66" class="logo-line"></path>
<path d="M9.607,33.012" class="logo-line-1"></path>
<path class="logo-line-two" d="M26.256,54.721c-9.245,0-16.766-7.59-16.766-16.92c0-4.496,1.729-8.73,4.867-11.921L33.171,6.882l5.514,5.561
l-6.921,6.99l6.344,6.4c0,0,0,0.001,0.001,0.001l0.002,0.002c3.168,3.196,4.911,7.445,4.911,11.964
C43.021,47.129,35.501,54.721,26.256,54.721z M26.253,24.995l-6.373,6.436c-1.67,1.698-2.595,3.965-2.595,6.37
c0,4.992,4.024,9.054,8.97,9.054c4.946-0.001,8.972-4.062,8.972-9.054c0-2.419-0.934-4.692-2.631-6.404L26.253,24.995z"></path>
<path class="logo-line-three" d="M26.387,64.316c-7.049,0-13.675-2.77-18.659-7.799C2.744,51.488-0.001,44.801,0,37.688
c0-7.076,2.722-13.739,7.663-18.763L26.394,0l5.515,5.56L13.186,24.476c-3.474,3.532-5.391,8.227-5.391,13.212
c0,5.012,1.933,9.725,5.444,13.268c3.511,3.543,8.181,5.494,13.147,5.494c10.252,0,18.591-8.416,18.591-18.762
c0-5.015-1.936-9.729-5.45-13.272h0.001l-9.11-9.192l5.512-5.564l9.114,9.199c4.984,5.028,7.729,11.715,7.729,18.83
C52.772,52.37,40.936,64.316,26.387,64.316z"></path>
</svg></div>
.logo path {
/* fill: #ff5825; */
/* transition: fill 0.5s; */
}
.container {
width: 100px;
display: block;
margin: auto;
padding: 50px 15px;
}
.logo-line-two, .logo-line-three {
fill: transparent;
stroke: #ff5825;
stroke-width: 1px;
stroke-dasharray: 320 320;
stroke-dashoffset: -300;
animation: dash 6s linear .5s infinite alternate;
}
#keyframes dash {
0% {
stroke-dashoffset: -300;
}
30% {
stroke-dashoffset: 0;
}
60% {
stroke-dashoffset: 0;
}
100% {
stroke-dashoffset: -300;
}
}
but I’m lacking a bit of knowledge on the SVG animation side of things. I would like to animate the fill colour instead (which i commented out to show the animation i’m after) and not necessarily the stroke-dash.
From my findings and research it seems that this can only be achieved by using a clipPath or is there an easier way around it? I’m not sure what attributes to use as the clipPath if that is the way.
Any help or guidelines will be greatly appreciated.
Animating fills can be messy and complicated. Since your logo consists of line segments with constant width, it makes more sense to draw it as an animated path with a stroke that matches the width of these line segments.
This is a vague approximation of what you're after; you'll have to sort out the geometry yourself.
#logo {
stroke-dasharray: 1100;
stroke-dashoffset: 1100;
animation: draw 2s forwards;
}
#keyframes draw {
to {
stroke-dashoffset: 0;
}
}
<svg width="125" height="150" viewBox="0 0 250 300">
<g transform="translate(125,170)">
<path id="logo" stroke="#000" stroke-width="30"
fill="none" stroke-linecap="butt"
d="M10.6-152.0-70.7-70.7A100 100 0 1 0 70.7-70.7L28.7
-112.7-42-42A59.4 59.4 0 1 0 42-42L10.6-73.4"
/>
</svg>
Note: If you're not sure what's going on in the <path> element, you should perhaps read up on SVG's elliptical arc commands.
The three (?) parts of your logo all have consistent width, so just redraw your logo using three thick lines rather than three outlines.
Related
So I found an svg image pattern off heropatterns.com, and I wanted to make that pattern infinitely move along the x-axis. The only problem is that for some reason there's a break/gap and the pattern isn't seamlessly looping. I'm using the translate, linear, and infinite properties, but it's still showing a gap.
It's like it's the the pattern is just moving within its container. Does anyone have any insights? here's a js fiddle I made
div.homehero-bg {
background-color: #1de9b6;
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20width%3D%2720%27%20height%3D%2712%27%20viewBox%3D%270%200%2020%2012%27%3E%3Cstyle%20type%3D%27text%2Fcss%27%3E.st0%7Banimation%3Ashift%2012s%20linear%20infinite%3B%7D%40keyframes%20shift%20%7Bfrom%20%7Btransform%3AtranslateX%280%29%3B%7Dto%20%7Btransform%3AtranslateX%28-20px%29%3B%7D%7D%3C%2Fstyle%3E%3Cg%20fill-rule%3D%27evenodd%27%20class%3D%27st0%27%3E%3Cg%20id%3D%27charlie-brown%27%20%20fill%3D%27%23361900%27%20fill-opacity%3D%271%27%3E%3Cpath%20d%3D%27M9.8%2012L0%202.2V.8l10%2010%2010-10v1.4L10.2%2012h-.4zm-4%200L0%206.2V4.8L7.2%2012H5.8zm8.4%200L20%206.2V4.8L12.8%2012h1.4zM9.8%200l.2.2.2-.2h-.4zm-4%200L10%204.2%2014.2%200h-1.4L10%202.8%207.2%200H5.8z%27%2F%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E");
background-size: 20px 12px;
background-repeat: repeat;
background-position: left top;
}
here's the decoded svg:
<svg xmlns='http://www.w3.org/2000/svg' width='20' height='12' viewBox='0 0 20 12'>
<style type='text/css'>.st0{animation:shift 12s linear infinite;}#keyframes shift {from {transform:translateX(0);}to {transform:translateX(-20px);}}
</style>
<g fill-rule='evenodd' class='st0'>
<g id='charlie-brown' fill='#361900' fill-opacity='1'>
<path d='M9.8 12L0 2.2V.8l10 10 10-10v1.4L10.2 12h-.4zm-4 0L0 6.2V4.8L7.2 12H5.8zm8.4 0L20 6.2V4.8L12.8 12h1.4zM9.8 0l.2.2.2-.2h-.4zm-4 0L10 4.2 14.2 0h-1.4L10 2.8 7.2 0H5.8z'/>
</g>
</g>
</svg>
*note: I originally got inspired from this codepen.
Better do another animation. Not in svg but in css:
.homehero-bg {
height: 400px;
width: 400px;
background-color: #1de9b6;
background-image: url("data:image/svg+xml;charset=utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20viewBox%3D%220%200%2020%2012%22%3E%3Cpath%20fill%3D%22%23361900%22%20fill-rule%3D%22evenodd%22%20d%3D%22M9.8%2012L0%202.2V.8l10%2010%2010-10v1.4L10.2%2012h-.4zm-4%200L0%206.2V4.8L7.2%2012H5.8zm8.4%200L20%206.2V4.8L12.8%2012h1.4zM9.8%200l.2.2.2-.2h-.4zm-4%200L10%204.2%2014.2%200h-1.4L10%202.8%207.2%200H5.8z%22/%3E%3C/svg%3E");
background-size: 20px 12px;
background-repeat: repeat;
background-position: 0 0;
animation: shift 12s linear infinite;
}
#keyframes shift {
to {
background-position:100% 0;
}
}
<div class="homehero-bg">
</div>
I have a simple SVG icon which I animate in CSS. Here is the SVG:
<svg width="100" height="100" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg" className={this.state.isTimewatchActive ? "active" : ""}>
<rect fill="lightgrey" id="background" ry="20" rx="20" height="512" width="512" y="0" x="0" />
<g id="icon">
<path
d="m352.35001,180.85625l-1.2375,-1.16875l12.65,0l5.84375,5.3625l15.46875,-15.675l-28.05,-27.70625l-15.95,15.33125l6.05,6.325l0,12.7875l-3.4375,-3.23125c-21.51875,-19.45625 -48.125,-31.075 -77.6875,-33.61875l0,-26.2625l-22,0l0,26.125l-1.375,0c-30.04375,2.0625 -58.4375,15.46875 -79.75,36.4375l0,-12.2375l6.11875,-6.325l-15.74375,-15.2625l-28.05,27.6375l15.46875,15.675l5.84375,-5.3625l12.2375,0c-0.20625,0 -0.48125,0.48125 -0.6875,0.75625c-22.55,24.13125 -35.0625,55.61875 -35.0625,88.34375c0,71.775 59.19375,130.2125 132.06875,130.2125c72.7375,0 131.93125,-58.36875 131.93125,-130.14375c0,-32.725 -12.375,-64.00625 -34.65,-88zm-91.85,117.90625l-5.5,12.2375l-5.5,-12.2375c-9.625,-2.40625 -16.5,-10.8625 -16.5,-20.96875c0,-9.4875 7.90625,-17.875 16.5,-20.83125l0,-88.9625l11,0l0,88.89375c9.28125,2.54375 16.5,10.93125 16.5,20.9c0,10.10625 -6.875,18.5625 -16.5,20.96875z"
fill="#FFFFFF"
stroke="null"
/>
</g>
</svg>
(I am working in the context of React, so the className attribute is really a class and the expression is evaluated to output the class string.)
This SVG has two states, active (with class="active" on the svg tag) and inactive (the code block above).
Here is the (post)CSS for the two states:
svg {
#icon {
transform: scale(0.8);
transform-origin: center center;
transition: all 0.2s;
}
#shadow {
opacity: 0;
transition: all 0.2s;
}
#background {
transition: all 0.2s;
}
&.active {
#background {
fill: $greenHn;
}
#icon {
transform: scale(1);
}
#shadow {
opacity: 0.2;
}
}
}
So at first, the icon should display at scale 0.8 in the center of the background. In Electron, it is scaled down but the transform origin is top left. The weird thing is that if I open the dev tools in Electron and toggle the transform-origin: center center rule (with the checkbox in the right-hand side panel), and toggle it back on, the rule is correctly applied.
So it doesn't seem to be a CSS problem but then I don't know what to do.
Does anyone have any idea?
Thanks :)
EDIT
As I read that SVG isn't supposed to support transform-origin, I tried using a transform: translate() instead, but I have the same behaviour.
http://www.guillaumejuvenet.com/
I'am impressed how this guy made his portfolio. Can anyone tell me how it is working?
I tried to make the path in illustrator and start draw it using stroke in CSS.
Everything works but I'am still far, far away from similar effect.
Here is the way that I used for it.
body {
background-color: #a3d5d3;
}
#check path{
stroke: red;
stroke-width: 0.5px;
stroke-dasharray: 116px; /* stroke-dasharray: 10px 5px; linia obrysowania*/
stroke-dashoffset: -116px; /*gdzie zaczynaja sie linie*/
fill: transparent;
transition: stroke-dashoffset 0.6s linear 0.5s, fill 1s ease;
}
#check.checked path {
fill: #fff;
stroke-dashoffset: 0px;
transition: stroke-dashoffset 0.8s linear, fill 2s ease 0.7s;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<div ng-app ng-init="checked = false">
<svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" viewBox="0 0 30 29" id="check" ng-class="checked ? 'checked' : ''">
<path style="stroke-dashoffset: {{range}}px" fill="#fff" d="M1.609,0.008c0.013,0.129,0.023,0.248,0.033,0.367
c0.103,1.153,0.203,2.307,0.307,3.459c0.132,1.465,0.265,2.933,0.395,4.397c0.11,1.232,0.219,2.467,0.328,3.7
c0.124,1.389,0.249,2.777,0.373,4.167c0.109,1.23,0.218,2.467,0.328,3.699c0.134,1.502,0.27,3.002,0.398,4.504
c0.008,0.098,0.039,0.139,0.135,0.164c3.177,0.896,6.352,1.793,9.525,2.688c0.08,0.021,0.176,0.021,0.256,0
c3.187-0.895,6.373-1.789,9.56-2.682c0.109-0.031,0.143-0.078,0.15-0.186c0.067-0.838,0.146-1.674,0.219-2.51
c0.082-0.922,0.166-1.846,0.248-2.77c0.074-0.826,0.146-1.65,0.221-2.477c0.084-0.924,0.166-1.848,0.248-2.771
c0.072-0.825,0.146-1.649,0.221-2.476c0.082-0.92,0.164-1.84,0.246-2.76c0.074-0.828,0.146-1.656,0.223-2.486
c0.082-0.92,0.164-1.84,0.246-2.76c0.074-0.838,0.148-1.678,0.228-2.517c0.021-0.25,0.042-0.502,0.065-0.76
C17.571,0.008,9.6,0.008,1.609,0.008z M20.831,7.965c-3.82,0-7.638,0-11.47,0c0.09,1.033,0.179,2.056,0.267,3.082
c3.649,0,7.287,0,10.938,0c-0.026,0.217-0.061,0.422-0.08,0.629c-0.051,0.521-0.1,1.043-0.146,1.562
c-0.084,0.943-0.166,1.892-0.248,2.835c-0.071,0.848-0.146,1.691-0.221,2.539c-0.047,0.535-0.101,1.07-0.146,1.604
c-0.008,0.084-0.062,0.086-0.11,0.102c-1.294,0.355-2.585,0.713-3.878,1.066c-0.709,0.197-1.416,0.396-2.126,0.592
c-0.032,0.01-0.076,0.004-0.11-0.008c-2.006-0.551-4.011-1.104-6.015-1.652c-0.092-0.023-0.094-0.08-0.1-0.146
c-0.051-0.645-0.102-1.283-0.15-1.927c-0.067-0.864-0.135-1.729-0.203-2.595c-0.002-0.021-0.002-0.049-0.004-0.08
c0.99,0,1.978,0,2.971,0c0.025,0.281,0.052,0.563,0.076,0.838c0.044,0.49,0.088,0.98,0.13,1.473
c0.004,0.057,0.021,0.078,0.075,0.094c1.076,0.287,2.15,0.578,3.228,0.867c0.038,0.012,0.084,0.006,0.123-0.004
c1.063-0.285,2.123-0.574,3.188-0.855c0.063-0.02,0.092-0.049,0.098-0.113c0.117-1.254,0.236-2.51,0.357-3.764
c0-0.004-0.002-0.008-0.004-0.022c-3.463,0-6.929,0-10.401,0C6.596,11.049,6.326,8.029,6.055,5c5.025,0,10.028,0,15.057,0
C21.021,5.988,20.925,6.971,20.831,7.965z"/>
</svg>
<button ng-click="checked = !checked">Toggle</button>
</div>
Any tips?
I'm trying to reverse how this SVG line animates. I need the line to draw from left to right but can only get it to work right to left. I tried changing the end point in illustrator but this only led to it drawing from both sides. How do I do this? You can see the animation here: http://mckeever02.github.io/voxbit/
This is the SVG:
<svg viewBox="0 0 759.7 234.2">
<path class="phone-line" stroke="#fff" stroke-width="4" stroke-dashoffset="20" fill="none" class="st0" d="M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
c-31.9,0-58,26.1-58,58v103.3v6.8c0,31.9-26.1,58-58,58H11.55" />
</svg>
and the CSS to animate it:
.phone-line {
stroke-dasharray:1400;
-webkit-animation: draw 4s ease-in;
}
#-webkit-keyframes draw {
from {
stroke-dashoffset: 1400;
}
to {
stroke-dashoffset: 0;
}
}
As you would be aware, the stroke-dasharray property creates a dashed line pattern. When the value is assigned as 1400 it means that the length of the dash and the space between the dashes is 1400. That is for 0 to 1400 the line will be present and from 1400 to 2800 a dash would be present.
Now when you change the stroke-dashoffset from 1400 to 0 it brings the line into view from one direction. Initially the offset is at 1400 and thus only the dash is visible (no line). When the offset is animated to 0, the dash moves out towards the left and the line (that is present from 0 to 1400) slowly comes into view.
A simple method to do it from the other direction would be to animate it from 1400 to 2800. When this is done, the dash moves out towards the right as the line (that is present from 2800 to 4200) slowly comes into view.
.phone-line {
stroke-dasharray: 1400;
animation: draw 4s ease-in;
}
#keyframes draw {
from {
stroke-dashoffset: 1400;
}
to {
stroke-dashoffset: 2800;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<svg viewBox="0 0 759.7 234.2">
<path class="phone-line" stroke="#000" stroke-width="4" stroke-dashoffset="20" fill="none" class="st0" d="M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
c-31.9,0-58,26.1-58,58v103.3v6.8c0,31.9-26.1,58-58,58H11.55" />
</svg>
Another approach (as mentioned by Paul LeBeau in comments) would be to animate it from -1400 to 0. This also produces the same output as the above snippet.
.phone-line {
stroke-dasharray: 1400;
animation: draw 4s ease-in;
}
#keyframes draw {
from {
stroke-dashoffset: -1400;
}
to {
stroke-dashoffset: 0;
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
<svg viewBox="0 0 759.7 234.2">
<path class="phone-line" stroke="#000" stroke-width="4" stroke-dashoffset="20" fill="none" class="st0" d="M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
M755.6,229.7H540.1c-31.9,0-57.6-27-57.6-58.9l0-5.8V61.6c0-31.9-26.1-58-58-58h-40.8h-7.9H335
c-31.9,0-58,26.1-58,58v103.3v6.8c0,31.9-26.1,58-58,58H11.55" />
</svg>
Note: Ideal approach in my view would be to change the direction of your path itself to start from the left and move to the right instead of go from right to left. This is only a simple workaround to reverse the direction without altering the path.
I'm trying to create a loading animation with ONLY html & css that looks like an ekg readout. I have it working but I want it to start redrawing sooner (right now it completely disappears and I'd like it to start drawing the before it finishes "undrawing"
<head>
<style>
body {
background-color: #fff;
}
.path {
animation: draw 2.2s infinite ease-in-out;
-webkit-animation: draw 2.2s infinite ease-in-out;
}
#keyframes draw {
from {
stroke-dashoffset: 1100;
}
to { stroke-dashoffset: 50}
}
#-webkit-keyframes draw {
from {
stroke-dashoffset: 1100;
}
to { stroke-dashoffset: 50}
}
</style>
</head>
<div class="bg">
<svg xmlns="http://www.w3.org/2000/svg" width="670" height="236" viewBox="0 0 670 236">
<path class="path" stroke="#ca6728" stroke-width="4" stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" stroke-dasharray="500" stroke-dashoffset="610" fill="none" d="M0,80.9h20.6c0.5,0,1.4-0.2,1.8-0.5L38,70.1
c0.5-0.3,1.2-0.3,1.6,0l12.7,9.4c0.4,0.3,1.3,0.6,1.8,0.6l13.3,0c0.6,0,1.2,0.4,1.5,0.9l6.2,11.3c0.3,0.5,0.5,0.4,0.5-0.1l4.4-90.8
c0-0.5,0.1-0.5,0.1,0l6.9,102.1c0,0.5,0.2,0.6,0.4,0l7-22.4c0.2-0.5,0.7-1,1.3-1l16.1,0c0.5,0,1.3-0.3,1.8-0.7L129,66.4
c0.4-0.4,1.1-0.3,1.5,0l13.3,13.1c0.4,0.4,1.2,0.7,1.7,0.7l20.1,0,"/>
</svg>
</div>
</html>
JS Fiddle here: https://jsfiddle.net/jzvenice/4sLw9ag9/
I think a similar effect can be achieved by playing with the stroke-dasharray values :
https://jsfiddle.net/4sLw9ag9/2/
...
stroke-dasharray="391 300" stroke-dashoffset="0"
....
#keyframes draw {
from {
stroke-dashoffset: 691;
}
to {
stroke-dashoffset: 0}
}
...
Only the first value is exact (length of the path is 391 pixels), it was detected with a line of JavaScript that is commented out and not needed for further functionality. The other value can be adjusted for what comes across best visually.
Edit - previously deleted the answer but it seems more relevant than a comment. So don't mind me undeleting with a minor update.