Skip to content

scottdotjs/svg-css-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SVG to CSS compiler

Description

A simplistic tool to take SVG files and compile them into a CSS file as classes that use data: URIs for background images.

This is the first revision and doesn't have options or anything nice yet. I wrote it to use with Lipis' country flags so it's still geared to that use.

It looks in a directory (currently input) for files with the names (not including .svg) that you specify in the array @file_names. The resulting file will be output/compiled.css with classes that look like this:

    .flag-whatever {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' ...");
        background-repeat: no-repeat;
        width: 320px;
        height: 240px;
    }

"whatever" in each case will be the name of each file as specified earlier. You can edit the constant CSS_TEMPLATE to change this - a future version of this tool will have the template externally to avoid needing to touch the code.

Usage

perl svg-css-compiler.pl

Author and license

Copyright 2022 Scott Martin.

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

About

Tool to compile SVG files into CSS classes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages