EmacsとGlossでお絵描きしてみるよ

  • 3,257 views
Uploaded on

http://partake.in/events/ab7f77b4-7541-47a4-867d-21a096ca883c

http://partake.in/events/ab7f77b4-7541-47a4-867d-21a096ca883c

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
3,257
On Slideshare
0
From Embeds
0
Number of Embeds
4

Actions

Shares
Downloads
7
Comments
1
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. EmacsとGlossでお絵描きしてみるよ Kiwamu Okabe
  • 2. わたしはだれ?☆ Twitter: @master_q☆ 最近転職しました☆ ミラクル・リナックス株式会社 勤務☆ Linuxでデジタルサイネージを作ってるー☆ ユニクロ銀座店に行くと実機が見れるかも
  • 3. 今日のお題☆ Emacsエディタ上の☆ ghc-modという編集モードでhttp://www.mew.org/~kazu/proj/ghc-mod/en/☆ Glossというパッケージを使ってhttp://hackage.haskell.org/package/gloss☆ 二次元萌え画像を作成せよ
  • 4. 環境設定: Debian sidの場合$ sudo apt-get install ghc-mod$ cabal install gloss簡単〜
  • 5. 環境設定: それ以外の方たぶんこんな感じ?$ cabal install gloss ghc-mod$ export PATH=$HOME/.cabal/bin:$PATH$ cd ~/.cabal/share/ghc-mod-1.10.15$ make$ lsMakefile ghc-doc.el ghc-func.elc ghc-ins-mod.elghc-command.el ghc-doc.elc ghc-indent.el ghc-ins-mod.elcghc-command.elc ghc-flymake.el ghc-indent.elc ghc.elghc-comp.el ghc-flymake.elc ghc-info.el ghc.elcghc-comp.elc ghc-func.el ghc-info.elc$ vi ~/.emacs(setq load-path (cons "/home/kiwamu/.cabal/share/ghc-mod-1.10.15" load-path))(autoload ghc-init "ghc" nil t)(add-hook haskell-mode-hook (lambda () (ghc-init) (flymake-mode)))@kazu_yamamoto さんに聞いて!
  • 6. 参考書☆ Preludeのhaddockhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html☆ Glossのhaddockhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.html☆ Hooglehttp://www.haskell.org/hoogle/があればなんとかなるんじゃなイカ?
  • 7. ライブコーディング開始ですGlossのhaddockに書かれている例から始めましょーimport Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
  • 8. 今日作ったコード #1import Graphics.Glossfib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeftjumpTo :: Num t => Way -> t -> t -> (t, t)jumpTo WLeft a b = (-b - a, -b + a)jumpTo WDown a b = (b - a, -b - a)jumpTo WRight a b = (b + a, b - a)jumpTo WUp a b = (-b + a, b + a)(次ページに続く)
  • 9. 今日作ったコード #2position :: Num b => [b] -> [(b, b)]position l = pos (0, 0) WDown (0 : l) where pos p w (x:xs) = let p = p `tplus` jumpTo w x (head xs) in p : pos p (next w) xs pos _ _ [] = [] tplus a b = let (f, s) = unzip [a, b] in (sum f, sum s)putCircle :: (Float, Float) -> Float -> PictureputCircle (x, y) r = Translate x y $ Circle rcircles :: [Float] -> Float -> Picturecircles l t = Scale s s . Pictures . take (truncate t) $ c where r = fmap (*5) l s = 10 / (1.4 ** t) c = zipWith putCircle (position r) rmain :: IO ()main = animate win white $ circles fib where win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
  • 10. ちょっとウンチクhttp://ja.wikipedia.org/wiki/黄金長方形
  • 11. 宣伝: HaskellやるならDebian!☆ 次のリリースではghc 7.4が使えるよ☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)☆ プロジェクトリーダーはOCaml使いだよ☆ 関数型ならDebianで決まりだね!☆ Debian勉強会やってるらしいよ☆ http://tokyodebian.alioth.debian.org/