From f259c7048dda566aa63350ec746c3b2a94a514f9 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: May 02 2011 01:37:18 +0000 Subject: Update the following function files: cli_getPathComponent.sh - Fix path location from Theme/Motifs to Images/Themes. This is the new organization inside trunk/Identity for artistic motifs. cli_printMessage.sh - Add `AsCroppingFromLine' output format. render_doThemeActions - Implement massive rendition for themes. Now you can use the command: centos-art render trunk/Identity/Images/Themes to render _all_ the artistic motifs therein through the `Default' design model. If you want to produce the artistic motifs with a different design model, then you need to provide the design model name through the `--theme-model' option. render_checkSvgAbsref.sh - Do not stop rendering when the required background information isn't available. Instead, try to crop the required background information from a bigger background image (e.g., 2048x1536 pixels) so the rendition can continue. - If the bigger image doesn't exist, then created it using just a plain color (e.g., 204C8D) in order to perform the cropping action and so, provide the required background information required to produce the artwork. - This configuration backups the massive rendition of themes. --- diff --git a/Scripts/Functions/Render/render_checkSvgAbsref.sh b/Scripts/Functions/Render/render_checkSvgAbsref.sh index 25016da..0cd53b7 100755 --- a/Scripts/Functions/Render/render_checkSvgAbsref.sh +++ b/Scripts/Functions/Render/render_checkSvgAbsref.sh @@ -3,9 +3,12 @@ # render_checkSvgAbsref.sh -- This function retrives absolute files # and checks their existence. In order for design templates to point # different artistic motifs, design templates make use of external -# files that point to specific artistic motif background images. If -# such external files doesn't exist, print a message and stop script -# execution. We cannot continue without background information. +# files which point to specific artistic motif background images. If +# such external files don't exist, try to create the background image +# required by cropping a higher background image (e.g., +# 2048x1536-final.png). If this isn't possible neither, then create +# the background image using a plain color and crop from it then. We +# can't go on without the required background information. # # Copyright (C) 2009, 2010, 2011 The CentOS Project # @@ -30,23 +33,95 @@ function render_checkSvgAbsref { local FILE='' - local ABSPATHS='' - local ABSPATH='' + local BG_DST_FILES='' + local BG_DST_FILE='' + local BG_DST_FILE_WIDTH='' + local BG_DST_FILE_HEIGHT='' + local BG_SRC_FILE='' + local BG_SRC_FILE_COLOR='' + local BG_SRC_FILE_WIDTH='' + local BG_SRC_FILE_HEIGHT='' - # Define absolute path of file we need to retrive absolute paths - # from. + # Define absolute path to the translated instance of design model. FILE="$1" # Verify existence of file we need to retrive absolute paths from. cli_checkFiles $FILE 'f' # Retrive absolute paths from file. - ABSPATHS=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ + BG_DST_FILES=$(egrep "(sodipodi:absref|xlink:href)=\"${HOME}.+" $FILE \ | sed -r "s,.+=\"(${HOME}.+\.png)\".*,\1,") # Verify absolute paths retrived from file. - for ABSPATH in $ABSPATHS;do - cli_checkFiles "$ABSPATH" 'f' + for BG_DST_FILE in $BG_DST_FILES;do + + if [[ ! -a $BG_DST_FILE ]];then + + # Warn about required background omission. + cli_printMessage "`eval_gettext "The path \\\"\\\$BG_DST_FILE\\\" doesn't exist."`" 'AsErrorLine' + + # Define the source background file, the image file will + # crop when no specific background informatio be available + # for using. Generally, this is the most reusable + # background file inside the artistic motifs (e.g,. the + # `2048x1536-final.png' file). We can use this image file + # to create almost all artworks inside The CentOS + # Distribution visual manifestation when + # resolution-specific backgrounds don't exist. + BG_SRC_FILE=$(echo $BG_DST_FILE \ + | sed -r "s!(.+)/[[:digit:]]+x[[:digit:]]+(-final\.png)!\1/2048x1536\2!") + + # Verify existence of source background file. If the file + # doesn't exist create it using The CentOS Project default + # background color information, as specified in its + # corporate identity manual. + if [[ ! -f $BG_SRC_FILE ]];then + + # Define plain color for the source background file + # the required background information is cropped from. + BG_SRC_FILE_COLOR='rgb:20/4C/8D' + + # Define width for the source background file the + # required background information is cropped from. + BG_SRC_FILE_WIDTH=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define height for the source background file the + # required background information is cropped from. + BG_SRC_FILE_HEIGHT=$(echo $BG_SRC_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Print action message. + cli_printMessage "${BG_SRC_FILE} ($BG_SRC_FILE_COLOR)" 'AsCreatingLine' + + # Create the source background file. + ppmmake -quiet ${BG_SRC_FILE_COLOR} \ + ${BG_SRC_FILE_WIDTH} ${BG_SRC_FILE_HEIGHT} \ + | pnmtopng > ${BG_SRC_FILE} + + fi + + # Print action message. + cli_printMessage "$BG_SRC_FILE" 'AsCroppingFromLine' + + # Define the width of the required background information. + BG_DST_FILE_WIDTH=$(echo $BG_DST_FILE \ + | sed -r 's!.+/([[:digit:]]+)x[[:digit:]]+-final\.png!\1!') + + # Define the height of the required background information. + BG_DST_FILE_HEIGHT=$(echo $BG_DST_FILE \ + | sed -r 's!.+/[[:digit:]]+x([[:digit:]]+)-final\.png!\1!') + + # Create required backgrounnd information. + convert -quiet \ + -crop ${BG_DST_FILE_WIDTH}x${BG_DST_FILE_HEIGHT}+0+0 \ + ${BG_SRC_FILE} ${BG_DST_FILE} + + # Verify required background information. + cli_checkFiles $BG_DST_FILE + + fi + done } diff --git a/Scripts/Functions/Render/render_doThemeActions.sh b/Scripts/Functions/Render/render_doThemeActions.sh index d436915..86e853e 100755 --- a/Scripts/Functions/Render/render_doThemeActions.sh +++ b/Scripts/Functions/Render/render_doThemeActions.sh @@ -25,6 +25,11 @@ function render_doThemeActions { + local -a MOTIFS + local MOTIF='' + local COUNT=0 + local NEXT_DIR='' + # Define patterns using the design model specified by # FLAG_THEME_MODEL as reference to know what organization to # create inside artistic motifs. When rendering, this condition @@ -33,23 +38,60 @@ function render_doThemeActions { # configuration is that you can have more than one design models # and each one can has its own unique organization. local MODELS_PATTERN=$(find \ - $(cli_getRepoTLDir)/Identity/Models/Themes/Default/ \ + $(cli_getRepoTLDir)/Identity/Models/Themes/${FLAG_THEME_MODEL}/ \ -type d | egrep -v '\.svn' | sed -r '/^$/d' | sed -r \ "s!^.*/${FLAG_THEME_MODEL}/!!" | tr "\n" '|' \ | sed -e 's!^|!!' -e 's!|$!!') # Define list of available artistic motifs include their names and # versions directory levels. To build this list use the theme - # design model directory structure as renference. - local MOTIFS=$(find $(cli_getRepoTLDir)/Identity/Images/Themes \ - -regextype posix-egrep -type d \ - -regex ".+/(${MODELS_PATTERN})$" \ - | sort | egrep "$ACTIONVAL") - - # Redefine action value using the list of available artistic - # motifs. - for ACTIONVAL in $(echo $MOTIFS);do + # design model directory structure as renference. Also, build the + # list using the most specific renderable directories (e.g., those + # whose have a longer path) to avoid unnecessary rendition loops. + for MOTIF in $(find $(cli_getRepoTLDir)/Identity/Images/Themes \ + -regextype posix-egrep -type d -regex ".+/(${MODELS_PATTERN})$" \ + | sort -r | grep $ACTIONVAL);do + MOTIFS[((++${#MOTIFS[*]}))]=${MOTIF} + done + + # Redefine counter using the grater value to perform an inverted + # interpretation of the values and so process them using the same + # order. + COUNT=$((${#MOTIFS[*]} - 1)) + + until [[ $COUNT -eq 0 ]];do + + # Redefine action value to refer theme specific renderable + # directory. + ACTIONVAL=${MOTIFS[$COUNT]} + + # Define what is the next directory in the list, so we could + # verify whether to render or not the current theme specific + # renderable directory. + if [[ $COUNT -eq 0 ]];then + NEXT_DIR='' + else + NEXT_DIR=$(dirname ${MOTIFS[(($COUNT - 1))]}) + fi + + # Verify whether to render or not the current theme renderable + # directory. This verificatin is required in order to avoid + # unncessary rendition loops. For example, don't render + # `path/to/dir/A' when `path/to/dir/A/B' does exist, that + # configuration would produce `/path/to/dir/A/B twice. + if [[ $ACTIONVAL =~ '[[:digit:]]$' ]] \ + || [[ $ACTIONVAL == $NEXT_DIR ]];then + COUNT=$(($COUNT - 1)) + continue + fi + + # Execute direct rendition on theme specific renderable + # directory as specified by action value. render_doBaseActions + + # Decrement counter. + COUNT=$(($COUNT - 1)) + done } diff --git a/Scripts/Functions/cli_getPathComponent.sh b/Scripts/Functions/cli_getPathComponent.sh index 9e26572..dbee5e5 100755 --- a/Scripts/Functions/cli_getPathComponent.sh +++ b/Scripts/Functions/cli_getPathComponent.sh @@ -100,9 +100,9 @@ function cli_getPathComponent { # Example: # +------> theme name # |-->| - # trunk/Identity/Themes/Motifs/Flame/1 - # trunk/Identity/Themes/Motifs/Flame/2 - # trunk/Identity/Themes/Motifs/Flame/3 + # trunk/Identity/Images/Themes/Flame/1 + # trunk/Identity/Images/Themes/Flame/2 + # trunk/Identity/Images/Themes/Flame/3 # | # +----> theme version # @@ -144,8 +144,8 @@ function cli_getPathComponent { # Example: # +------> theme name # |-->| - # tags/Identity/Themes/Motifs/Flame/1.0 - # trunk/Identity/Themes/Motifs/Flame/1 |--> minor update + # tags/Identity/Images/Themes/Flame/1.0 + # trunk/Identity/Images/Themes/Flame/1 |--> minor update # |----> major udpate # # Tags have the format X.Z, where X is the first number in the @@ -162,24 +162,24 @@ function cli_getPathComponent { # # Consider the following relations: # - # trunk/Identity/Themes/Motifs/Flame/1 - # tags/Identity/Themes/Motifs/Flame/1.0 - # tags/Identity/Themes/Motifs/Flame/1.1 - # tags/Identity/Themes/Motifs/Flame/1.2 + # trunk/Identity/Images/Themes/Flame/1 + # tags/Identity/Images/Themes/Flame/1.0 + # tags/Identity/Images/Themes/Flame/1.1 + # tags/Identity/Images/Themes/Flame/1.2 # - # trunk/Identity/Themes/Motifs/Flame/2 - # tags/Identity/Themes/Motifs/Flame/2.0 - # tags/Identity/Themes/Motifs/Flame/2.1 - # tags/Identity/Themes/Motifs/Flame/2.2 + # trunk/Identity/Images/Themes/Flame/2 + # tags/Identity/Images/Themes/Flame/2.0 + # tags/Identity/Images/Themes/Flame/2.1 + # tags/Identity/Images/Themes/Flame/2.2 # - # trunk/Identity/Themes/Motifs/TreeFlower/1 + # trunk/Identity/Images/Themes/TreeFlower/1 # ... # and so on. # # Tag versions are created to release fixes and improvements, Tags # are immutable (i.e., once tags are created, they shouldn't be # modified.). - PATTERN[2]="Identity/Themes/Motifs/(([A-Za-z0-9]+)/(${PATTERN[0]}))/" + PATTERN[2]="Identity/Images/Themes/(([A-Za-z0-9]+)/(${PATTERN[0]}))/" # Identify which part of the release we want to output. case "$OPTION" in diff --git a/Scripts/Functions/cli_printMessage.sh b/Scripts/Functions/cli_printMessage.sh index 810e94d..da97e44 100755 --- a/Scripts/Functions/cli_printMessage.sh +++ b/Scripts/Functions/cli_printMessage.sh @@ -55,6 +55,10 @@ function cli_printMessage { cli_printMessage "`gettext "Updating"`: $MESSAGE" ;; + 'AsCroppingFromLine' ) + cli_printMessage "`gettext "Cropping from"`: $MESSAGE" + ;; + 'AsTuningLine' ) cli_printMessage "`gettext "Tuning"`: $MESSAGE" ;;