• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

A categorical programming language


Commit MetaInfo

修订版873bb278c3325ccf4b0144c07f98a4af52c801ec (tree)
时间2021-10-16 04:02:28
作者Corbin <cds@corb...>
CommiterCorbin

Log Message

Improve draw command's memory usage.

更改概述

差异

--- a/stub.scm
+++ b/stub.scm
@@ -1,4 +1,4 @@
1-(import (srfi 4) (srfi 6) (srfi 144) (srfi 189))
1+(import (srfi 6) (srfi 144) (srfi 160 u8) (srfi 189))
22 (import (chicken condition) (chicken format) (chicken process-context) (chicken string))
33 (import (matchable))
44 (import (stb-image-write))
@@ -111,17 +111,20 @@
111111 (r (car color))
112112 (g (car (cdr color)))
113113 (b (cdr (cdr color))))
114- (map finish-channel (list r g b))))
115-
116-(define (count-to i) (if (eqv? 0 i) '() (cons (- i 1) (count-to (- i 1)))))
114+ (list->u8vector (map finish-channel (list r g b)))))
117115
118116 (define ((draw-png program width height))
119- (let
117+ (let*
120118 ((vp (viewport width height))
121- (indices (reverse (count-to (* width height)))))
122- (write-png (list->u8vector
123- (flatten (map (draw-pixel program vp) indices)))
124- width height 3)))
119+ (drawable (draw-pixel program vp))
120+ (size (* width height))
121+ (channels 3)
122+ (pixels
123+ (do ((buf (make-u8vector (* size channels)))
124+ (i 0 (+ i 1)))
125+ ((eqv? i size) buf)
126+ (u8vector-copy! buf (* i channels) (drawable i)))))
127+ (write-png pixels width height channels)))
125128
126129 ; Run a program repeatedly and draw the results.
127130 (define (cammy-draw program ty)
--- a/todo.txt
+++ b/todo.txt
@@ -5,7 +5,6 @@
55 * list/append : [X] × [X] → [X]
66 * rat
77 * refactoring from the bikeshed: ignore -> !
8-* fun/const? Would be: (comp ignore @0)
98 * Typechecker needs to handle holes
109 * Typechecker should handle polymorphism better
1110 * Typechecker errors are inscrutable