#lang racket/base
; Functions to divide a flag into sectors

(require
  "../../graphics/vectorial.rkt"
  "../../base-generation/random.rkt"
  "../../base-generation/distribution.rkt"
  "charge.rkt"
  "palette.rkt")

(provide
  field-division)

; Each division takes 3 parameters: a width, a height and a palette
; Each division can have a variation of overlays that place charges on the flag

; Common overlay: no overlay
(define (division:overlay:none . args)
  (group))

; Common overlay: single charge over the flag
; The 1st color of the palette is used
(define (division:overlay:charge width height palette)
  (large-charge
    width
    height
    (palette-secondary palette 0)
    (palette-main palette 0)))

; Common overlay: fess on chief (1/3 of flag)
; The 4th color of the palette is used
(define (division:overlay:fess-chief width height palette)
  (group
    (rectangle
      #:width width
      #:height (/ height 3)
      #:attributes (at-fill-color (palette-main palette 3)))
    (large-charge
      width
      (/ height 3)
      (palette-secondary palette 3)
      (palette-main palette 3))))

; Common overlay: fess on base
; The 4th color of the palette is used
(define (division:overlay:fess-base width height palette)
  (group
    #:attributes (at-translate (point 0 (* 2/3 height)))
    (division:overlay:fess-chief width height palette)))

; Common overlay: pale on "chief" (left side)
; The 4th color of the palette is used
(define (division:overlay:pale-chief width height palette)
  (group
    (rectangle
      #:width (/ width 3)
      #:height height
      #:attributes (at-fill-color (palette-main palette 3)))
    (large-charge
      (/ width 3)
      height
      (palette-secondary palette 3)
      (palette-main palette 3))))

; Common overlay: pale on "base" (right side)
; The 4th color of the palette is used
(define (division:overlay:pale-base width height palette)
  (group
    #:attributes (at-translate (point (* 2/3 width) 0))
    (division:overlay:pale-chief width height palette)))

; Common overlay: pairle (triangle) on left
; The 4th color of the palette is used. Only a small charge can be put here.
(define (division:overlay:pairle-left width height palette)
  (define l (* width (random:from-vector (vector 1 1/2 1/3))))
  (define has-charge? (random:boolean))
  (group
    (polygon
      #:attributes (at-fill-color (palette-main palette 3))
      (point 0 0)
      (point 0 height)
      (point l (/ height 2)))
    (cond
      ( has-charge?
        (define e 1/10)
        (define r (/ (* l height (- 1 e)) (+ l height)))
        (group
          #:attributes (at-translate (point (* e l) (/ (- height r) 2)))
          (small-charge
            r r
            (palette-secondary palette 3)
            (palette-main palette 3))))
      ( #t
        (group)))))

; Common overlay: pairle (triangle) on right
; The 4th color of the palette is used. Only a small charge can be put here.
(define (division:overlay:pairle-right width height palette)
  (define l (* width (random:from-vector (vector 1 1/2 1/3))))
  (define has-charge? (random:boolean))
  (group
    (polygon
      #:attributes (at-fill-color (palette-main palette 3))
      (point width 0)
      (point width height)
      (point (- width l) (/ height 2)))
    (cond
      ( has-charge?
        (define e 1/10)
        (define r (/ (* l height (- 1 e)) (+ l height)))
        (group
          #:attributes (at-translate (point (- width r (* e l)) (/ (- height r) 2)))
          (small-charge
            r r
            (palette-secondary palette 3)
            (palette-main palette 3))))
      ( #t
        (group)))))

; Common overlay: pairle (triangle) on top
; The 4th color of the palette is used. Only a small charge can be put here.
(define (division:overlay:pairle-top width height palette)
  (define l (* height (random:from-vector (vector 1 1/2 1/3))))
  (define has-charge? (random:boolean))
  (group
    (polygon
      #:attributes (at-fill-color (palette-main palette 3))
      (point 0 0)
      (point width 0)
      (point (/ width 2) l))
    (cond
      ( has-charge?
        (define e 1/10)
        (define r (/ (* l width (- 1 e)) (+ l width)))
        (group
          #:attributes (at-translate (point (/ (- width r) 2) (* e l)))
          (small-charge
            r r
            (palette-secondary palette 3)
            (palette-main palette 3))))
      ( #t
        (group)))))

; Common overlay: pairle (triangle) on bottom
; The 4th color of the palette is used. Only a small charge can be put here.
(define (division:overlay:pairle-bottom width height palette)
  (define l (* height (random:from-vector (vector 1 1/2 1/3))))
  (define has-charge? (random:boolean))
  (group
    (polygon
      #:attributes (at-fill-color (palette-main palette 3))
      (point 0 height)
      (point width height)
      (point (/ width 2) (- height l)))
    (cond
      ( has-charge?
        (define e 1/10)
        (define r (/ (* l width (- 1 e)) (+ l width)))
        (group
          #:attributes (at-translate (point (/ (- width r) 2) (- height r (* e l))))
          (small-charge
            r r
            (palette-secondary palette 3)
            (palette-main palette 3))))
      ( #t
        (group)))))

; Plain division: the field is of a single color
; Distribution of overlays
(define division:plain:overlay-distribution
  (distribution
    (cons division:overlay:none 1)
    (cons division:overlay:charge 15)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    ))
;
(define (division:plain width height palette)
  (define overlay (distribution-generate division:plain:overlay-distribution))
  (group
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 0)))
    (overlay width height palette)))

; Per fess - Bicolor horizontal

; Chief overlay
; The 1st color of the palette is used
(define (division:fess:chief width height palette)
  (large-charge
    width (/ height 2)
    (palette-secondary palette 0)
    (palette-main palette 0)))

; Base overlay
; The 2nd color of the palette is used
(define (division:fess:base width height palette)
  (group
    #:attributes (at-translate (point 0 (/ height 2)))
    (large-charge
      width (/ height 2)
      (palette-secondary palette 1)
      (palette-main palette 1))))

; Base + chief overlay
(define (division:fess:chief+base width height palette)
  (group
    (division:fess:chief width height palette)
    (division:fess:base width height palette)))

; Per fess division
; Distribution of overlays - case 1: base and chief share the same kind of main lightness: a charge on the whole flag is possible
(define division:fess:overlay-distribution:same-main-light
  (distribution
    (cons division:overlay:none 3)
    (cons division:overlay:charge 3)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:fess:chief 1)
    (cons division:fess:base 1)
    (cons division:fess:chief+base 1)))
; Distribution of overlays - case 2: base and chief don't share the same kind of main lightness
(define division:fess:overlay-distribution:different-main-light
  (distribution
    (cons division:overlay:none 3)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:fess:chief 1)
    (cons division:fess:base 1)
    (cons division:fess:chief+base 1)))
;
(define (division:fess width height palette)
  (define same-main-color? (eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1)))
  (define overlay (distribution-generate
                    (if same-main-color?
                        division:fess:overlay-distribution:same-main-light
                        division:fess:overlay-distribution:different-main-light)))
  (group
    ; base
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 1)))
    ; chief
    (rectangle
      #:width width
      #:height (/ height 2)
      #:attributes (at-fill-color (palette-main palette 0)))
    ; Overlay
    (overlay width height palette)))

; Per pale - Bicolor vertical

; "Chief" overlay (left side)
; The 1st color of the palette is used
(define (division:pale:chief width height palette)
  (large-charge
    (/ width 2) height
    (palette-secondary palette 0)
    (palette-main palette 0)))

; "Base" overlay (right side)
; The 2nd color of the palette is used
(define (division:pale:base width height palette)
  (group
    #:attributes (at-translate (point (/ width 2) 0))
    (large-charge
      (/ width 2) 0
      (palette-secondary palette 1)
      (palette-main palette 1))))

; Base + chief overlay
(define (division:pale:chief+base width height palette)
  (group
    (division:pale:chief width height palette)
    (division:pale:base width height palette)))

; Per pale division
; Distribution of overlays - case 1: base and chief share the same kind of main lightness: a charge on the whole flag is possible
(define division:pale:overlay-distribution:same-main-light
  (distribution
    (cons division:overlay:none 3)
    (cons division:overlay:charge 3)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:pale:chief 1)
    (cons division:pale:base 1)
    (cons division:pale:chief+base 1)))
; Distribution of overlays - case 2: base and chief don't share the same kind of main lightness
(define division:pale:overlay-distribution:different-main-light
  (distribution
    (cons division:overlay:none 3)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:pale:chief 1)
    (cons division:pale:base 1)
    (cons division:pale:chief+base 1)))
;
(define (division:pale width height palette)
  (define same-main-color? (eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1)))
  (define overlay (distribution-generate
                    (if same-main-color?
                        division:pale:overlay-distribution:same-main-light
                        division:pale:overlay-distribution:different-main-light)))
  (group
    ; "base" (right side)
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 1)))
    ; "chief" (left side)
    (rectangle
      #:width (/ width 2)
      #:height height
      #:attributes (at-fill-color (palette-main palette 0)))
    ; Overlay
    (overlay width height palette)))


; Tierced per fess - tricolor horizontal

; Chief overlay
; The 1st color of the palette is used
(define (division:tierced-fess:chief width height palette)
  (large-charge
    width (/ height 3)
    (palette-secondary palette 0)
    (palette-main palette 0)))

; Middle overlay
; The 2nd color of the palette is used
(define (division:tierced-fess:middle width height palette)
  (group
    #:attributes (at-translate (point 0 (/ height 3)))
    (large-charge
      width (/ height 3)
      (palette-secondary palette 1)
      (palette-main palette 1))))

; Base overlay
; The 3rd color of the palette is used
(define (division:tierced-fess:base width height palette)
  (group
    #:attributes (at-translate (point 0 (* height 2/3)))
    (large-charge
      width (/ height 3)
      (palette-secondary palette 2)
      (palette-main palette 2))))

; Chief + Middle + Base overlay
(define (division:tierced-fess:chief-middle-base width height palette)
  (group
    (division:tierced-fess:chief width height palette)
    (division:tierced-fess:middle width height palette)
    (division:tierced-fess:base width height palette)))

; Chief + Middle overlay
(define (division:tierced-fess:chief-middle width height palette)
  (group
    (division:tierced-fess:chief width height palette)
    (division:tierced-fess:middle width height palette)))

; Chief + Base overlay
(define (division:tierced-fess:chief-base width height palette)
  (group
    (division:tierced-fess:chief width height palette)
    (division:tierced-fess:base width height palette)))

; Middle + Base overlay
(define (division:tierced-fess:middle-base width height palette)
  (group
    (division:tierced-fess:middle width height palette)
    (division:tierced-fess:base width height palette)))

; Single charge on chief + middle
; Use the 2nd color of the palette
(define (division:tierced-fess:single-chief-middle width height palette)
  (large-charge
    width (* height 2/3)
    (palette-secondary palette 1)
    (palette-main palette 1)))

; Single charge on middle + base
; Use the 2nd color of the palette
(define (division:tierced-fess:single-middle-base width height palette)
  (group
    #:attributes (at-translate (point 0 (/ height 3)))
    (large-charge
      width (* height 2/3)
      (palette-secondary palette 1)
      (palette-main palette 1))))

; Tierced per fess division
; Distributions: 4 cases
; 1st case: All the areas have the same main lightness
(define division:tierced-fess:overlay-distribution:all-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:charge 6)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:tierced-fess:chief 3)
    (cons division:tierced-fess:middle 6)
    (cons division:tierced-fess:base 3)
    (cons division:tierced-fess:chief-middle-base 1)
    (cons division:tierced-fess:chief-middle 1)
    (cons division:tierced-fess:chief-base 1)
    (cons division:tierced-fess:middle-base 1)
    (cons division:tierced-fess:single-chief-middle 3)
    (cons division:tierced-fess:single-middle-base 3)
    ))
; 2nd case: Chief and middle have the same main lightness
(define division:tierced-fess:overlay-distribution:chief-middle-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:tierced-fess:chief 3)
    (cons division:tierced-fess:middle 6)
    (cons division:tierced-fess:base 3)
    (cons division:tierced-fess:chief-middle-base 1)
    (cons division:tierced-fess:chief-middle 1)
    (cons division:tierced-fess:chief-base 1)
    (cons division:tierced-fess:middle-base 1)
    (cons division:tierced-fess:single-chief-middle 3)
    ))
; 3rd case: Middle and base have the same main lightness
(define division:tierced-fess:overlay-distribution:middle-base-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:tierced-fess:chief 3)
    (cons division:tierced-fess:middle 6)
    (cons division:tierced-fess:base 3)
    (cons division:tierced-fess:chief-middle-base 1)
    (cons division:tierced-fess:chief-middle 1)
    (cons division:tierced-fess:chief-base 1)
    (cons division:tierced-fess:middle-base 1)
    (cons division:tierced-fess:single-middle-base 3)
    ))
; 4th case: the other cases
(define division:tierced-fess:overlay-distribution:none-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:pale-chief 1)
    (cons division:overlay:pale-base 1)
    (cons division:overlay:pairle-left 1)
    (cons division:overlay:pairle-right 1)
    (cons division:tierced-fess:chief 3)
    (cons division:tierced-fess:middle 6)
    (cons division:tierced-fess:base 3)
    (cons division:tierced-fess:chief-middle-base 1)
    (cons division:tierced-fess:chief-middle 1)
    (cons division:tierced-fess:chief-base 1)
    (cons division:tierced-fess:middle-base 1)
    ))
;
(define (division:tierced-fess width height palette)
  (define overlay
    (distribution-generate
      (cond
        ((and (eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1))
              (eq? (palette-main-dark? palette 1) (palette-main-dark? palette 2)))
        division:tierced-fess:overlay-distribution:all-main-light)
        ((eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1))
        division:tierced-fess:overlay-distribution:chief-middle-main-light)
        ((eq? (palette-main-dark? palette 1) (palette-main-dark? palette 2))
        division:tierced-fess:overlay-distribution:middle-base-main-light)
        (#t
        division:tierced-fess:overlay-distribution:none-main-light))))
  (group
    ; base
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 2)))
    ; middle
    (rectangle
      #:width width
      #:height (* height 2/3)
      #:attributes (at-fill-color (palette-main palette 1)))
    ; chief
    (rectangle
      #:width width
      #:height (/ height 3)
      #:attributes (at-fill-color (palette-main palette 0)))
    ; Overlay
    (overlay width height palette)))


; Tierced per pale - tricolor vertical

; "Chief" overlay (left side)
; The 1st color of the palette is used
(define (division:tierced-pale:chief width height palette)
  (large-charge
    (/ width 3) height
    (palette-secondary palette 0)
    (palette-main palette 0)))

; Middle overlay
; The 2nd color of the palette is used
(define (division:tierced-pale:middle width height palette)
  (group
    #:attributes (at-translate (point (/ width 3) 0))
    (large-charge
      (/ width 3) height
      (palette-secondary palette 1)
      (palette-main palette 1))))

; "Base" overlay (right side)
; The 3rd color of the palette is used
(define (division:tierced-pale:base width height palette)
  (group
    #:attributes (at-translate (point (* width 2/3) 0))
    (large-charge
      (/ width 3) height
      (palette-secondary palette 2)
      (palette-main palette 2))))

; Chief + Middle + Base overlay
(define (division:tierced-pale:chief-middle-base width height palette)
  (group
    (division:tierced-pale:chief width height palette)
    (division:tierced-pale:middle width height palette)
    (division:tierced-pale:base width height palette)))

; Chief + Middle overlay
(define (division:tierced-pale:chief-middle width height palette)
  (group
    (division:tierced-pale:chief width height palette)
    (division:tierced-pale:middle width height palette)))

; Chief + Base overlay
(define (division:tierced-pale:chief-base width height palette)
  (group
    (division:tierced-pale:chief width height palette)
    (division:tierced-pale:base width height palette)))

; Middle + Base overlay
(define (division:tierced-pale:middle-base width height palette)
  (group
    (division:tierced-pale:middle width height palette)
    (division:tierced-pale:base width height palette)))

; Single charge on chief + middle
; Use the 2nd color of the palette
(define (division:tierced-pale:single-chief-middle width height palette)
  (large-charge
    (* width 2/3) height
    (palette-secondary palette 1)
    (palette-main palette 1)))

; Single charge on middle + base
; Use the 2nd color of the palette
(define (division:tierced-pale:single-middle-base width height palette)
  (group
    #:attributes (at-translate (point (/ width 3) 0))
    (large-charge
      (* width 2/3) height
      (palette-secondary palette 1)
      (palette-main palette 1))))

; Tierced per pale division
; Overlay distributions: 4 cases
; 1st case: All the areas have the same main lightness
(define division:tierced-pale:overlay-distribution:all-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:charge 6)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:tierced-pale:chief 3)
    (cons division:tierced-pale:middle 6)
    (cons division:tierced-pale:base 3)
    (cons division:tierced-pale:chief-middle-base 1)
    (cons division:tierced-pale:chief-middle 1)
    (cons division:tierced-pale:chief-base 1)
    (cons division:tierced-pale:middle-base 1)
    (cons division:tierced-pale:single-chief-middle 3)
    (cons division:tierced-pale:single-middle-base 3)
    ))
; 2nd case: Chief and middle have the same main lightness
(define division:tierced-pale:overlay-distribution:chief-middle-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:tierced-pale:chief 3)
    (cons division:tierced-pale:middle 6)
    (cons division:tierced-pale:base 3)
    (cons division:tierced-pale:chief-middle-base 1)
    (cons division:tierced-pale:chief-middle 1)
    (cons division:tierced-pale:chief-base 1)
    (cons division:tierced-pale:middle-base 1)
    (cons division:tierced-pale:single-chief-middle 3)
    ))
; 3rd case: Middle and base have the same main lightness
(define division:tierced-pale:overlay-distribution:middle-base-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:tierced-pale:chief 3)
    (cons division:tierced-pale:middle 6)
    (cons division:tierced-pale:base 3)
    (cons division:tierced-pale:chief-middle-base 1)
    (cons division:tierced-pale:chief-middle 1)
    (cons division:tierced-pale:chief-base 1)
    (cons division:tierced-pale:middle-base 1)
    (cons division:tierced-pale:single-middle-base 3)
    ))
; 4th case: the other cases
(define division:tierced-pale:overlay-distribution:none-main-light
  (distribution
    (cons division:overlay:none 6)
    (cons division:overlay:fess-chief 1)
    (cons division:overlay:fess-base 1)
    (cons division:overlay:pairle-top 1)
    (cons division:overlay:pairle-bottom 1)
    (cons division:tierced-pale:chief 3)
    (cons division:tierced-pale:middle 6)
    (cons division:tierced-pale:base 3)
    (cons division:tierced-pale:chief-middle-base 1)
    (cons division:tierced-pale:chief-middle 1)
    (cons division:tierced-pale:chief-base 1)
    (cons division:tierced-pale:middle-base 1)
    ))
;
(define (division:tierced-pale width height palette)
  (define overlay
    (distribution-generate
      (cond
        ((and (eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1))
              (eq? (palette-main-dark? palette 1) (palette-main-dark? palette 2)))
        division:tierced-pale:overlay-distribution:all-main-light)
        ((eq? (palette-main-dark? palette 0) (palette-main-dark? palette 1))
        division:tierced-pale:overlay-distribution:chief-middle-main-light)
        ((eq? (palette-main-dark? palette 1) (palette-main-dark? palette 2))
        division:tierced-pale:overlay-distribution:middle-base-main-light)
        (#t
        division:tierced-pale:overlay-distribution:none-main-light))))
  (group
    ; base
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 2)))
    ; middle
    (rectangle
      #:width (* width 2/3)
      #:height height
      #:attributes (at-fill-color (palette-main palette 1)))
    ; chief
    (rectangle
      #:width (/ width 3)
      #:height height
      #:attributes (at-fill-color (palette-main palette 0)))
    ; Overlay
    (overlay width height palette)))

; Horizontal stripes
; This one does not have specific overlays
; Overlay distributions
(define division:horizontal-stripes:overlay-distribution
  (distribution
    (cons division:overlay:none 1)
    (cons division:overlay:pale-chief 3)
    (cons division:overlay:pale-base 3)
    (cons division:overlay:pairle-left 3)
    (cons division:overlay:pairle-right 3)
    ))
;
(define (division:horizontal-stripes width height palette)
  (define overlay (distribution-generate division:horizontal-stripes:overlay-distribution))
  (define nb-charge-stripes (+ 1 (random 6))) ; Number of stripes using the charge colors => between 3 stripes and 13 stripes
  (define stripe-height (/ height (+ 1 (* 2 nb-charge-stripes))))
  (group
    ; Stripes with field color
    (rectangle
      #:width width
      #:height height
      #:attributes (at-fill-color (palette-main palette 0)))
    ; Stripes with charge color
    (apply group
      (build-list
        nb-charge-stripes
        (lambda (i)
          (rectangle
            #:width width
            #:height stripe-height
            #:top-left (point 0 (* stripe-height (+ 1 (* 2 i))))
            #:attributes (at-fill-color (palette-secondary palette 0))))))
    ; Overlay
    (overlay width height palette)))

; Field division
; Distribution of divisions
(define field-division:distribution
  (distribution
    (cons division:plain 9)
    (cons division:fess 3)
    (cons division:pale 3)
    (cons division:tierced-fess 2)
    (cons division:tierced-pale 2)
    (cons division:horizontal-stripes 1)
    ))
;
(define (field-division width height palette)
  ((distribution-generate field-division:distribution)
   width height palette))
