#lang racket
(require racket/draw games/cards)
(provide make-oxygen-deck)
(define (load-plate)
(read-bitmap
"/Users/mt/Desktop/Open Flowers/card-faces/White-Oxygen-Playing-Card-Faces.png"
))
(define first-row-offset 10)
(define first-column-offset 6)
(define second-row-offset 224)
(define second-column-offset 160)
(define face-width 149)
(define face-height 208)
(define column-offset (- second-column-offset first-column-offset))
(define row-offset (- second-row-offset first-row-offset))
(define (column-n-x n)
(cond
([= n 13] 1867)
([= n 12] 1712)
([= n 11] 1557)
([= n 10] 1402)
([= n 09] 1247)
([= n 08] 1092)
([= n 07] 937)
([= n 06] 782)
([= n 05] 627)
([= n 04] 471)
([= n 03] 316)
(else
(+ first-column-offset
(* (sub1 n) column-offset)))))
(define (row-n-y n)
(cond
([= n 3] 440)
([= n 4] 653)
(else
(+ first-row-offset
(* (sub1 n) row-offset)) ) ))
(define (aspect-ratio width height)
(exact->inexact (/ width height)))
(define card-width 72)
(define card-height 96)
(define (extract-face plate column row)
(let* ((bitmap (make-bitmap card-width card-height #t))
(drawable (new bitmap-dc% [bitmap bitmap])))
(send drawable draw-bitmap-section-smooth
plate
0 0 card-width card-height
(column-n-x column) (row-n-y row) face-width face-height)
bitmap))
(define (make-my-cards plate)
(let ((background (extract-face plate 1 5)))
(map {lambda (id)
(map {lambda (row suit-id)
(make-card (extract-face plate id row)
background
suit-id
id)}
'(1 2 3 4) '(3 4 2 1) )}
'(1 2 3 4 5 6 7 8 9 10 11 12 13))))
(define (make-oxygen-deck)
(apply append (make-my-cards (load-plate))))