say() : Print messages with various animals

아스키 아트와 함께 메시지를 출력하고 싶을 때
cowsay
Author

chichead

Published

October 11, 2022

Today Function : say()

오늘의 함수는 cowsay 패키지의 say() 함수입니다. 패키지 이름에서 알 수 있듯 say() 함수를 사용하면 소를 비롯한 여러 동물들의 아스키 아트로 텍스트를 출력할 수 있습니다. 아스키 아트는 텍스트와 특수문자만을 이용해서 그림을 표현하는 것을 말합니다.


Usage

say(what = "Hello world!",
    by = "cat",
    type = NULL,
    what_color = NULL,
    by_color = NULL,
    length = 18,
    fortune = NULL,
    ...
)


Argument

what : 출력하고 싶은 말을 넣으세요
by : 어떤 동물이 말을 하도록 하고 싶나요?
type : message(기본값), warning, print, string 등 출력 타입을 선택합니다
what_color : 출력할 말의 색깔을 정합니다
by_color : 동물의 색깔을 정합니다
length : 만일 longcat을 선택했다면 longcat의 길이를 정해주세요


Example

library(cowsay)

# 닭이 꼬끼오하고 울게 해보겠습니다.
say("꼬끼오", by = "chicken")

 ----- 
꼬끼오 
 ------ 
    \   
     \
         _
       _/ }
      `>' \
      `|   \
       |   /'-.     .-.
        \'     ';`--' .'
         \'.    `'-./
          '.`-..-;`
            `;-..'
            _| _|
            /` /` [nosig]
  
# cowsay 패키지에서 제공해주는 아스키아트는 총 44마리입니다.
sort(names(animals))
 [1] "ant"          "anxiouscat"   "bat"          "bat2"         "behindcat"   
 [6] "bigcat"       "buffalo"      "cat"          "chicken"      "chuck"       
[11] "clippy"       "cow"          "daemon"       "duck"         "duckling"    
[16] "egret"        "endlesshorse" "facecat"      "fish"         "frog"        
[21] "ghost"        "grumpycat"    "hypnotoad"    "longcat"      "longtailcat" 
[26] "monkey"       "mushroom"     "owl"          "pig"          "poop"        
[31] "pumpkin"      "rabbit"       "shark"        "shortcat"     "signbunny"   
[36] "smallcat"     "snowman"      "spider"       "squirrel"     "squirrel2"   
[41] "stretchycat"  "trilobite"    "turkey"       "yoda"        
# 아스키아트에는 cat()함수를 이용해 접근할 수 있습니다.
# 호박 아스키아트에 접근해보죠.
pumpkin <- animals[["pumpkin"]]
cat(pumpkin)

 ----- 
%s 
 ------ 
    \   
     \
                  ___
               ___)__|_
          .-*'          '*-,
         /      /|   |\     \
        ;      /_|   |_\     ;
        ;   |\           /|  ;
        ;   | ''--...--'' |  ;
         \  ''---.....--''  /
          ''*-.,_______,.-*'  [nosig]
  
# longcat에게 말을 시킨다면 longcat의 길이도 정해주세요
say(what = "음메",
    by = "longcat",
    length = "20")

 ----- 
음메 
 ------ 
    \   
     \
    .ハ,,ハ
    ( ゚ω゚)
    |つ  つ
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    |    |
    U "  U
        [BoingBoing]