Welcome to the CHICKEN Scheme pasting service
no title added by anonymous on Wed Dec 5 02:01:00 2018
(define (lerp a b t) (+ a (* t (- b a)))) (define (line-lerp-y->x a b y) (let-values (((ax ay) (apply values a)) ((bx by) (apply values b))) (let ((t (/ (- y ay) (- by ay)))) (exact (floor (lerp ax bx t)))))) (define (render-draw-trapezoid! renderer trap) (let*-values (((la ra lb rb) (apply values trap)) ((lay) (cadr la)) ((lby) (cadr lb)) ((next-y) (/ (- lby lay) (abs (- lby lay))))) (let loop ((y lay)) (let ((lx (line-lerp-y->x la lb y)) (rx (line-lerp-y->x ra rb y))) (sdl2:render-draw-line! renderer lx y rx y) (cond ((= y lby)) (else (loop (+ y next-y))))))))