HTML5

HTML5 canvas plasma demo

I was going through some old QuickBasic stuff, and decided to see if modern browsers could render a old-school plasma demo in JavaScript, as quickly as QB ones could be run in DOS. Using this code, I found out that no, those old QB plasma demos are still faster. (To be fair, though, they used VGA mode 13, which meant 256 paletted colours; this is 24-bit colour here.)

  1. <title>Canvas Plasma</title>
  2.  
  3. <script type="text/javascript">
  4. var ctx;
  5. var tid = null;
  6.  
  7. function body_Load() {
  8.     var canvas = document.getElementById('plasma');
  9.     if (canvas.getContext) {
  10.         ctx = canvas.getContext('2d');
  11.        
  12.         traceDiv = document.getElementById('trace');
  13.     }
  14.     else {
  15.         alert("Couldn't get the canvas, sorry :(");
  16.     }
  17. }
  18.  
  19. function startButton_Click() {
  20.     if (tid != null)
  21.         clearInterval(tid);
  22.    
  23.     tid = setInterval("drawFrame()", 50);
  24. }
  25.  
  26. function stepButton_Click() {
  27.     drawFrame();
  28. }
  29.  
  30. func
Syndicate content