vydd / sketch

A Common Lisp framework for the creation of electronic art, visual design, game prototyping, game making, computer graphics, exploration of human-computer interaction, and more.
MIT License
1.39k stars 67 forks source link

Cut image surface on load #94

Closed vydd closed 9 months ago

vydd commented 9 months ago

Adds 4 optional params (x y w h) when loading image resources, to put only a part of the image into the texture.

This is how to tile a part of an image:

(defsketch tile
    ((width 400) (height 400))
  (let ((res (load-resource "100x100.png" :x 0 :y 0 :w 50 :h 50)))
    (with-pen (make-pen :fill (crop res 0 0 100 100))
      (rect 0 0 400 400))))

Here, only the upper left 50x50 part of the image is loaded. As crop (unintuivitely?) tiles the image when width or height are larger than the ones of the image, the intended effect is achieved.