blob: 98e01e07a06b109174f7cbedb08c84058924141e (
plain) (
blame)
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
|
;;;; Copyright © 2022 siddharth ravikumar <s@ricketyspace.net>
;;;; SPDX-License-Identifier: ISC
#lang racket
(require racket/draw)
(require racket/snip)
;; Sets up settings for the drawing context.
(define (setup-dc dc)
(send dc set-smoothing 'aligned)
(send dc set-pen "black" 1 'transparent)
(send dc set-brush "black" 'solid))
;; Draws a moon.
(define (moon-drawing size)
(let* ((moon (new dc-path%))
(inner-arc-x (/ (* size -50) 500.0))
(inner-arc-y (* -1 inner-arc-x))
(inner-arc-size (/ (* size 320) 500.0))
(outer-arc-x (/ (* size 5) 500.0))
(outer-arc-y outer-arc-x)
(outer-arc-size (/ (* size 490) 500.0)))
(send moon arc inner-arc-x inner-arc-y inner-arc-size inner-arc-size 1.57 4.36 #f)
(send moon arc outer-arc-x outer-arc-y outer-arc-size outer-arc-size 3.54 2.20 #t)
moon))
;; Draws the peach logo in a bitmap and returns the bitmap.
(define (draw-logo size)
(let* ((target (make-bitmap size size))
(dc (new bitmap-dc% (bitmap target))))
(setup-dc dc)
(send dc set-brush "black" 'solid)
(send dc draw-path (moon-drawing size))
target))
;; Exports the logo into PNG.
(define (png-export logo)
(send logo save-file "peach.png" 'png))
;; Peach logo as a bitmap.
(define peach-logo (draw-logo 500))
;; Render logo in racket shell.
(make-object image-snip% peach-logo)
;; Export logo to a PNG file.
(png-export peach-logo)
|