I have a rectangular div, where I added a background-color
, and background-image
with repeat on, so that the semi-transparent image blend with the background color and make a colorful patterned background for my content. I took a pattern from SubtlePatterns which is: 300px × 295px
in dimension. Here's the code:
#nd {
background-image: url('../images/dark-mosaic.png');
background-color: #b33939;
color: #fff;
}
Now I wanted to make the harsh rectangle a bit smoother, so I took an SVG separator from this link. Used this answer to make an SVG path background image. With the following code:
<svg id="curveUpColor" xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100" viewBox="0 0 100 100" preserveAspectRatio="none">
<defs>
<pattern id="img1" patternUnits="userSpaceOnUse" width="300" height="295">
<image xlink:href="{{ asset('images/dark-mosaic.png') }}" x="0" y="0" width="300" height="295" />
</pattern>
</defs>
<path d="M0 100 C 20 0 50 0 100 100 Z" fill="url(#img1)"></path>
</svg>
I ended up with a SVG shape with stretched/filled background image:
I consulted this link and fixed the width and height attribute of the <image>
tag to the width and height of the image file, but I failed.
Now I have two questions:
- How can I make the background image to be tiled exactly like the rectangle?
- How can I put a fill color to the shape so that the SVG pattern matched with the pattern in the rectangle?