cal2svg gerador de calendários em formato vetorial SVG
Publicado por Hamilton R. Amorim 06/05/2005
[ Hits: 7.886 ]
Homepage: http://www.algorista.tk
Este programinha gera um calendário vetorial que pode ser modificado em qualquer editor vetorial (Sodipodi, Inkscape, OpenOffice, Gimp, ...). Procure na seção de screenshots que eu postei uma tela de exemplo.
Os calendários ficam realmente bonitos.
O script é simples, mas faz o que tem que fazer.
O svg é gerado direto na saida do terminal, então direcione a saida para um arquivo:
$ ./cal2svg 2005 >calend_2005.svg
HRA
#!/bin/bash
ano=$1
mes=0
X=0
Y=0
#funcao que gera o calendario efetivamente
function desenhaMes() {
cal $mes $ano | awk -v M=$mes -v A=$ano -v X=$X -v Y=$Y '{
#aqui monto umas strings bases para concatenar lá embaixo
tagB = "</tspan></text> ";
align_middle="text-anchor:middle;";
align_end="text-anchor:end;";
align_left="text-anchor:left;";
style="font-family:helvetica;font-size:12px;";
style_pequeno="font-family:helvetica;font-size:7px;";
base = "<text style=\"" style align_end "\"";
base_titulo = "<text style=\"" style align_middle "\"";
base_subtitulo = "<text style=\"" style_pequeno align_end "\"";
baseX = (X * 60) + 20; # esses 20mm extras são a margem esquerda
baseY = (Y * 40) + 20; # idem
#se for a primeira linha então é a string com o nome do mes, ou seja: titulo
if (FNR == 1) {
mes = $1
ano = $2
# troca o mes por causa dos acentos que o sodipodi não compreende
if (M == 3) {
mes = "Março";
}
tagA = base_titulo " x=\"" (baseX+17) "mm\" y=\"" (baseY+5) "mm\"><tspan>"
print tagA mes " " ano tagB;
} else {
#aqui é assim: segunda linha (FNR=2) é o subtitulo, as demais linhas são os numeros
dom = substr($0, 1, 2);
seg = substr($0, 4, 2);
ter = substr($0, 7, 2);
qua = substr($0, 10, 2);
qui = substr($0, 13, 2);
sex = substr($0, 16, 2);
sab = substr($0, 19, 2);
style = base;
# troca o Sab por causa do sodipodi que não manja de portugues, de quebra por tres letras
if (FNR == 2) {
dom = "Dom";
seg = "Seg";
ter = "Ter";
qua = "Qua";
qui = "Qui";
sex = "Sex";
sab = "Sab";
style = base_subtitulo;
}
tagA1 = style " x=\"" (baseX+5) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA2 = style " x=\"" (baseX+10) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA3 = style " x=\"" (baseX+15) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA4 = style " x=\"" (baseX+20) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA5 = style " x=\"" (baseX+25) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA6 = style " x=\"" (baseX+30) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
tagA7 = style " x=\"" (baseX+35) "mm\" y=\"" (baseY + (FNR * 5)) "mm\"><tspan>";
print tagA1 dom tagB;
print tagA2 seg tagB;
print tagA3 ter tagB;
print tagA4 qua tagB;
print tagA5 qui tagB;
print tagA6 sex tagB;
print tagA7 sab tagB;
}
}';
}
#verifica o parametro
if [ -z $1 ]
then
echo "cal2svg versao 0.1 - hra - algorista@yahoo.com.br"
echo "uso: cal2svg <ano>"
echo ""
echo " <ano> com quatro digitos"
echo ""
else
#header do arquivo SVG
echo "<svg width=\"210mm\" height=\"297mm\">"
#desenha os 12 meses
for ((m=1; $m <= 12; m++))
do
mes=$m
t=$(( $m - 1 ))
Y=$(( $t / 3 ))
X=$(( $t % 3 ))
echo "<g>"
desenhaMes
echo '</g>'
done
#rodape do arquivo SVG
echo '</svg>'
fi
POSTFIX AUTOMÁTICO COM MYSQL E IPTABLES - BLOQUEAR IP
Estok SH 1.2b - Controle de Estoque em Shell Script
LazyDocker – Interface de Usuário em Tempo Real para o Docker
Instalando COSMIC no Linux Mint
Turbinando o Linux Mint: o poder das Nemo Actions
Inteligência Artificial no desenvolvimento de software: quando começar a usar?
[Resolvido] Algo deu errado ao abrir seu perfil
Usando o VNSTAT para medir o seu consumo de internet
Habilitando clipboard manager no ambiente COSMIC
Quando vocês pararam de testar distros? (12)
Problema com som no laptop (3)
Não estou conseguindo fazer funcionar meu Postfix na versão 2.4 no Deb... (2)









