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))))))))

Your annotation:

Enter a new annotation:

Your nick:
The title of your paste:
Your paste (mandatory) :
Which one-argument R5RS procedure returns 3 when given `'(1 2 3 4)' as input?
Visually impaired? Let me spell it for you (wav file) download WAV