Image noise: Difference between revisions

Content added Content deleted
Line 1,768: Line 1,768:
main()</lang>
main()</lang>
About 28 FPS max, Python 2.6.6.
About 28 FPS max, Python 2.6.6.

=={{header|Racket}}==
<lang racket>
#lang racket
(require 2htdp/image 2htdp/universe)

(define black (color 0 0 0 255))
(define white (color 255 255 255 255))

(define-struct world (last fps))

(define (noise w h)
(color-list->bitmap
(for*/list ([x (in-range w)] [y (in-range h)])
(if (zero? (random 2))
black
white))
w h ))

(define (draw w)
(underlay/xy
(noise 320 240) 0 0
(text (number->string (world-fps w)) 64 "Red")))

(define (handle-tick w)
(define cm (current-inexact-milliseconds))
(make-world cm (exact-floor (/ 1000.0 (- cm (world-last w))))))

(big-bang (make-world 1 0)
[on-draw draw]
[on-tick handle-tick (/ 1. 120)])
</lang>


=={{header|Ruby}}==
=={{header|Ruby}}==
Line 1,796: Line 1,828:
Glut.glutCreateWindow "noise"
Glut.glutCreateWindow "noise"
Glut.glutMainLoop</lang>
Glut.glutMainLoop</lang>



=={{header|Run BASIC}}==
=={{header|Run BASIC}}==