Created
August 17, 2020 07:30
-
-
Save dibitol/7669638818ca72b4924e0e3bd1310d65 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
(ns flaggen.core | |
(:gen-class)) | |
(def header_seq | |
"66 77 0 0 0 0 0 0 0 0 54 0 0 0 40 0 0 0 %s 0 0 0 %s 0 0 0 1 0 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0") | |
(defn -main | |
[& args] | |
(System/setProperty "file.encoding" "UTF8") | |
(println "FlagGen 1.0.0") | |
(println "X ekseninin cozunurlugu px cinsinden (4'un kati olmak zorunda) (max 100)") | |
(def x_cord (read-line)) | |
(println "Y ekseninin cozunurlugu px cinsinden") | |
(def y_cord (read-line)) | |
(println "Kac Farkli renk kullanilacak (Y eksenini tam bolmek zorunda) (max 100)") | |
(def seperator (read-line)) | |
;;For truncating if file is already created | |
(spit "ex.bmp" "") | |
;;Formating the file we desire | |
(doseq [i (clojure.string/split (format header_seq x_cord y_cord) #" ")] | |
(spit "ex.bmp" (char (Integer/parseInt i)) :append true :encoding "windows-1254") | |
) | |
(def red (rand-int 255)) | |
(def green (rand-int 255)) | |
(def blue (rand-int 255)) | |
(def sep_y (/ (Integer/parseInt y_cord) (Integer/parseInt seperator))) | |
(dotimes [n (Integer/parseInt y_cord)] | |
(when (= (rem n sep_y) 0) | |
(do | |
(def red (rand-int 255)) | |
(def green (rand-int 255)) | |
(def blue (rand-int 255)) | |
) | |
) | |
(dotimes [_ (Integer/parseInt x_cord)] | |
(spit "ex.bmp" (char red) :append true :encoding "windows-1254") | |
(spit "ex.bmp" (char green) :append true :encoding "windows-1254") | |
(spit "ex.bmp" (char blue) :append true :encoding "windows-1254") | |
) | |
) | |
) | |
; A A A A | |
; A A A A | |
; B B B B | |
; B B B B | |
;;;;;;;;;;;;;;;;; | |
;;0x42 0x4d;; BM | |
;;0x00 0x00 0x00 0x00;; File Size | |
;;0x00 0x00;; Additional | |
;;0x00 0x00;; Additional | |
;;0x36 0x00 0x00 0x00;; Pixel data start | |
;;;;;;;;;;;;;;;;;;; | |
;;0x28 0x00 0x00 0x00;; 40 byte header size | |
;;0x00 0x00 0x00 0x00;; Image width | |
;;0x00 0x00 0x00 0x00; Image heigth | |
;;0x01 0x00;; plane | |
;;0x18 0x00;; bits per pixel | |
;;0x00 0x00 0x00 0x00;; Compression | |
;;0x00 0x00 0x00 0x00;; no compress | |
;;0x00 0x00 0x00 0x00;; x res | |
;;0x00 0x00 0x00 0x00;; y res | |
;;0x00 0x00 0x00 0x00;; total color | |
;;0x00 0x00 0x00 0x00;; important color | |
;;;;;;;;;;;;;;;;;;;;;;; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment