;;;;
;;;; canvas2.stk    -- GTKlos Canvas Demo
;;;;
;;;; Copyright © 2002-2021 Erick Gallesio - I3S-CNRS/ESSI <eg@unice.fr>
;;;;
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
;;;; the Free Software Foundation; either version 2 of the License, or
;;;; (at your option) any later version.
;;;;
;;;; This program is distributed in the hope that it will be useful,
;;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;;; GNU General Public License for more details.
;;;;
;;;; You should have received a copy of the GNU General Public License
;;;; along with this program; if not, write to the Free Software
;;;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
;;;; USA.
;;;;
;;;;           Author: Erick Gallesio [eg@unice.fr]
;;;;    Creation date: 17-Feb-2002 10:57 (eg)
;;;;

(include "demos-utils.stk")

(define canvas-msg "
Canvas Demo widget

This is another simple  demo of the GTklos Canvas Widget.
This one focueses on poly-lines
")

(define (make-polish-diamond c)
  (let ((vertices 10)
        (radius   60.0)
        (pi       (* 4 (atan 1)))
        (posx     100)
        (posy     100))

    (do ((i 0 (+ i 1)))
        ((>= i vertices))
      (let* ((a  (/ (* 2 pi i) vertices))
             (x1 (+ posx (* radius (cos a))))
             (y1 (+ posy (* radius (sin a)))))
        (do ((j (+ i 1) (+ j 1)))
            ((>= j vertices))
          (let* ((a  (/ (* 2 pi j) vertices))
                 (x2 (+ posx (* radius (cos a))))
                 (y2 (+ posy (* radius (sin a)))))
            (make <canvas-line> #:parent c #:stroke-color "blue"
                  #:line-width 1 #:points (list x1 y1 x2 y2))))))))


(define (main args)
  (let* ((win  (make <demo-window> #:title "Canvas Demo" #:x 100 #:y 100
                     #:file "canvas2" #:border-width 5
                     #:padding 20 #:message canvas-msg))
         (c    (make <canvas> #:parent win #:width 600 #:height 500)))

    (make <canvas-line> #:parent c #:stroke-color "green"
          #:points '(270 330 270 430 390 430 390
                     330 310 330 310 390 350 390
                     350 370 330 370 330 350 370
                     350 370 410 290 410 290 330))
    (make <canvas-line> #:parent c #:points '(20 200 400 200)
          #:stroke-color "red" #:line-width 5 #:end-arrow #t)
    (make-polish-diamond c)
    (gtk-main)))
