0  ,]']±>Sï}WÿÍu§ðp8·d%qy)6o;]ÉA¦ösï÷ôôô”°ÂVl†3<W                                  ÎÌÌÌÌˆˆˆ¬ªªª¬ˆˆˆ¬ÌÌÌ¬ÌÀÌ¬ÌÀÌ¬ÌÀÌÌÌìîˆˆÌîªªÀîˆ¨ÀîÌ¬ÀÌÀ¬ÀÀÀ¬ÀÀÀ¬ÀÀÎÌÌÌÌˆˆˆ¬ªªª¬ˆˆˆ¬ÌÌÌ¬ÌÌÌ¬ÌÀÌ¬ÌÀÌÌÌìîˆˆÌîªªÀîˆ¨ÀîÌ¬ÀÌÌ¬ÀÀÀ¬ÀÀÀ¬ÀÀ                                                                                                                                                                                                                                                                                                                                                                                                ¬ÌÌÌ¬ªªª¬ª¬ª¬ªÊÌ¬ªªªŒˆˆˆÌ ÀÌÎÌÌÎÌ¬ ÌªªÀì¬ªÀîªªÀîªªÀîˆˆÌî ÀìîÌÌîî¬ÌÌÌ¬ªªª¬ª¬ª¬ªÊÌ¬ªªªŒˆˆˆÌ ÀÌÎÌÌÎÌ¬ ÌªªÀì¬ªÀîªªÀîªªÀîˆˆÌî ÀìîÌÌîî_:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Ò"                                                                                                                      ÒÝ                                                                                                                     ÝÝ-                                                                                                                   ÒÝÝÝ-                                                                                                                   ÒÝÝÝÝ                                                                                                                  ÝÝÝÝÝ-                                                                                                                ÒÝÝÝÝÝÝ-                                                                                                                ÒÝÝÝÝÝÝÝ"                                                                                                               ÝÝÝÝÝÝÝÝÝ                                                                                                              ÝÝÝÝÝÝÝÝÝ-                                                                                                            ÒÝÝÝÝÝÝÝÝÝÝ-                                                                                                            ÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                           ÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                         ÒÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                         ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"                                                                                                        ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                      ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                     ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                     ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                   ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                  ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                  ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ"                                                                                                ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                               ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                               ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                 ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                   ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                    ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                    "ÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                      ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                       ÒÝÝÝÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                        ÝÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                         "ÝÝÝÝÝÝÝÝÝÝÝÝÝ-                                                                                                          ÒÝÝÝÝÝÝÝÝÝÝÝÝ                                                                                                           ÒÝÝÝÝÝÝÝÝÝÝ-                                                                                                             ÝÝÝÝÝÝÝÝÝÝ-                                                                                                             "ÝÝÝÝÝÝÝÝÝ                                                                                                              ÒÝÝÝÝÝÝÝ-                                                                                                                ÒÝÝÝÝÝÝ-                                                                                                                 ÝÝÝÝÝÝ                                                                                                                 "ÝÝÝÝ-                                                                                                                   ÒÝÝÝ-                                                                                                                    ÒÝÝ                                                                                                                     Ý-                                                                                                                      "-                                                                                                                                                                                                                                       P                                                                                                                       •U                                                                                                                      •™                                                                                                                    P™™Y                                                                                                                   •™™™Y                                                                                                                   •™™™™U                                                                                                                 P™™™™™™                                                                                                                •™™™™™™Y                                                                                                               •™™™™™™™Y                                                                                                              P™™™™™™™™™U                                                                                                             •™™™™™™™™™™                                                                                                            •™™™™™™™™™™Y                                                                                                          P™™™™™™™™™™™™Y                                                                                                          •™™™™™™™™™™™™™U                                                                                                         •™™™™™™™™™™™™™™                                                                                                       P™™™™™™™™™™™™™™™Y                                                                                                      •™™™™™™™™™™™™™™™™Y                                                                                                      •™™™™™™™™™™™™™™™™™U                                                                                                    P™™™™™™™™™™™™™™™™™™™                                                                                                   •™™™™™™™™™™™™™™™™™™™Y                                                                                                  •™™™™™™™™™™™™™™™™™™™™Y                                                                                                 P™™™™™™™™™™™™™™™™™™™™™™U                                                                                                •™™™™™™™™™™™™™™™™™™™™™™™                                                                                               •™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               P™™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               •™™™™™™™™™™™™™™™™™™™™™™™                                                                                               •™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               P™™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               •™™™™™™™™™™™™™™™™™™™™™™™                                                                                               •™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               P™™™™™™™™™™™™™™™™™™™™™™™Y                                                                                               •™™™™™™™™™™™™™™™™™™™™™™™                                                                                               •™™™™™™™™™™™™™™™™™™™™™™™                                                                                              P™™™™™™™™™™™™™™™™™™™™™™™Y                                                                                                U™™™™™™™™™™™™™™™™™™™™™™                                                                                                 •™™™™™™™™™™™™™™™™™™™™™                                                                                                 P•™™™™™™™™™™™™™™™™™™™Y                                                                                                   P™™™™™™™™™™™™™™™™™™™                                                                                                    •™™™™™™™™™™™™™™™™™™                                                                                                    P•™™™™™™™™™™™™™™™™Y                                                                                                      P™™™™™™™™™™™™™™™™                                                                                                       U™™™™™™™™™™™™™™™                                                                                                        •™™™™™™™™™™™™™Y                                                                                                         P•™™™™™™™™™™™™                                                                                                          P™™™™™™™™™™™™                                                                                                           •™™™™™™™™™™Y                                                                                                            P•™™™™™™™™™                                                                                                             P™™™™™™™™™                                                                                                              U™™™™™™™Y                                                                                                                •™™™™™™Y                                                                                                                P•™™™™™                                                                                                                 P™™™™Y                                                                                                                   •™™™Y                                                                                                                   P•™™                                                                                                                    P™Y                                                                                                                      UY                                                                                                                       þ ;; title:   Flood filled rotating vector graphics
;; author:  parlortricks
;; desc:    demo2 shows 2 filled rectangles draw on screen rotating around their point and around another origin
;; website: http://tic80.com/dev?id=6589
;; script:  fennel
;; SPDX-License-Identifier: GPL-3.0-or-later
;; Copyright (c) 2021 parlortricks

(local screen-width 240)
(local screen-height 136)
(local sin math.sin)
(local cos math.cos)
(local atan2 math.atan2)
(var r 0)

(fn rotate-point [p o r]
 (let [(px py ox oy r) (values p.x p.y o.x o.y r)
  rx (+ (- (* (- px ox) (cos r)) (* (- py oy) (sin r))) ox)
  ry (+ (+ (* (- py oy) (cos r)) (* (- px ox) (sin r))) oy)
 ]
 {:x rx :y ry})) 

(fn draw-line [p1 p2 c]
 (line p1.x p1.y p2.x p2.y c))


(fn draw-rect [o w h s a c ?use_fill]
 (local p1 {:x (- o.x (// w 2)) :y (- o.y (// h 2))}) ;top left
 (local p2 {:x (+ o.x (// w 2)) :y (- o.y (// h 2))}) ;top right
 (local p3 {:x (- o.x (// w 2)) :y (+ o.y (// h 2))}) ;bottom left
 (local p4 {:x (+ o.x (// w 2)) :y (+ o.y (// h 2))}) ;bottom right

 (local r1 (rotate-point p1 o a))
 (local r2 (rotate-point p2 o a))
 (local r3 (rotate-point p3 o a))
 (local r4 (rotate-point p4 o a))  
 
 (draw-line r1 r2 c)
 (draw-line r2 r4 c)
 (draw-line r4 r3 c)
 (draw-line r3 r1 c))

(fn fill [x y to-c]
 (let [on-c (pix x y)]
   (when (not= on-c to-c)
    (fn flood [x y]
     (when (= (pix x y) on-c)
      (pix x y to-c)
      (when (> x 0)
       (flood (- x 1) y))
      (when (< x 239)
       (flood (+ x 1) y))
      (when (> y 0)
       (flood x (- y 1)))
      (when (< y 135)
       (flood x (+ y 1)))))
    (flood x y))))

(fn _G.TIC []


 (local [w h] [values 40 40])
 (local origin {:x (// screen-width 2) :y (// screen-height 2)})
 (local point (rotate-point {:x (- origin.x 20) :y (- origin.y 20)} origin (sin r)))
 (local point2 (rotate-point {:x (+ origin.x 20) :y (+ origin.y 20)} origin (sin r)))

 (cls) 
 (draw-rect  point 40 40 1 r 2)
 (fill point.x point.y 13)

 (draw-rect  point2 40 40 1 r 5)
 (fill point2.x point2.y 9)

 (set r (+ r 0.05)))

