Is there a way I can modify my page background color to show as random shades with svg? - svg

I have a black #000 page background on my web page.
Is there a way that I can change this with SVG to show a random effect of small #111 and #222 colored squares. I was told I could do this with SVG but I don't have any idea where to start. Even a really simple example would be a great help.
I'm looking for a solution for IE9+ browsers.

SVGs can be used as background images they same way that a PNG or JPG can. Create an SVG with any suitable editor - such as Inkscape - and include it the way you normally would.
background-image: url(../images/mybackground.svg);

Related

cairo + librsvg: draw svg icons forcing the colour at runtime

I'm using a set of svg icons in my applications, and I'm painting them using librsvg. These icons are all single-colour black drawings, and I can only draw them black because that is the colour written in the svg file.
There is a way I can to choose, at runtime, the colour (and possibily the alpha channel) of the icon just before painting them, without making a dedicated svg file for any colour I need? Can I make librsvg to ignore the colours written in the svg file and use only the one of my choice? Or any other workaround to have the same effect?
I'm thinking about loading the svg file content and modify in-memory the colour declarations, it should work, but I'm looking for a cleaner way.
Thanks.
You may want to monitor https://gitlab.gnome.org/GNOME/librsvg/issues/379 for a clean way to do this. In summary, librsvg needs an API to let you pass in an extra CSS stylesheet; this way your shapes can obtain their colors from that CSS.
https://gitlab.gnome.org/GNOME/gtk/issues/1471 mentions the way in which GTK hacks around this, and you may be able to use something similar. In short, it creates a wrapper SVG like this:
<svg ...>
<style type="text/css">
... extra styling here ...
</style>
<xi:include href="... original SVG encoded as a data:URL ..."/>
</svg>
(but check the actual source code in the comments there for the correct syntax!)

Changing only some path/group fills in a background image using svg-sprites

I'm using svg as a background image (logo) in a WP menu plugin and i want it to change a color (fill) when hovered. As it's a free version of the plugin i can't use image, object etc - i have to use my svg as a background image. I've to support IE (9+) so masks/filters are out of question and i'm pretty much left with svg-sprites. That's okey, i know how to do it (using use/xlink:href).
But now comes a tricky part. I want my svg to change only fills of some groups/paths while hovered leaving others untouched. I can only change colors of all paths/groups together in a background image with svg-sprites afaik. Is there a way to do it? Thank you in advance!

Color different when I save a svg image

In my .ai (illustrator) file you can see the right color:
But when I save to web SVG the colors change to more lighter colors:
What is happening?
I don't think illustrators svg export functionality includes blend mode filtering. So all of your blends are not being rendered, just the basic shape fill colors. I believe you could achieve your blend effects with filters or css, but it would likely have to be done outside of illustrator in the svg or web code.

Exporting transparent background using Fireworks

I'm pretty new to Fireworks. I drew an orange rectangle and made it semi-transparent. My web page has a patterned background which I'd like to be able to see through my div, but I can't change the opacity of the div in CSS as the div contains other divs that also become transparent using this CSS when I don't want them to!
I've tried loads of things I found on Google but to no avail. Can anyone help?
If you want to know how to export the semi-transparent rectangle from Fireworks so it stays that way, just make sure your canvas color is set to none (the box with a red diagonal line through it) and then export it as a PNG-32.
I'm not sure I understood what you mean by DIVs becoming transparent when using CSS. Can you elaborate on that a bit?

Rollover overlays with SVG

i want to acheive the effect on this page using SVG. As you can see it uses a series of PNG transparent overlays when the user mouses over a polygonal hotspot drawn on a product.
What i want to achieve is the same thing with SVG, but without messing about with creating a load of PNGs, so that when the user mouses over an area the transparent shape (with link on it) appears over the top. The SVG shape would be built from a set of coordinates exactly as a polygonal hotspot would on an image map.
So i guess my first question is, can this be done with plain old SVG or do i need to use something like Raphael to achieve this? Never seen this effect before with SVG so if anyone has an example like that would be very useful.
Thanks in advance.
There are several ways to get this effect with plain old SVG. Probably the simplest is to use CSS within the SVG. For example:
<style>
.overlay:hover
{
opacity: 0.5;
}
</style>
<svg>
<a xlink:href="http://www.wherever/you/want/to/link/to.com">
<path class="overlay" d="Coordinates of your shape..." />
</a>
</svg>
I've written about various other methods at:
http://www.petercollingridge.co.uk/data-visualisation/mouseover-effects-svgs
Yes it can be done with SVG only, with or without javascript.
One way to get the effect would be to overlay a white semi-transparent path on top of the image that you want to whiten. Another way would be to use an SVG filter to process the image directly, similar to what I've done here or here to recolor a PNG (view page source and feel free to reuse that in any way you like).
You'll want to make use of the 'pointer-events' property most likely. Here's an example showing how to detect mouse-events on the fill and/or stroke of an svg shape, even if the shape is invisible.

Resources