Triangle svg with a transparent semi-circle on its side - html

I'm searching a way to make those svg path, but without luck for now.
I was searching on the internet for a long time ...
I know that css can do this but if someone knows how to build them with SVG it would be really nice.
Thank you
First SVG :
Second SVG :

You should learn about SVG path commands.
https://www.w3.org/TR/SVG2/paths.html#PathData
For example, you can define such shapes by list of some path commands.
<svg viewBox="0 0 200 200" width="200" height="200">
<path d="M0 0l60 60a1 1 0 0 0 80 80l60 60h-200z"/>
</svg>
<svg viewBox="0 0 200 200" width="200" height="200">
<path d="M0 0l60 60a1 1 0 0 1 80 80l60 60v-200z"/>
</svg>

Related

Why doesn't this SVG display?

I'm working on a project that uses svg. I generate this svg code thanks to an ocaml library:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:l="http://www.w3.org/1999/xlink" version="1.1" width="161.8mm" height="100mm" viewBox="0 0 161.8 100" color-profile="auto" color-interpolation="linearRGB" color-interpolation-filters="linearRGB">
<g fill="none" stroke-miterlimit="9.98123" transform="matrix(100 0 0 -100 -0 100)">
<defs>
<path id="i1" d="M0 0L1.618 0L1.618 1L0 1Z"/>
</defs>
<use l:href="#i1" fill="#50C878"/>
</g>
</svg>
When I use gthumb or GIMP to display the svg, it prints the correct green square. However, when I include this block of code in Chromium or Firefox, the block appears in the html tree but nothing is display. This is the first time I use svg: after several researches on Google, I can't find anything....
Does someone know why it doesn't work ?
Edit
Solve with the answer:
<use xlink:href="#i1">

How to use W3.org's SVG Icons on my website?

I often scan through the elements in websites and keep seeing things like:
<svg width="13" height="13" viewBox="0 0 13 13" version="1.1"
xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink" data-ui-test="undefined-svg">
<use x="0" y="0" width="13" height="13" xlink:href="/images/icons/icon_definitions.svg#heart"></use></svg>
How can I use the icons like that on my website? I tried going to W3.org to find out how but it is not very clear how to do it, if at all I can. Anyone care to explain?
You will see similiar code if you open any .svg file in some text editor. It's just two-dimensional vector described in XML language which can be directly used in HTML.
SVG is a language based on XML for describing two-dimensional vector and mixed vector/raster graphics.
source: w3.org/TR/SVG2/
As an example you can check iconsvg.xyz. Each of these icons are downloadable as .svg but you can see their code right above the download button.
I don't know much about SVG icons but I've used some in my project. The format is as shown below in the snippet I created. There is a website I use with free icons but they are not as much. The website is https://iconsvg.xyz/. It gives you the full code of the icon you will choose where you just paste it into your HTML file.
<div>
<h5>This is a user icon</h5>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M5.52 19c.64-2.2 1.84-3 3.22-3h6.52c1.38 0 2.58.8 3.22 3"/><circle cx="12" cy="10" r="3"/><circle cx="12" cy="12" r="10"/></svg>
<h5>This is a brand icon</h5>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="#000"><path d="M12.04 3.5c.59 0 7.54.02 9.34.5a3.02 3.02 0 0 1 2.12 2.15C24 8.05 24 12 24 12v.04c0 .43-.03 4.03-.5 5.8A3.02 3.02 0 0 1 21.38 20c-1.76.48-8.45.5-9.3.51h-.17c-.85 0-7.54-.03-9.29-.5A3.02 3.02 0 0 1 .5 17.84c-.42-1.61-.49-4.7-.5-5.6v-.5c.01-.9.08-3.99.5-5.6a3.02 3.02 0 0 1 2.12-2.14c1.8-.49 8.75-.51 9.34-.51zM9.54 8.4v7.18L15.82 12 9.54 8.41z"/></svg>
</div>

The shape change when the window decrease with svg

I'm currently working on a website and I need help on a svg trapezoid shape.
I decided to use SVG because, before that, my trapezoid was realized with css and the main problem with that is that is wasn't responsive as I expected.
This is the shape I would like : Trapezoid.
I've already realized this shape but the problem is when the window size decrease the shape look like that.
So my question is, does there any ways to "lock" the points to keep the shape of the 1st image ?
HTML :
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="84%" height="200" preserveAspectRatio="none">
<polygon fill="blue" points="1.5 0, 100 0, 85 100, 1.5 100"/>
...
</svg>
Edit:
Thanks to Paulie_D, i've patched my problem with :
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100%" height="200" preserveAspectRatio="xMaxYMin slice" class="spaceBetweenButton" >
<polygon fill="#00a8f3" points="1.5 0, 100 0, 0 100, 1.5 100"/>
...
</svg>
But now I would like to add another trapezoid at the right of the 1st like that but as before, my problem isn't on how to realize the shape but on how it render with this code :
<div class="col-md-2 col-xs-12">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100%" height="200" preserveAspectRatio="xMaxYMin slice" transform="rotate(180)" class="spaceBetweenButton">
<polygon fill="#00a8f3" points="0 0, 130 0, 0 130, 0 130" />
</svg>
</div>
And how it appear. At first sight I thought that the problem was in the preserveAspectRatio so I've tried to replace it by xMaxYMin slice off but I didn't found a way to have a decent result with it.
So I have 2 problem, how to extend the right trapezoid (I think it's with the width of the svg) and how to move it on the left. I've tried to add margin but the space between the 2 trapezoid changes when we resize the window.
Thanks for your help.
Valentin.
Just add another polygon to your SVG.
Move the right hand end of the first polygon left a bit
Add a second polygon of the right shape, to the right of that, leaving an appropriate gap.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100" width="100%" height="200" preserveAspectRatio="xMaxYMin slice" class="spaceBetweenButton" >
<polygon fill="#00a8f3" points="0 0, 83 0, 0 83"/>
<polygon fill="#00a8f3" points="85 0, 100 0, 100 100, 0 100, 0 85"/>
</svg>

SVG size of shape with css

I trying to set the icon width at 100% of the svg container. This is my problem:
And this is the code for SVG icon
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve" class="icon">
<path width="100px" height="100px" fill-rule="evenodd" clip-rule="evenodd" d="M79.941,43.641h-4c-1.104,0-2-0.895-2-2c0-1.104,0.896-1.998,2-1.998h4
c1.104,0,1.999,0.895,1.999,1.998C81.94,42.747,81.046,43.641,79.941,43.641z M72.084,30.329c-0.781,0.781-2.047,0.781-2.828,0
c-0.781-0.78-0.781-2.047,0-2.827l2.828-2.828c0.781-0.781,2.047-0.781,2.828,0c0.781,0.78,0.781,2.047,0,2.828L72.084,30.329z
M69.137,45.936L69.137,45.936c1.749,2.086,2.806,4.77,2.806,7.706l0,0c0,5.227-3.349,9.66-8.014,11.305
c-0.027-1.336-0.434-2.66-1.222-3.807c3.054-1.127,5.235-4.055,5.235-7.498c0-4.418-3.581-8-7.999-8
c-1.601,0-3.083,0.482-4.333,1.291c-1.232-5.316-5.974-9.29-11.665-9.29c-6.626,0-11.998,5.372-11.998,11.999
c0,1.404,0.254,2.746,0.697,4h0.015c0.975,2.74,2.895,5.031,5.395,6.445l-0.058,0.057c-0.98,0.98-1.596,2.184-1.872,3.445
c-3.751-2.107-6.551-5.686-7.652-9.947l0,0c-0.33-1.281-0.524-2.617-0.524-4c0-8.836,7.163-15.998,15.998-15.998
c1.572,0,3.089,0.232,4.523,0.654c2.195-2.827,5.618-4.654,9.475-4.654c6.627,0,11.999,5.372,11.999,11.998
C69.942,43.157,69.649,44.602,69.137,45.936z M57.943,33.644c-2.212,0-4.214,0.898-5.662,2.35c2.34,1.436,4.286,3.453,5.629,5.853
c0.664-0.113,1.337-0.205,2.033-0.205c2.126,0,4.118,0.559,5.85,1.527l0,0c0.096-0.494,0.149-1.004,0.149-1.527
C65.942,37.225,62.361,33.644,57.943,33.644z M57.943,25.644c-1.104,0-1.999-0.895-1.999-1.999v-3.999c0-1.105,0.895-2,1.999-2
s2,0.895,2,2v3.999C59.943,24.749,59.048,25.644,57.943,25.644z M43.804,30.329l-2.828-2.827c-0.781-0.781-0.781-2.048,0-2.828
c0.78-0.781,2.047-0.781,2.828,0l2.828,2.828c0.78,0.78,0.78,2.047,0,2.827C45.851,31.11,44.584,31.11,43.804,30.329z
M42.945,60.851l2.121,2.121c1.172,1.172,1.172,3.07,0,4.242c-1.171,1.172-3.07,1.172-4.242,0c-1.171-1.172-1.171-3.07,0-4.242
L42.945,60.851z M49.944,68.849l2.121,2.121c1.172,1.172,1.172,3.072,0,4.242c-1.171,1.172-3.07,1.172-4.242,0
c-1.171-1.17-1.171-3.07,0-4.242L49.944,68.849z M56.943,60.851l2.121,2.121c1.172,1.172,1.172,3.07,0,4.242
c-1.171,1.172-3.07,1.172-4.241,0c-1.172-1.172-1.172-3.07,0-4.242L56.943,60.851z"/>
</svg>
Thanks
As mentioned by Robert Longson you can transform (scale) the path to the correct size and transform (translate) it to ensure it maintains the correct position
JSfiddle Demo
Additional SVG Path Info
transform="translate(-40,-28) scale(1.66)
The values are for this path / viewbox configuration.
As an alternative, you should look into redrawing the path based on a set viewbox intended for this path to fill the viewbox.

SVG path not observing aspect ratio

I'm having trouble getting the SVG path to scale to its container:
<svg xmlns="http://www.w3.org/2000/svg"
preserveAspectRatio="xMidYMid"
viewBox="0 0 16 16"
width="16"
height="16">
<path stroke="#000" fill="none" d="M209,15a195,195 0 1,0 2,0zm1,0v390m195-195H15M59,90a260,260 0 0,0 302,0 m0,240 a260,260 0 0,0-302,0M195,20a250,250 0 0,0 0,382 m30,0 a250,250 0 0,0 0-382"></path>
</svg>
Demo: http://jsfiddle.net/FeTv2/1/ - As you can see the path is way too big, and seems to have a top and left offset.
Looks the same in Chrome and Firefox.
The viewBox of you SVG is way too small to fit the path you're using. The viewBox represents the part of your SVG, that should be shown. The width and height the represent the dimension of the box, in which the content is shown.
Try a viewBox size, that really fits your path like this (may need further adjustments):
<svg height="16" width="16"
viewBox="0 0 450 450"
preserveAspectRatio="xMidYMid"
xmlns="http://www.w3.org/2000/svg">
<path d="M209,15a195,195 0 1,0 2,0zm1,0v390m195-195H15M59,90a260,260 0 0,0 302,0 m0,240 a260,260 0 0,0-302,0M195,20a250,250 0 0,0 0,382 m30,0 a250,250 0 0,0 0-382" fill="none" stroke="#000"/>
</svg>
Additionally, you may (or may not) want to adjust the size of the <svg> element.
Example Fiddle (big <svg>)
Example Fiddle (16x16 <svg>)