2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

TTYとLispで再帰図形

Posted at

Easy-ISLispの簡易グラフィクスを改良しました。ttyモードでフォントが小さい問題は再設定で見やすくすることができました。懐かしいCカーブも表示されています。ご紹介します。

bandicam 2025-11-18 08-15-23-677.jpg

フォントサイズ

ttyモードに入ったら次によりフォントの再設定ができます。

sudo pdkg-reconfigure console-setup

ここでUTF8、Terminus、16*32を選択します。
すると見やすい文字表示になります。

bandicam 2025-11-18 08-15-38-342.jpg

bandicam 2025-11-18 08-15-45-217.jpg

c-curve

有名な再帰図形です。初めて知ったのはウインストンのLisp本でした。

コードは下記のとおりです。

;; C-Curve recursive drawing
;; Uses gr-line to draw on /dev/fb0

(defun c-curve (x0 y0 x1 y1 depth)
  (if (= depth 0)
      (gr-line x0 y0 x1 y1 'red)
      (let* ((mx (div (+ x0 x1) 2))
             (my (div (+ y0 y1) 2))
             (dx (- x1 x0))
             (dy (- y1 y0))
             (nx (+ mx (div (- dy) 2)))
             (ny (+ my (div dx 2))))
        (c-curve x0 y0 nx ny (- depth 1))
        (c-curve nx ny x1 y1 (- depth 1)))))

;; Example usage
(defun draw ()
  (gr-open)
  (gr-cls 'black)
  (c-curve 1200 300 1500 600 10))


学習目的

実用ということになるとOPEN-GLということになろうかと思います。しかし、再帰図形の不思議を味わうにはこちらの方が優れています。付属エディタのEdlisももともとCUIエディタなので問題なく使えます。初期のパソコンで動作したテキサスインスツルメントのPC-Schemeを思い出します。どうぞお試しください。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?