Blame Scripts/CentOS-Art/Functions/Render/Svg/svg.sh

8af4d8
#!/bin/bash
8af4d8
#
3f3805
# svg.sh -- This function performs base-rendition action for SVG
3f3805
# files.
8af4d8
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
8af4d8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
8af4d8
# General Public License for more details.
8af4d8
#
8af4d8
# You should have received a copy of the GNU General Public License
8af4d8
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
8af4d8
# ----------------------------------------------------------------------
8af4d8
# $Id$
8af4d8
# ----------------------------------------------------------------------
8af4d8
3f3805
function svg {
8af4d8
3a7b62
    # Initialize the export id used inside design templates. This
3a7b62
    # value defines the design area we want to export.
8af4d8
    local EXPORTID='CENTOSARTWORK'
8af4d8
3a7b62
    # Verify the export id.
8c13b6
    svg_checkModelExportId "$INSTANCE" "$EXPORTID" 
8af4d8
8af4d8
    # Check existence of external files. Inside design templates and
8af4d8
    # their instances, external files are used to refere the
8af4d8
    # background information required by the design template. If such
8af4d8
    # background information is not available the image is produced
8af4d8
    # without background information. This is something that need to
8af4d8
    # be avoided.
8c13b6
    svg_checkModelAbsref "$INSTANCE"
8af4d8
0ff158
    # Render template instance using inkscape and save the output.
0ff158
    local INKSCAPE_OUTPUT="$(\
0ff158
        inkscape $INSTANCE --export-id=$EXPORTID --export-png=${FILE}.png)"
0ff158
0ff158
    # Modify output from inkscape to fit the centos-art.sh script
0ff158
    # output visual style.
0ff158
    cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Area' \
519e5d
        | sed -r "s!^Area!`gettext "Area"`:!")"
0ff158
    cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Background' \
874511
        | sed -r "s!^Background (RRGGBBAA):(.*)!`gettext "Background"`: \1 \2!")" 
0ff158
    cli_printMessage "$(echo "$INKSCAPE_OUTPUT" | egrep '^Bitmap saved as' \
519e5d
        | sed -r "s!^Bitmap saved as:!`gettext "Saved as"`:!")"
472d62
465bb1
    # Perform backend post-rendition.
8c13b6
    svg_doPostActions
465bb1
465bb1
    # Perform backend last-rendition.
8c13b6
    svg_doLastActions
465bb1
8af4d8
}