Last active
March 30, 2023 13:59
-
-
Save voronoipotato/9b57bb0185654f25c52c7ef9ba2ddd44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open System.IO | |
#I @"/lib/mono/gtk-sharp-3.0" | |
#r "atk-sharp.dll" | |
#r "gio-sharp.dll" | |
#r "glib-sharp.dll" | |
#r "gtk-sharp.dll" | |
#r "gdk-sharp.dll" | |
module Tarot = | |
let mutable handSize = 5 | |
let shuffle a = | |
let swap (a: _[]) x y = | |
let tmp = a.[x] | |
a.[x] <- a.[y] | |
a.[y] <- tmp | |
let rand = new System.Random() | |
Array.iteri (fun i _ -> swap a i (rand.Next(i, Array.length a))) a | |
let filenames = System.IO.Directory.GetFiles ("/home/alan/Downloads/Hexen2.0/fullLarge","*.jpg") | |
Tarot.shuffle filenames | |
Gtk.Application.Init() | |
let w = new Gtk.Window "Hexen 2.0" | |
let gridView = new Gtk.Grid () | |
w.Add gridView | |
let hand = | |
filenames.[0..Tarot.handSize-1] | |
|> Array.map(fun name -> File.Open(name, FileMode.Open,FileAccess.Read)) | |
hand | |
|> Array.map (fun i -> new Gtk.Image (i) ) | |
|> Array.iter (gridView.Add) | |
hand |> Array.iter(fun f -> f.Close()) | |
w.ShowAll () | |
w.DeleteEvent.Subscribe(fun _ -> Gtk.Application.Quit()) | |
Gtk.Application.Run () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment