Skip to content

Instantly share code, notes, and snippets.

@RenaissanceBug
RenaissanceBug / two-song-player.rkt
Created April 6, 2016 23:26
Alternating between playing two WAV files using rsound
#lang racket
#|
Little audio player to demo switching between recordings with
the rsound library.
Create two .wav files, define your constants MUSIC-DIR, SONG1, SONG2,
and run in DrRacket.
Controls: press 1 to start looping SONG1, 2 to start looping SONG2,
or Esc to kill the audio.
@RenaissanceBug
RenaissanceBug / triangle-colors.rkt
Created September 20, 2015 00:50
Choosing colors with Racket
#lang racket/base
(require 2htdp/image
lang/posn
racket/match)
;; Given: I've got three colors of paint, and the wall is painted light blue.
(define blue (make-color #x66 #xcc #xff))
(define purple (make-color #x66 #x33 #xff))
(define orange (make-color #xff #xcc #x33))
@RenaissanceBug
RenaissanceBug / circular-function-graphs
Created June 8, 2015 20:19
Circular graphs of functions in modular arithmetic
#lang typed/racket/base
#|
Drawing function graphs on a circle, in modular arithmetic.
jmj, 8 June 2015.
See also:
http://stephanainley.com/shapes2/#
http://blog.recursiveprocess.com/2015/04/28/linear-modulus-art/
|#
@RenaissanceBug
RenaissanceBug / solar-system.rkt
Created December 7, 2014 21:50
Beginner Racket solar-system model
(require 2htdp/image)
(require 2htdp/universe)
; Sun and background
(define SPACE (rectangle 900 900 "solid" "black"))
(define SUN (star 20 "solid" "gold"))
;Key
; (+ [center of ellipse] (* [determines width/height of ellipse]
; (cos (/ fn [adjusts the speed of rotation])))))
@RenaissanceBug
RenaissanceBug / bezier.rkt
Created December 7, 2014 21:42
Drawing a Bezier curve in Racket
#lang racket
;; Bezier curve drawing. jmj, 4/22/10.
;; Illustrates using posns to represent 2d locations, and drawing using 2htdp/image library.
;; Test cases removed.
(require 2htdp/image)
(define BG (rectangle 220 150 'solid 'white))
@RenaissanceBug
RenaissanceBug / differentiation.rkt
Created December 7, 2014 21:36
Functions & derivatives, symbolically
#lang racket
#|
Symbolic differentiation:
An example of higher-order functions in math. Includes:
* Basic function constructors:
- identity
- constant functions for several small numbers
- power-functions (x^n for given n)
* Functions of functions, or function combinators:
@RenaissanceBug
RenaissanceBug / modular-times-tables.rkt
Created December 7, 2014 21:26
Generating multiplication tables for modular arithmetic
#lang racket
#| Generator for times-table images for modular arithmetic.
jmj (jjohnson@kirby.org), 12 Nov 2013
Based on a discussion at the Monterey Bay Area Math Teachers' Circle.
|#
(require 2htdp/image)