about summary refs log tree commit diff stats
path: root/favicon.ico
blob: ad54706e2e5150596f61f20f291f0e1765608a07 (plain)
ofshex dumpascii
0000 00 00 01 00 01 00 10 10 02 00 01 00 01 00 b0 00 00 00 16 00 00 00 28 00 00 00 10 00 00 00 20 00 ......................(.........
0020 00 00 01 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
0040 00 00 ff ff ff 00 ff ff 00 00 ff ff 00 00 ff ff 00 00 ff ff 00 00 ff ff 00 00 ff ff 00 00 c0 2b ...............................+
0060 00 00 da ab 00 00 c2 83 00 00 fb ff 00 00 fb ff 00 00 ff ff 00 00 ff ff 00 00 ff ff 00 00 ff ff ................................
0080 00 00 ff ff 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................................
00c0 00 00 00 00 00 00 ......
v class='alt'>
78bd804 ^
7a222e4 ^
5f74b7b ^

78bd804 ^

bd05807 ^
7cced76 ^
7a222e4 ^
7cced76 ^
a76b6b2 ^
bd05807 ^
7cced76 ^
5f74b7b ^
7cced76 ^
a76b6b2 ^










4c22154 ^
5f74b7b ^






cdffe0c ^
5f74b7b ^

cdffe0c ^
5f74b7b ^
4c22154 ^
5f74b7b ^

454f107 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 












                                                                  

                    
              
 

                                    

          
                                                
 
 
                        
                                                 
                                                                                                                                                
                             
                                                                                                        
 










                                                                                                      
                     






                                                                                                                                        
 

                                   
 
                                               
 

                                                         
                                                                                     
#lang racket

;; let's try to make a pokedex in racket!

;; first step will be to write a function to query the pokeAPI
;; like so, https://pokeapi.co/api/v2/pokemon/ditto

;; once there is a function in place that returns data I will
;; have a choice to make -- do I want to always query the API,
;; do I want to cache results, or do I want to create an offline
;; repository of poke-data to search through and sometimes update?


;; basic GET request
(require net/url)
(require json)

; 🤔
(require slideshow/pict racket/draw)

;; API URL
(define *POKE-API* "https://pokeapi.co/api/v2/")


(define (get-pokemon id)
    "queries the api, returns a butt ton of info"
	(call/input-url (string->url (~a *POKE-API* "pokemon/" id)) ; ~a, like string-append but appends *either* strings or numbers to a string
                get-pure-port
                (compose string->jsexpr port->string))) ; QUESTION: could I use read-json here, instead?

(define (dex-entry id)
    "selects the info we need from the api, builds a hash table of the data that will build the entry"
    (let ([poke-data (get-pokemon id)])
        (define entry-data (make-hash))
        (hash-set! entry-data "name" (hash-ref poke-data 'name))
        (hash-set! entry-data "id" (hash-ref poke-data 'id))
        (hash-set! entry-data "sprite" (hash-ref (hash-ref poke-data 'sprites) 'front_default))
        (hash-set! entry-data "stats" (hash-ref poke-data 'stats))
        (hash-set! entry-data "types" (hash-ref poke-data 'types))
        entry-data))

(define (inspector h)
  "display the contents of a hash table for human eyeballs and let the hash table fall back out"
  (hash-map h
            (lambda (k v)
              (if (list? v) (map ; consider making this if a cond and testing for lists/hash tables to recursively dive into nested data
                             (lambda (x) (inspector x)) v)
                  (display (~a "  key: " k "\nvalue: " v "\n=====\n")))))
  h)

(inspector (dex-entry 11))
(inspector (dex-entry "bulbasaur"))

(define img (hash-ref (dex-entry 11) "sprite"))

(define display-image (bitmap (make-object bitmap% img)))

(frame (scale display-image 0.3)) ; this doesn't actually seem to work with URLs/PNGs