[perldoc-kr] r694 committed - Generate logo with template png

1 view
Skip to first unread message

codesite...@google.com

unread,
Apr 24, 2010, 10:58:43 PM4/24/10
to perldoc...@googlegroups.com
Revision: 694
Author: keedi.k
Date: Sat Apr 24 19:57:25 2010
Log: Generate logo with template png

http://code.google.com/p/perldoc-kr/source/detail?r=694

Added:
/trunk/slide/mkslide/bin/SeoulNamsanEB.ttf
/trunk/slide/mkslide/bin/mkslide-logo.pl
/trunk/slide/mkslide/images/template.png
Deleted:
/trunk/slide/mkslide/logo.png
Modified:
/trunk/slide/mkslide/Makefile
/trunk/slide/mkslide/bin/mkslide.pl
/trunk/slide/mkslide/slide.conf

=======================================
--- /dev/null
+++ /trunk/slide/mkslide/bin/SeoulNamsanEB.ttf Sat Apr 24 19:57:25 2010
File is too large to display a diff.
=======================================
--- /dev/null
+++ /trunk/slide/mkslide/bin/mkslide-logo.pl Sat Apr 24 19:57:25 2010
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+
+use 5.010;
+use common::sense;
+use YAML;
+use Readonly;
+use GD;
+
+Readonly my $CONF_FILE => 'slide.conf';
+
+my $slide_info = YAML::LoadFile($CONF_FILE);
+
+my $subject = $slide_info->{macro}{title};
+my $bg_image = $slide_info->{logo}{template};
+
+# create a new image
+my $gd = GD::Image->new( 800, 165 );
+my $bg = GD::Image->new( 1000, 165 );
+if ( $bg_image ) {
+ $bg = GD::Image->newFromPng( $bg_image );
+}
+
+my $bg_color = $gd->colorAllocate( 3, 29, 64 );
+my $white = $gd->colorAllocate( 255, 255, 255 );
+my $black = $gd->colorAllocate( 0, 0, 0 );
+my $red = $gd->colorAllocate( 255, 0, 0 );
+my $blue = $gd->colorAllocate( 0, 0, 255 );
+
+$gd->transparent($bg_color);
+$gd->interlaced('true');
+$gd->setAntiAliased($black);
+
+$bg->transparent($bg_color);
+$bg->interlaced('true');
+$bg->setAntiAliased($black);
+
+$gd->useFontConfig(1);
+bordered_text($gd, 1, $black, $white, './SeoulNamsanEB.ttf', 30, 0, 20,
50, $subject);
+#bordered_text($gd, 1, $black, $white, 'NanumMyeongjo:italic', 25, 0, 20,
50, $subject);
+#bordered_text($gd, 2, $black, $white, 'Arial:italic', 25, 0, 20, 50,
$subject);
+
+binmode STDOUT;
+
+$bg->copyResampled($gd, 250, 0, 0, 0, 800, 165, 800, 165);
+print $bg->png;
+
+sub bordered_text {
+ my ( $image, $width, $bordercolor, $fgcolor, $fontname, $ptsize,
$angle, $x, $y, $string ) = @_;
+
+ my $sx = $x - $width;
+ my $sy = $y - $width;
+ my $n = $width * 2;
+ for my $dx ( 0 .. $n ) {
+ for my $dy ( 0 .. $n ) {
+ $image->stringFT(
+ $bordercolor,
+ $fontname,
+ $ptsize, $angle, ($sx + $dx), ($sy + $dy),
+ $string,
+ {
+ linespacing => 1.0,
+ charmap => 'Unicode',
+ }
+ );
+ }
+ }
+
+ $image->stringFT(
+ $fgcolor,
+ $fontname,
+ $ptsize, $angle, $x, $y,
+ $string,
+ {
+ linespacing => 1.0,
+ charmap => 'Unicode',
+ }
+ );
+}
=======================================
--- /dev/null
+++ /trunk/slide/mkslide/images/template.png Sat Apr 24 19:57:25 2010
Binary file, no diff available.
=======================================
--- /trunk/slide/mkslide/logo.png Fri Jun 27 18:21:19 2008
+++ /dev/null
Binary file, no diff available.
=======================================
--- /trunk/slide/mkslide/Makefile Fri Jun 27 20:08:34 2008
+++ /trunk/slide/mkslide/Makefile Sat Apr 24 19:57:25 2010
@@ -5,6 +5,7 @@

PROJECT_OBJS = \
index.html \
+ logo.png

OBJS = $(PROJECT_OBJS)
SRCS = $(OBJS:.html=.txt)
@@ -12,26 +13,17 @@
.PHONY: all clean

MKSLIDE := bin/mkslide.pl
+MKSLIDE_LOGO := bin/mkslide-logo.pl

all: $(TARGETS)

clean:
rm -rf *~ $(PROJECT_OBJS)

-ifeq ($(V),1)
-MSG_G=
-MSG_C=
-MSG_L=
-PREFIX=
-else
-MSG_G=@echo "[G] $@ ..."
-MSG_C=@echo "[C] $@ ..."
-MSG_L=@echo "[L] $@ ..."
-PREFIX=@
-endif
-
%.html: %.txt $(MKSLIDE)
- $(MSG_C)
$(MKSLIDE) $< > $@

$(PROJECT): $(PROJECT_OBJS)
+
+logo.png: slide.conf $(MKSLIDE_LOGO)
+ $(MKSLIDE_LOGO) > $@
=======================================
--- /trunk/slide/mkslide/bin/mkslide.pl Sat Apr 24 16:35:12 2010
+++ /trunk/slide/mkslide/bin/mkslide.pl Sat Apr 24 19:57:25 2010
@@ -1,31 +1,9 @@
#!/usr/bin/perl
-#===============================================================================
-#
-# FILE: mkslide.pl
-#
-# USAGE: ./mkslide.pl index.txt > index.html
-#
-# DESCRIPTION: 텍스트 문서를 이용해서 html 슬라이드를 만들어 줍니다.
-#
-# OPTIONS: ---
-# REQUIREMENTS:
-# YAML
-# Readonly
-# Switch::Perlish
-# BUGS: ---
-# NOTES: ---
-# AUTHOR: 김도형 (Keedi Kim), <ke...@naver.com>
-# COMPANY: Emstone; Perlmania
-# VERSION: 0.01
-# CREATED: 2008년 06월 21일 09시 48분 33초 KST
-# REVISION: ---
-#===============================================================================

use 5.010;
use common::sense;
use YAML;
use Readonly;
-use Switch::Perlish;

Readonly my $CONF_FILE => 'slide.conf';
Readonly my %TAG => (
=======================================
--- /trunk/slide/mkslide/slide.conf Tue Aug 19 08:48:01 2008
+++ /trunk/slide/mkslide/slide.conf Sat Apr 24 19:57:25 2010
@@ -2,7 +2,7 @@
macro:
title: mkslide 사용하기
link: http://localhost/index.html
- email: ke...@naver.com
+ email: kee...@gmail.com
name: keedi (김도형)
company: Emstone
community: Perlmania
@@ -10,4 +10,5 @@
css: slide.css
javascript: slide.js
images: images
-
+logo:
+ template: images/template.png

--
You received this message because you are subscribed to the Google Groups "perldoc-kr-dev" group.
To post to this group, send email to perldoc...@googlegroups.com.
To unsubscribe from this group, send email to perldoc-kr-de...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/perldoc-kr-dev?hl=en.

Reply all
Reply to author
Forward
0 new messages