EmacsとGlossでお絵描きしてみるよ
-
Upload
kiwamu-okabe -
Category
Technology
-
view
3.281 -
download
1
description
Transcript of EmacsとGlossでお絵描きしてみるよ
![Page 1: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/1.jpg)
EmacsとGlossでお絵描きしてみるよEmacsとGlossでお絵描きしてみるよEmacsとGlossでお絵描きしてみるよEmacsとGlossでお絵描きしてみるよEmacsとGlossでお絵描きしてみるよ
Kiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu OkabeKiwamu Okabe
![Page 2: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/2.jpg)
わたしはだれ?わたしはだれ?わたしはだれ?わたしはだれ?わたしはだれ?
☆ Twitter: @master_q☆ Twitter: @master_q☆ Twitter: @master_q☆ Twitter: @master_q☆ Twitter: @master_q
☆ 最近転職しました☆ 最近転職しました☆ 最近転職しました☆ 最近転職しました☆ 最近転職しました
☆ ミラクル・リナックス株式会社 勤務☆ ミラクル・リナックス株式会社 勤務☆ ミラクル・リナックス株式会社 勤務☆ ミラクル・リナックス株式会社 勤務☆ ミラクル・リナックス株式会社勤務
☆ Linuxでデジタルサイネージを作ってるー☆ Linuxでデジタルサイネージを作ってるー☆ Linuxでデジタルサイネージを作ってるー☆ Linuxでデジタルサイネージを作ってるー☆ Linuxでデジタルサイネージを作ってるー
☆ ユニクロ銀座店に行くと実機が見れるかも☆ ユニクロ銀座店に行くと実機が見れるかも☆ ユニクロ銀座店に行くと実機が見れるかも☆ ユニクロ銀座店に行くと実機が見れるかも☆ ユニクロ銀座店に行くと実機が見れるかも
![Page 3: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/3.jpg)
今日のお題今日のお題今日のお題今日のお題今日のお題
☆ Emacsエディタ上の☆ Emacsエディタ上の☆ Emacsエディタ上の☆ Emacsエディタ上の☆ Emacsエディタ上の
☆ ghc-modという編集モードで☆ ghc-modという編集モードで☆ ghc-modという編集モードで☆ ghc-modという編集モードで☆ ghc-modという編集モードでhttp://www.mew.org/~kazu/proj/ghc-mod/en/http://www.mew.org/~kazu/proj/ghc-mod/en/http://www.mew.org/~kazu/proj/ghc-mod/en/http://www.mew.org/~kazu/proj/ghc-mod/en/http://www.mew.org/~kazu/proj/ghc-mod/en/
☆ Glossというパッケージを使って☆ Glossというパッケージを使って☆ Glossというパッケージを使って☆ Glossというパッケージを使って☆ Glossというパッケージを使ってhttp://hackage.haskell.org/package/glosshttp://hackage.haskell.org/package/glosshttp://hackage.haskell.org/package/glosshttp://hackage.haskell.org/package/glosshttp://hackage.haskell.org/package/gloss
☆ 二次元萌え画像を作成せよ☆ 二次元萌え画像を作成せよ☆ 二次元萌え画像を作成せよ☆ 二次元萌え画像を作成せよ☆ 二次元萌え画像を作成せよ
![Page 4: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/4.jpg)
環境設定: Debian sidの場合環境設定: Debian sidの場合環境設定: Debian sidの場合環境設定: Debian sidの場合環境設定: Debian sidの場合
$ sudo apt-get install ghc-mod$ sudo apt-get install ghc-mod$ sudo apt-get install ghc-mod$ sudo apt-get install ghc-mod$ sudo apt-get install ghc-mod
$ cabal install gloss$ cabal install gloss$ cabal install gloss$ cabal install gloss$ cabal install gloss
簡単〜簡単〜簡単〜簡単〜簡単〜
![Page 5: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/5.jpg)
環境設定: それ以外の方環境設定: それ以外の方環境設定: それ以外の方環境設定: それ以外の方環境設定: それ以外の方
たぶんこんな感じ?たぶんこんな感じ?たぶんこんな感じ?たぶんこんな感じ?たぶんこんな感じ?$ 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)))
$ 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)))
$ 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)))
$ 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)))
$ 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 さんに聞いて!@kazu_yamamoto さんに聞いて!@kazu_yamamoto さんに聞いて!@kazu_yamamoto さんに聞いて!@kazu_yamamoto さんに聞いて!
![Page 6: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/6.jpg)
参考書参考書参考書参考書参考書
☆ Preludeのhaddock☆ Preludeのhaddock☆ Preludeのhaddock☆ Preludeのhaddock☆ Preludeのhaddockhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.htmlhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.htmlhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.htmlhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.htmlhttp://hackage.haskell.org/packages/archive/base/latest/doc/html/Prelude.html
☆ Glossのhaddock☆ Glossのhaddock☆ Glossのhaddock☆ Glossのhaddock☆ Glossのhaddockhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.htmlhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.htmlhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.htmlhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.htmlhttp://hackage.haskell.org/packages/archive/gloss/latest/doc/html/Graphics-Gloss.html
☆ Hoogle☆ Hoogle☆ Hoogle☆ Hoogle☆ Hooglehttp://www.haskell.org/hoogle/http://www.haskell.org/hoogle/http://www.haskell.org/hoogle/http://www.haskell.org/hoogle/http://www.haskell.org/hoogle/
があればなんとかなるんじゃなイカ?があればなんとかなるんじゃなイカ?があればなんとかなるんじゃなイカ?があればなんとかなるんじゃなイカ?があればなんとかなるんじゃなイカ?
![Page 7: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/7.jpg)
ライブコーディング開始ですライブコーディング開始ですライブコーディング開始ですライブコーディング開始ですライブコーディング開始です
Glossのhaddockに書かれている例から始めましょーGlossのhaddockに書かれている例から始めましょーGlossのhaddockに書かれている例から始めましょーGlossのhaddockに書かれている例から始めましょーGlossのhaddockに書かれている例から始めましょーimport Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
import Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
import Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
import Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
import Graphics.Glossmain = display (InWindow "Nice Window" (200, 200) (10, 10)) white (Circle 80)
![Page 8: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/8.jpg)
今日作ったコード #1今日作ったコード #1今日作ったコード #1今日作ったコード #1今日作ったコード #1import Graphics.Gloss
fib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)
data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeft
jumpTo :: 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)
import Graphics.Gloss
fib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)
data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeft
jumpTo :: 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)
import Graphics.Gloss
fib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)
data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeft
jumpTo :: 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)
import Graphics.Gloss
fib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)
data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeft
jumpTo :: 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)
import Graphics.Gloss
fib :: [Float]fib = 1:1:zipWith (+) fib (tail fib)
data Way = WLeft | WRight | WUp | WDownnext :: Way -> Waynext WLeft = WDownnext WDown = WRightnext WRight = WUpnext WUp = WLeft
jumpTo :: 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)
(次ページに続く)(次ページに続く)(次ページに続く)(次ページに続く)(次ページに続く)
![Page 9: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/9.jpg)
今日作ったコード #2今日作ったコード #2今日作ったコード #2今日作ったコード #2今日作ったコード #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 r
circles :: [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) r
main :: IO ()main = animate win white $ circles fib where win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
position :: 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 r
circles :: [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) r
main :: IO ()main = animate win white $ circles fib where win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
position :: 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 r
circles :: [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) r
main :: IO ()main = animate win white $ circles fib where win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
position :: 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 r
circles :: [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) r
main :: IO ()main = animate win white $ circles fib where win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
position :: 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 r
circles :: [Float] -> Float -> Picturecircles l t = Scale s s . Pictures . take (truncate t) $ cwhere r = fmap (*5) l
s = 10 / (1.4 ** t) c = zipWith putCircle (position r) r
main :: IO ()main = animate win white $ circles fibwhere win = InWindow "MyApp" (1024 `div` 2, 768 `div` 2) (0, 0)
![Page 10: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/10.jpg)
ちょっとウンチクちょっとウンチクちょっとウンチクちょっとウンチクちょっとウンチク
http://ja.wikipedia.org/wiki/黄金長方形http://ja.wikipedia.org/wiki/黄金長方形http://ja.wikipedia.org/wiki/黄金長方形http://ja.wikipedia.org/wiki/黄金長方形http://ja.wikipedia.org/wiki/黄金長方形
![Page 11: EmacsとGlossでお絵描きしてみるよ](https://reader034.fdocument.pub/reader034/viewer/2022051818/54b6c1454a7959e5268b45b1/html5/thumbnails/11.jpg)
宣伝: HaskellやるならDebian!宣伝: HaskellやるならDebian!宣伝: HaskellやるならDebian!宣伝: HaskellやるならDebian!宣伝: HaskellやるならDebian!
☆ 次のリリースではghc 7.4が使えるよ☆ 次のリリースではghc 7.4が使えるよ☆ 次のリリースではghc 7.4が使えるよ☆ 次のリリースではghc 7.4が使えるよ☆ 次のリリースではghc 7.4が使えるよ
☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)☆ (実はUbuntuのHaskellパッケージはDebianをそのままパクってるんだよ!)
☆ プロジェクトリーダーはOCaml使いだよ☆ プロジェクトリーダーはOCaml使いだよ☆ プロジェクトリーダーはOCaml使いだよ☆ プロジェクトリーダーはOCaml使いだよ☆ プロジェクトリーダーはOCaml使いだよ
☆ 関数型ならDebianで決まりだね!☆ 関数型ならDebianで決まりだね!☆ 関数型ならDebianで決まりだね!☆ 関数型ならDebianで決まりだね!☆ 関数型ならDebianで決まりだね!
☆ Debian勉強会やってるらしいよ☆ Debian勉強会やってるらしいよ☆ Debian勉強会やってるらしいよ☆ Debian勉強会やってるらしいよ☆ Debian勉強会やってるらしいよ
☆ http://tokyodebian.alioth.debian.org/☆ http://tokyodebian.alioth.debian.org/☆ http://tokyodebian.alioth.debian.org/☆ http://tokyodebian.alioth.debian.org/☆ http://tokyodebian.alioth.debian.org/