#lang racket/base

; Road map pages

(require
  "templates.rkt"
  "../webcontainer/weblets.rkt"
  "../generators/road-map.rkt"
  "../graphics/color.rkt")

(provide
  pages:road-map
  pages:road-map-raw-image)

; For rendering islands
(define *tile-size* 16)
(define *road-map-tileset* (make-road-map-tileset "static/images/road-map-tileset.png" *tile-size*))

; Raw page
(define pages:road-map-raw-image
  (raw-data-weblet
    #:content-type #"image/png"
    #:body
      (lambda (param)
        (define output-port (open-output-bytes))
        (road-map-render
          (road-map-generate 40) ; images made of 40x40 tiles
          *tile-size*
          *road-map-tileset*
          output-port)
        (get-output-bytes output-port))))

; Road Map page
(define pages:road-map
  (pages:template
    #:title "Island Generator - Road Map"
    #:author "feuforeve.fr"
    #:content
      '(article
        (a ((href "/RoadMap")) "New Map") (br)
        (img ((alt "Generated Road Map") (src "/RoadMap/Raw")))
        (p (h3 "About this generator")
           "This generator makes islands rendered with a look inspired by old Michelin maps. "
          )
        )))
