Plasma effect: Difference between revisions

m
→‎{{header|Wren}}: Changed to Wren S/H
(Added Forth entry)
m (→‎{{header|Wren}}: Changed to Wren S/H)
(8 intermediate revisions by 4 users not shown)
Line 14:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
#!/usr/bin/awk -f
 
Line 94:
printf("\n")
}
</syntaxhighlight>
</lang>
 
=={{header|C}}==
===ASCII version for Windows===
If you don't want to bother with Graphics libraries, try out this nifty implementation on Windows :
<syntaxhighlight lang="c">
<lang C>
#include<windows.h>
#include<stdlib.h>
Line 137:
return 0;
}
</syntaxhighlight>
</lang>
 
===Graphics version===
And here's the Graphics version, requires the [http://www.cs.colorado.edu/~main/bgi/cs1300/ WinBGIm] library. Prints out usage on incorrect invocation.
<syntaxhighlight lang="c">
<lang C>
#include<graphics.h>
#include<stdlib.h>
Line 185:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|C++}}==
===Version 1 (windows.h)===
[[File:plasma.png]]
 
Windows version.
<langsyntaxhighlight lang="cpp">
#include <windows.h>
#include <math.h>
Line 407 ⟶ 408:
return myWnd.Run( hInstance );
}
</syntaxhighlight>
</lang>
 
===Version 2 (SDL2)===
{{libheader|SDL2}}
<center>Take that, Paulo Jorente!</center>
 
====Version 2.1====
<syntaxhighlight lang="cpp" line>
// Standard C++ stuff
#include <iostream>
#include <array>
#include <cmath>
#include <numbers>
 
// SDL2 stuff
#include "SDL2/SDL.h"
 
// Compile: g++ -std=c++20 -Wall -Wextra -pedantic -Ofast SDL2Plasma.cpp -o SDL2Plasma -lSDL2 -fopenmp
 
struct RGB {
int Red, Green, Blue;
};
 
RGB HSBToRGB(const double hue, const double saturation, const double brightness) {
double Red = 0,
Green = 0,
Blue = 0;
if (hue == 1) {
Red = brightness;
} else {
double Sector = hue * 360,
Cosine = std::cos(Sector*std::numbers::pi/180),
Sine = std::sin(Sector*std::numbers::pi/180);
Red = brightness * Cosine + saturation * Sine;
Green = brightness * Cosine - saturation * Sine;
Blue = brightness - saturation * Cosine;
}
RGB Result;
Result.Red = (int)(Red * 255);
Result.Green = (int)(Green * 255);
Result.Blue = (int)(Blue * 255);
return Result;
}
 
template <int width_array_length, int height_array_length>
void CalculatePlasma(std::array<std::array<double, width_array_length>, height_array_length> &array) {
#pragma omp parallel for
for (unsigned long y = 0; y < array.size(); y++)
#pragma omp simd
for (unsigned long x = 0; x < array.at(0).size(); x++) {
// Calculate the hue
double Hue = std::sin(x/16.0);
Hue += std::sin(y/8.0);
Hue += std::sin((x+y)/16.0);
Hue += std::sin(std::sqrt(x*x+y*y)/8.0);
Hue += 4;
// Clamp the hue to the range of [0, 1]
Hue /= 8;
array[y][x] = Hue;
}
}
 
template <int width_array_length, int height_array_length>
void DrawPlasma(SDL_Renderer *r, const std::array<std::array<double, width_array_length>, height_array_length> &array, const double &hue_shift) {
for (unsigned long y = 0; y < array.size(); y++)
for (unsigned long x = 0; x < array.at(0).size(); x++) {
// Convert the HSB value to RGB value
double Hue = hue_shift + std::fmod(array[y][x], 1);
RGB CurrentColour = HSBToRGB(Hue, 1, 1);
// Draw the actual plasma
SDL_SetRenderDrawColor(r, CurrentColour.Red, CurrentColour.Green, CurrentColour.Blue, 0xff);
SDL_RenderDrawPoint(r, x, y);
}
}
 
int main() {
const unsigned DefaultWidth = 640,
DefaultHeight = 640;
std::array<std::array<double, DefaultWidth>, DefaultHeight> ScreenArray;
SDL_Window *Window = NULL; // Define window
SDL_Renderer *Renderer = NULL; // Define renderer
// Init everything just for sure
SDL_Init(SDL_INIT_EVERYTHING);
// Set window size to 640x640, always shown
Window = SDL_CreateWindow("Plasma effect", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, SDL_WINDOW_SHOWN);
Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED);
// Set background colour to white
SDL_SetRenderDrawColor(Renderer, 0xff, 0xff, 0xff, 0xff);
SDL_RenderClear(Renderer);
// Create an event handler and a "quit" flag
SDL_Event e;
bool KillWindow = false;
CalculatePlasma<DefaultWidth, DefaultHeight>(ScreenArray);
double HueShift = 0.0;
// The window runs until the "quit" flag is set to true
while (!KillWindow) {
while (SDL_PollEvent(&e) != 0) {
// Go through the events in the queue
switch (e.type) {
// Event: user hits a key
case SDL_QUIT: case SDL_KEYDOWN:
// Destroy window
KillWindow = true;
break;
}
}
// Render the plasma
DrawPlasma<DefaultWidth, DefaultHeight>(Renderer, ScreenArray, HueShift);
SDL_RenderPresent(Renderer);
if (HueShift < 1) {
HueShift = std::fmod(HueShift + 0.0025, 3);
} else {
CalculatePlasma<DefaultWidth, DefaultHeight>(ScreenArray);
HueShift = 0.0;
}
}
// Destroy renderer and window
SDL_DestroyRenderer(Renderer);
SDL_DestroyWindow(Window);
SDL_Quit();
return 0;
}
</syntaxhighlight>
 
{{Output}}
<center>[[File:C++ plasma effect SDL2.gif]]</center>
 
====Version 2.2====
<syntaxhighlight lang="cpp" line>
// Standard C++ stuff
#include <iostream>
#include <array>
#include <cmath>
#include <numbers>
 
// SDL2 stuff
#include "SDL2/SDL.h"
 
// Compile: g++ -std=c++20 -Wall -Wextra -pedantic -Ofast SDL2Plasma.cpp -o SDL2Plasma -lSDL2 -fopenmp
 
struct RGB {
int Red, Green, Blue;
};
 
RGB HSBToRGB(const float hue, const float saturation, const float brightness) {
float Red = 0,
Green = 0,
Blue = 0;
if (hue == 1) {
Red = brightness;
} else {
float Sector = hue * 360,
Cosine = std::cos(Sector*std::numbers::pi/180),
Sine = std::sin(Sector*std::numbers::pi/180);
Red = brightness * Cosine + saturation * Sine;
Green = brightness * Cosine - saturation * Sine;
Blue = brightness - saturation * Cosine;
}
RGB Result;
Result.Red = (int)(Red * 255);
Result.Green = (int)(Green * 255);
Result.Blue = (int)(Blue * 255);
return Result;
}
 
template <int width_array_length, int height_array_length>
void CalculatePlasma(std::array<std::array<float, width_array_length>, height_array_length> &array) {
#pragma omp parallel for
for (unsigned long y = 0; y < array.size(); y++)
#pragma omp simd
for (unsigned long x = 0; x < array.at(0).size(); x++) {
// Calculate the hue
float Hue = std::sin(x/16.0);
Hue += std::sin(y/8.0);
Hue += std::sin((x+y)/16.0);
Hue += std::sin(std::sqrt(x*x+y*y)/8.0);
Hue += 4;
// Clamp the hue to the range of [0, 1]
Hue /= 8;
array[y][x] = Hue;
}
}
 
template <int width_array_length, int height_array_length>
void DrawPlasma(SDL_Renderer *r, SDL_Texture *t, const std::array<std::array<float, width_array_length>, height_array_length> &array, const float &hue_shift) {
unsigned char *Bytes = NULL;
int Pitch = 0;
float Hue;
// Lock the texture
SDL_LockTexture(t, NULL, (void**)&Bytes, &Pitch);
for (unsigned long y = 0; y < array.size(); y++)
for (unsigned long x = 0; x < array.at(0).size(); x++) {
// Convert the HSB value to RGB value
Hue = hue_shift + std::fmod(array[y][x], 1);
RGB CurrentColour = HSBToRGB(Hue, 1, 1);
// Write colour data directly to texture
Bytes[y*Pitch+x*4] = CurrentColour.Red; // Red
Bytes[y*Pitch+x*4+1] = CurrentColour.Green; // Green
Bytes[y*Pitch+x*4+2] = CurrentColour.Blue; // Blue
Bytes[y*Pitch+x*4+3] = 0xff; // Alpha
}
// Unlock the texture
SDL_UnlockTexture(t);
// Feed the finished texture to the renderer
SDL_RenderCopy(r, t, NULL, NULL);
}
 
int main() {
const unsigned DefaultWidth = 640,
DefaultHeight = 640;
std::array<std::array<float, DefaultWidth>, DefaultHeight> ScreenArray;
SDL_Window *Window = NULL; // Define window
SDL_Renderer *Renderer = NULL; // Define renderer
// Init everything just for sure
SDL_Init(SDL_INIT_EVERYTHING);
// Set window size to 640x640, always shown
Window = SDL_CreateWindow("Plasma effect", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, DefaultWidth, DefaultHeight, SDL_WINDOW_SHOWN);
Renderer = SDL_CreateRenderer(Window, -1, SDL_RENDERER_ACCELERATED);
SDL_Texture *PlasmaTexture = SDL_CreateTexture(Renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_STREAMING, DefaultWidth, DefaultHeight);
// Set background colour to white
SDL_SetRenderDrawColor(Renderer, 0xff, 0xff, 0xff, 0xff);
SDL_RenderClear(Renderer);
// Create an event handler and a "quit" flag
SDL_Event e;
bool KillWindow = false;
CalculatePlasma<DefaultWidth, DefaultHeight>(ScreenArray);
float HueShift = 0.0;
// The window runs until the "quit" flag is set to true
while (!KillWindow) {
while (SDL_PollEvent(&e) != 0) {
// Go through the events in the queue
switch (e.type) {
// Event: user hits a key
case SDL_QUIT: case SDL_KEYDOWN:
// Destroy window
KillWindow = true;
break;
}
}
// Render the plasma
DrawPlasma<DefaultWidth, DefaultHeight>(Renderer, PlasmaTexture, ScreenArray, HueShift);
SDL_RenderPresent(Renderer);
if (HueShift < 1) {
HueShift = std::fmod(HueShift + 0.0025, 3);
} else {
CalculatePlasma<DefaultWidth, DefaultHeight>(ScreenArray);
HueShift = 0.0;
}
}
// Destroy renderer and window
SDL_DestroyRenderer(Renderer);
SDL_DestroyWindow(Window);
SDL_Quit();
return 0;
}
</syntaxhighlight>
 
{{Output}}
<center>[[File:C++ plasma effect SDL2 version 2.2.png|480px]]</center>
 
=={{header|Ceylon}}==
Be sure to import javafx.base, javafx.graphics and ceylon.numeric in your module file.
{{trans|Java}}
<langsyntaxhighlight lang="ceylon">
import javafx.application {
Application
Line 497 ⟶ 789:
}
 
}</langsyntaxhighlight>
 
=={{header|Common Lisp}}==
Line 503 ⟶ 795:
{{libheader|simple-rgb}}
plasma_demo.lisp:
<langsyntaxhighlight lang="lisp">(require :lispbuilder-sdl)
(require :simple-rgb)
 
Line 570 ⟶ 862:
(:quit-event () t))))))
 
(demo/plasma)</langsyntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
[[File:DelphiPlasma.png|frame|none]]
{{libheader|SysUtils,StdCtrls}}
This code animates the plasma, which looks very nice. However, there are too many colors to render it properly with an animated GIF. As a result, I've only posted a static image of the plasma.
 
 
<syntaxhighlight lang="Delphi">
 
function PasmaPixel(X,Y,W,H: integer; Offset: double): TColor;
{Return pixel based on X,Y position and the size of the image}
{Offset controls the progression through the plasma for animation}
var A, B, C, Red, Green, Blue: double;
begin
A:=X + Y + Cos(Sin(Offset) * 2) * 100 + Sin(x / 100) * 1000;
B:=Y / H / 0.2 + Offset;
C:=X / W / 0.2;
Red:=abs(Sin(B + Offset) / 2 + C / 2 - B - C + Offset);
Green:=abs(Sin(Red + Sin(A / 1000 + Offset) + Sin(Y / 40 + Offset) + Sin((X + Y) / 100) * 3));
Blue:=abs(sin(Green + Cos(B + C + Green) + Cos(C) + Sin(X / 1000)));
Result := RGB(Round(255*Red), Round(255*Green), Round(255*Blue));
end;
 
 
procedure DisplayPlasma(Bmp: TBitmap; Width,Height: integer; Offset: double);
{Draw the plasma pattern on the bitmap progressed according to "Offset"}
var X,Y: integer;
var Scan: pRGBTripleArray;
begin
Bmp.PixelFormat:=pf24Bit;
for Y:=0 to Height-1 do
begin
Scan:=Bmp.ScanLine[Y];
for X:=0 to Width-1 do
begin
Scan[X]:=ColorToTriple(PasmaPixel(X,Y,Width,Height,Offset));
end;
end;
end;
var Offset: double;
 
 
procedure ShowPlasma(Image: TImage);
{Animate 10 seconds of plasma display}
var X,Y: integer;
var I,StartTime,CurTime,StopTime: integer;
const TimeLimit = 10;
begin
{setup stop time based on real-time clock}
StartTime:=GetTickCount;
StopTime:=StartTime + (TimeLimit * 1000);
{Keep display frame until stop time is reached}
for I:=0 to high(integer) do
begin
{Display one frame}
DisplayPlasma(Image.Picture.Bitmap,Image.Width,Image.Height,Offset);
{Display count-down time}
CurTime:=GetTickCount;
Image.Canvas.Brush.Style:=bsClear;
Image.Canvas.TextOut(5,5,IntToStr((CurTime-StartTime) div 1000)+' '+IntToStr(I));
Image.Repaint;
Application.ProcessMessages;
if Application.Terminated then exit;
{Exit if timed out}
if CurTime>StopTime then break;
Sleep(50);
{progress animation one step}
Offset:=Offset+0.1;
end;
end;
 
</syntaxhighlight>
{{out}}
<pre>
Elapsed Time: 10.127 Sec.
 
</pre>
 
=={{header|Forth}}==
Line 576 ⟶ 946:
{{works with|gforth|0.7.3}}
Ouputs a PPM file.
<langsyntaxhighlight lang="forth">: sqrt ( u -- sqrt ) ( Babylonian method )
dup 2/ ( first square root guess is half )
dup 0= if drop exit then ( sqrt[0]=0, sqrt[1]=1 )
Line 616 ⟶ 986:
r> to outfile-id ;
 
plasma</langsyntaxhighlight>
 
 
Line 622 ⟶ 992:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' version 12-04-2017
' compile with: fbc -s gui
' Computer Graphics Tutorial (lodev.org), last example
Line 658 ⟶ 1,028:
End If
 
Loop</langsyntaxhighlight>
 
=={{header|Go}}==
Line 670 ⟶ 1,040:
$ eog plasma2.gif
</pre>
<langsyntaxhighlight lang="go">package main
 
import (
Line 758 ⟶ 1,128:
log.Fatal(err2)
}
}</langsyntaxhighlight>
 
=={{header|Gosu}}==
[[File:Gosu_plasma.png|200px|thumb|right]]
{{trans|Java}}
<langsyntaxhighlight lang="gosu">
uses javax.swing.*
uses java.awt.*
Line 809 ⟶ 1,179:
}
}
</syntaxhighlight>
</lang>
 
=={{header|J}}==
[[File:J-viewmat-plasma.png|200px|thumb|right]]
<langsyntaxhighlight lang="j">require 'trig viewmat'
plasma=: 3 :0
'w h'=. y
Line 823 ⟶ 1,193:
xy2=. sin (Y +&.*:/ X)*32
xy1+xy2+y1+/x1
)</langsyntaxhighlight>
 
<syntaxhighlight lang ="j"> viewmat plasma 256 256</langsyntaxhighlight>
 
=={{header|Java}}==
[[File:plasma_effect_java.png|200px|thumb|right]]
{{works with|Java|8}}
<langsyntaxhighlight lang="java">import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
Line 911 ⟶ 1,281:
});
}
}</langsyntaxhighlight>
 
=={{header|JavaScript}}==
{{trans|Java}}
<langsyntaxhighlight lang="javascript"><!DOCTYPE html>
<html lang='en'>
<head>
Line 1,036 ⟶ 1,406:
 
</body>
</html></langsyntaxhighlight>
 
=={{header|Julia}}==
{{trans|Perl}}
<langsyntaxhighlight lang="julia">using Luxor, Colors
 
Drawing(800, 800)
 
function plasma(wid, hei)
for x in 1-wid:wid, y in 1-hei:hei
sethue(parse(Colorant, HSV(180 + 45sin(x/19) + 45sin(y/9) +
45sin((x+y)/25) + 45sin(sqrt(x^2 + y^2)/8), 1, 1)))
Line 1,053 ⟶ 1,423:
 
@png plasma(800, 800)
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">// version 1.1.2
 
import java.awt.*
Line 1,127 ⟶ 1,497:
f.isVisible = true
}
}</langsyntaxhighlight>
 
=={{header|Lua}}==
Needs L&Ouml;VE 2D Engine
{{trans|C++}}
<langsyntaxhighlight lang="lua">
_ = love.graphics
p1, p2, points = {}, {}, {}
Line 1,173 ⟶ 1,543:
_.points( points )
end
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">s = 400;
Image@Table[
hue = Sin[i/16] + Sin[j/8] + Sin[(i + j)/16] + Sin[Sqrt[i^2 + j^2]/8];
Line 1,184 ⟶ 1,554:
{i, 1.0, s},
{j, 1.0, s}
]</langsyntaxhighlight>
{{out}}
Outputs an image.
Line 1,190 ⟶ 1,560:
=={{header|Nim}}==
{{libheader|imageman}}
<langsyntaxhighlight Nimlang="nim">import math
import imageman
 
Line 1,206 ⟶ 1,576:
let rgb = to(ColorHSL([hue * 360, 1, 0.5]), ColorRGBF)
img[x, y] = rgb
img.savePNG("plasma.png")</langsyntaxhighlight>
 
=={{header|Ol}}==
<langsyntaxhighlight lang="scheme">
; creating the "plasma" image buffer
(import (scheme inexact))
Line 1,224 ⟶ 1,594:
(iota 256)))
(iota 256))))
</syntaxhighlight>
</lang>
<langsyntaxhighlight lang="scheme">
; rendering the prepared buffer (using OpenGL)
(import (lib gl1))
Line 1,251 ⟶ 1,621:
(glVertex2f 1 -1)
(glEnd)))
</syntaxhighlight>
</lang>
 
=={{header|Perl}}==
{{trans|Raku}}
<langsyntaxhighlight lang="perl">use Imager;
 
sub plasma {
Line 1,273 ⟶ 1,643:
 
my $img = plasma(400, 400);
$img->write(file => 'plasma-perl.png');</langsyntaxhighlight>
Off-site image: [https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/plasma.png Plasma effect]
 
Line 1,279 ⟶ 1,649:
{{libheader|Phix/pGUI}}
{{trans|JavaScript}}
<langsyntaxhighlight Phixlang="phix">-- demo\rosetta\plasma.exw
include pGUI.e
 
Line 1,378 ⟶ 1,748:
end procedure
 
main()</langsyntaxhighlight>
And here's a simple console ditty, similar I think to C's ASCII version for Windows, though this also works on Linux:
<langsyntaxhighlight Phixlang="phix">sequence s = video_config()
for i=1 to s[VC_SCRNLINES]*s[VC_SCRNCOLS]-1 do
bk_color(rand(16)-1)
Line 1,386 ⟶ 1,756:
puts(1,"\xDF")
end for
{} = wait_key()</langsyntaxhighlight>
 
=={{header|Processing}}==
<langsyntaxhighlight lang="java">/**
Plasmas with Palette Looping
https://lodev.org/cgtutor/plasma.html#Plasmas_with_Palette_Looping_
Line 1,436 ⟶ 1,806:
}
updatePixels();
}</langsyntaxhighlight>
 
'''It can be played on line''' :<BR> [https://www.openprocessing.org/sketch/873932/ here.]
Line 1,442 ⟶ 1,812:
==={{header|Processing Python mode}}===
 
<langsyntaxhighlight lang="python">"""
Plasmas with Palette Looping
https://lodev.org/cgtutor/plasma.html#Plasmas_with_Palette_Looping_
Line 1,489 ⟶ 1,859:
pixels[i] = pal[(b + frameCount) % 127]
updatePixels()
</syntaxhighlight>
</lang>
 
=={{header|Python}}==
{{trans|Raku}}
 
<langsyntaxhighlight lang="python">import math
import colorsys
from PIL import Image
Line 1,511 ⟶ 1,881:
if __name__=="__main__":
im = plasma(400, 400)
im.show()</langsyntaxhighlight>
 
=={{header|Racket}}==
Line 1,517 ⟶ 1,887:
Uses `return-color-by-pos` from [[#Lisp]], because it was almost lift and shift
 
<langsyntaxhighlight lang="racket">#lang racket
;; from lisp (cos I could just lift the code)
(require images/flomap
Line 1,577 ⟶ 1,947:
(define plsm ((plasma-flomap) 300 300))
(animate (λ (t)
((colour-plasma plsm) t)))</langsyntaxhighlight>
 
=={{header|Raku}}==
Line 1,583 ⟶ 1,953:
[[File:Plasma-perl6.png|200px|thumb|right]]
{{works with|Rakudo|2018.09}}
<syntaxhighlight lang="raku" perl6line>use Image::PNG::Portable;
 
my ($w, $h) = 400, 400;
Line 1,613 ⟶ 1,983:
when 5/6..1 { $c, 0, $x }
} ).map: ((*+$m) * 255).Int
}</langsyntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Plasma effect
 
Line 1,688 ⟶ 2,058:
d = sqrt(((a - c) * (a - c) + (b - d) * (b - d)))
return d
</syntaxhighlight>
</lang>
Output:
 
Line 1,698 ⟶ 2,068:
{{libheader|JRubyArt}}
JRubyArt is a port of Processing to the ruby language
<langsyntaxhighlight lang="ruby">
attr_reader :buffer, :palette, :r, :g, :b, :rd, :gd, :bd, :dim
 
Line 1,760 ⟶ 2,130:
update_pixels
end
</syntaxhighlight>
</lang>
 
=={{header|Rust}}==
<langsyntaxhighlight lang="rust">
extern crate image;
 
Line 1,845 ⟶ 2,215:
}
 
</syntaxhighlight>
</lang>
 
=={{header|Scala}}==
===Java Swing Interoperability===
<langsyntaxhighlight Scalalang="scala">import java.awt._
import java.awt.event.ActionEvent
import java.awt.image.BufferedImage
Line 1,906 ⟶ 2,276:
})
 
}</langsyntaxhighlight>
 
=={{header|Sidef}}==
{{trans|Raku}}
<langsyntaxhighlight lang="ruby">require('Imager')
 
class Plasma(width=400, height=400) {
Line 1,934 ⟶ 2,304:
var plasma = Plasma(256, 256)
plasma.generate
plasma.save_as('plasma.png')</langsyntaxhighlight>
Output image: [https://github.com/trizen/rc/blob/master/img/plasma-effect-sidef.png Plasma effect]
 
Line 1,940 ⟶ 2,310:
{{trans|Kotlin}}
{{libheader|DOME}}
<langsyntaxhighlight ecmascriptlang="wren">import "graphics" for Canvas, Color, ImageData
import "dome" for Window
import "math" for Math
Line 2,003 ⟶ 2,373:
}
 
var Game = PlasmaEffect.new(640, 640)</langsyntaxhighlight>
 
=={{header|XPL0}}==
Translation of Lode's RGB plasma, provided by link at the top of this page.
<langsyntaxhighlight XPL0lang="xpl0">func real Dist(X1, Y1, X2, Y2);
int X1, Y1, X2, Y2;
return sqrt( float((X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2)) );
Line 2,025 ⟶ 2,395:
];
until KeyHit;
]</langsyntaxhighlight>
9,482

edits