guillaumejuvenet - how this site is built ? / SVG path / self drawing - css
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?
Related
Transform-origin for an SVG group in Electron is ignored
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.
Odd shape SVG Animation
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.
IE10 CSS Keyframes animation issue
I've create an SVG loading indicator. It works fine in Chrome et al but I can't seem to get it working in IE10 - here's the fiddle: https://jsfiddle.net/288mu88o/ #keyframes loading { 0% { fill: red; } 100% { fill: yellow; } } .c1, .c2, .c3, .c4, .c5, .c6, .c7, .c8, .c9, .c10, .c11, .c12, .c13, .c14, .c15 { animation: loading 1.5s infinite; } .c1 { animation-delay: 1.4s; } .c2 { animation-delay: 1.3s; } .c3 { animation-delay: 1.2s; } ... <g> <circle fill="#D9E2E7 " cx="294.7" cy="342.1" r="3.5" class="c1" /> </g> <g> <circle fill="#D9E2E7 " cx="281.3" cy="344.8" r="3.5" class="c2"/> </g> <g> <circle fill="#D9E2E7 " cx="270.2" cy="352.7" r="3.5" class="c3"/> </g> ... What am I missing? Thanks.
IE 10 does not supprt CSS animation of SVG. You could use a third party solution like Fakesmile
CSS Animate SVG stroke stop at last frame
CodePen In the above codepen there is an SVG that the stroke animates into view, but at the end it just disappears. Is there a way to keep it into view once its loaded? .path { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: dash 5s linear alternate; } #keyframes dash { from { stroke-dashoffset: 1000; } to { stroke-dashoffset: 0; } }
add these two properties to your .path animation-fill-mode: forwards; // Stay on the last frame animation-iteration-count: 1;// Run only once Css will be: .path { stroke-dasharray: 1000; stroke-dashoffset: 1000; animation: dash 5s linear alternate; animation-fill-mode: forwards; // Stay on the last frame animation-iteration-count: 1; } Codepen is Here,its working fine.
This is not exactly what the OP asked for, but in case you wish to use svg's <animate> tag for your animation and encountered the same issue, you can use the fill attribute. Like this: <animate ... fill="freeze"/> This will freeze the animation at its last frame on completion. For example: <svg viewBox="-5 -5 100 20" xmlns="http://www.w3.org/2000/svg"> <rect width="90" height="10"> <animate attributeName="width" values="0;90" dur="3s" repeatCount="1" fill="freeze"/> </rect> </svg> See reference here.
How can I get an animated SVG to start "drawing itself" sooner?
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.