Recent Posts
Bash | 43 sec ago
C# | 56 sec ago
None | 1 min ago
None | 1 min ago
None | 2 min ago
None | 2 min ago
Java | 3 min ago
C# | 3 min ago
None | 3 min ago
None | 3 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
Learn a little bit about the new Pastebin.com on our help page. hide message
By Anonymous on the 9th of Feb 2010 08:51:15 PM Download | Raw | Embed | Report
  1. (import opengl/gl)
  2. (import sdl/sdl)
  3. (import cairo/cairo)
  4.  
  5. (import graph)
  6.  
  7. (define (representation-init)
  8.   (SDL::initialize SDL::init-everything)
  9.   (SDL::set-window-caption "ensanche-core" "ensanche-core")
  10.   (display "--> Representation init\n"))
  11.  
  12. (define (representation-cleanup)
  13.   (SDL::exit))
  14.  
  15. (define (represent-loop graph)
  16.   (define (control-state)
  17.     (let*
  18.       ((maxx 500)
  19.        (maxy 500)
  20.        (cairo-surface (SDL::set-video-mode maxx maxy 0 (+ SDL::hwsurface
  21.                                                           SDL::hwpalette
  22.                                                           SDL::doublebuf)))
  23.        (image-surface (cairo-image-surface-create-for-data
  24.                         (SDL::surface-pixels cairo-surface)
  25.                         CAIRO_FORMAT_RGB24
  26.                         maxx
  27.                         maxy
  28.                         (SDL::screen-pitch cairo-surface)))
  29.        (cairo (cairo-create image-surface))
  30.        (paint-loop (lambda ()
  31.                      (cairo-set-source-rgba cairo 1.0 1.0 1.0 1.0)
  32.                      (cairo-rectangle cairo 0.0 0.0 (* maxx 1.0) (* maxy 1.0))
  33.                      (cairo-fill cairo)
  34.  
  35.                      (cairo-set-source-rgba cairo 1.0 1.0 0.0 1.0)
  36.                      (cairo-set-line-width cairo 15.0)
  37.  
  38.                      (cairo-new-path cairo)
  39.                      (cairo-set-line-cap cairo CAIRO_LINE_CAP_BUTT)
  40.                      (cairo-move-to cairo 10.0 10.0)
  41.                      (cairo-line-to cairo 10.0 80.0)
  42.                      (cairo-stroke cairo)
  43.  
  44.                      (cairo-new-path cairo)
  45.                      (cairo-set-line-cap cairo CAIRO_LINE_CAP_ROUND)
  46.                      (cairo-move-to cairo 50.0 10.0)
  47.                      (cairo-line-to cairo 50.0 80.0)
  48.                      (cairo-stroke cairo)
  49.  
  50.                      (cairo-new-path cairo)
  51.                      (cairo-set-line-cap cairo CAIRO_LINE_CAP_SQUARE)
  52.                      (cairo-move-to cairo 90.0 10.0)
  53.                      (cairo-line-to cairo 90.0 80.0)
  54.                      (cairo-stroke cairo)
  55.  
  56.                      (SDL::flip cairo-surface)
  57.  
  58.                      )))
  59.       (display "FIRST TIME ONLY\n")
  60.  
  61.       (call-with-current-continuation
  62.         (lambda (resume-here)
  63.           ;; Grab the current continuation
  64.           (set! control-state resume-here)
  65.           (let loop ()
  66.             (SDL::delay 4)
  67.             (if (SDL::event-exit)
  68.               (begin (SDL::exit)
  69.                      (exit 0)))
  70.             (display "WILL BE LOOP\n")
  71.             (paint-loop)
  72.             ;(loop)
  73.             )))))
  74.  
  75.   control-state)
  76.  
  77. (define (represent graph)
  78.   ((represent-loop graph)))
Submit a correction or amendment below. Make A New Post
To highlight particular lines, prefix each line with @h@
Syntax highlighting:
Post expiration:
Post exposure:
Name / Title:
Email: