Plasma effect: Difference between revisions
m
syntax highlighting fixup automation
(Added Forth entry) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 14:
=={{header|AWK}}==
<syntaxhighlight lang="awk">
#!/usr/bin/awk -f
Line 94:
printf("\n")
}
</syntaxhighlight>
=={{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">
#include<windows.h>
#include<stdlib.h>
Line 137:
return 0;
}
</syntaxhighlight>
===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">
#include<graphics.h>
#include<stdlib.h>
Line 185:
return 0;
}
</syntaxhighlight>
=={{header|C++}}==
Line 191:
Windows version.
<
#include <windows.h>
#include <math.h>
Line 407:
return myWnd.Run( hInstance );
}
</syntaxhighlight>
=={{header|Ceylon}}==
Be sure to import javafx.base, javafx.graphics and ceylon.numeric in your module file.
{{trans|Java}}
<
import javafx.application {
Application
Line 497:
}
}</
=={{header|Common Lisp}}==
Line 503:
{{libheader|simple-rgb}}
plasma_demo.lisp:
<
(require :simple-rgb)
Line 570:
(:quit-event () t))))))
(demo/plasma)</
=={{header|Forth}}==
Line 576:
{{works with|gforth|0.7.3}}
Ouputs a PPM file.
<
dup 2/ ( first square root guess is half )
dup 0= if drop exit then ( sqrt[0]=0, sqrt[1]=1 )
Line 616:
r> to outfile-id ;
plasma</
Line 622:
=={{header|FreeBASIC}}==
<
' compile with: fbc -s gui
' Computer Graphics Tutorial (lodev.org), last example
Line 658:
End If
Loop</
=={{header|Go}}==
Line 670:
$ eog plasma2.gif
</pre>
<
import (
Line 758:
log.Fatal(err2)
}
}</
=={{header|Gosu}}==
[[File:Gosu_plasma.png|200px|thumb|right]]
{{trans|Java}}
<
uses javax.swing.*
uses java.awt.*
Line 809:
}
}
</syntaxhighlight>
=={{header|J}}==
[[File:J-viewmat-plasma.png|200px|thumb|right]]
<
plasma=: 3 :0
'w h'=. y
Line 823:
xy2=. sin (Y +&.*:/ X)*32
xy1+xy2+y1+/x1
)</
<syntaxhighlight lang
=={{header|Java}}==
[[File:plasma_effect_java.png|200px|thumb|right]]
{{works with|Java|8}}
<
import java.awt.event.*;
import java.awt.image.*;
Line 911:
});
}
}</
=={{header|JavaScript}}==
{{trans|Java}}
<
<html lang='en'>
<head>
Line 1,036:
</body>
</html></
=={{header|Julia}}==
{{trans|Perl}}
<
Drawing(800, 800)
Line 1,053:
@png plasma(800, 800)
</syntaxhighlight>
=={{header|Kotlin}}==
{{trans|Java}}
<
import java.awt.*
Line 1,127:
f.isVisible = true
}
}</
=={{header|Lua}}==
Needs LÖVE 2D Engine
{{trans|C++}}
<
_ = love.graphics
p1, p2, points = {}, {}, {}
Line 1,173:
_.points( points )
end
</syntaxhighlight>
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<
Image@Table[
hue = Sin[i/16] + Sin[j/8] + Sin[(i + j)/16] + Sin[Sqrt[i^2 + j^2]/8];
Line 1,184:
{i, 1.0, s},
{j, 1.0, s}
]</
{{out}}
Outputs an image.
Line 1,190:
=={{header|Nim}}==
{{libheader|imageman}}
<
import imageman
Line 1,206:
let rgb = to(ColorHSL([hue * 360, 1, 0.5]), ColorRGBF)
img[x, y] = rgb
img.savePNG("plasma.png")</
=={{header|Ol}}==
<
; creating the "plasma" image buffer
(import (scheme inexact))
Line 1,224:
(iota 256)))
(iota 256))))
</syntaxhighlight>
<
; rendering the prepared buffer (using OpenGL)
(import (lib gl1))
Line 1,251:
(glVertex2f 1 -1)
(glEnd)))
</syntaxhighlight>
=={{header|Perl}}==
{{trans|Raku}}
<
sub plasma {
Line 1,273:
my $img = plasma(400, 400);
$img->write(file => 'plasma-perl.png');</
Off-site image: [https://github.com/SqrtNegInf/Rosettacode-Perl5-Smoke/blob/master/ref/plasma.png Plasma effect]
Line 1,279:
{{libheader|Phix/pGUI}}
{{trans|JavaScript}}
<
include pGUI.e
Line 1,378:
end procedure
main()</
And here's a simple console ditty, similar I think to C's ASCII version for Windows, though this also works on Linux:
<
for i=1 to s[VC_SCRNLINES]*s[VC_SCRNCOLS]-1 do
bk_color(rand(16)-1)
Line 1,386:
puts(1,"\xDF")
end for
{} = wait_key()</
=={{header|Processing}}==
<
Plasmas with Palette Looping
https://lodev.org/cgtutor/plasma.html#Plasmas_with_Palette_Looping_
Line 1,436:
}
updatePixels();
}</
'''It can be played on line''' :<BR> [https://www.openprocessing.org/sketch/873932/ here.]
Line 1,442:
==={{header|Processing Python mode}}===
<
Plasmas with Palette Looping
https://lodev.org/cgtutor/plasma.html#Plasmas_with_Palette_Looping_
Line 1,489:
pixels[i] = pal[(b + frameCount) % 127]
updatePixels()
</syntaxhighlight>
=={{header|Python}}==
{{trans|Raku}}
<
import colorsys
from PIL import Image
Line 1,511:
if __name__=="__main__":
im = plasma(400, 400)
im.show()</
=={{header|Racket}}==
Line 1,517:
Uses `return-color-by-pos` from [[#Lisp]], because it was almost lift and shift
<
;; from lisp (cos I could just lift the code)
(require images/flomap
Line 1,577:
(define plsm ((plasma-flomap) 300 300))
(animate (λ (t)
((colour-plasma plsm) t)))</
=={{header|Raku}}==
Line 1,583:
[[File:Plasma-perl6.png|200px|thumb|right]]
{{works with|Rakudo|2018.09}}
<syntaxhighlight lang="raku"
my ($w, $h) = 400, 400;
Line 1,613:
when 5/6..1 { $c, 0, $x }
} ).map: ((*+$m) * 255).Int
}</
=={{header|Ring}}==
<
# Project : Plasma effect
Line 1,688:
d = sqrt(((a - c) * (a - c) + (b - d) * (b - d)))
return d
</syntaxhighlight>
Output:
Line 1,698:
{{libheader|JRubyArt}}
JRubyArt is a port of Processing to the ruby language
<
attr_reader :buffer, :palette, :r, :g, :b, :rd, :gd, :bd, :dim
Line 1,760:
update_pixels
end
</syntaxhighlight>
=={{header|Rust}}==
<
extern crate image;
Line 1,845:
}
</syntaxhighlight>
=={{header|Scala}}==
===Java Swing Interoperability===
<
import java.awt.event.ActionEvent
import java.awt.image.BufferedImage
Line 1,906:
})
}</
=={{header|Sidef}}==
{{trans|Raku}}
<
class Plasma(width=400, height=400) {
Line 1,934:
var plasma = Plasma(256, 256)
plasma.generate
plasma.save_as('plasma.png')</
Output image: [https://github.com/trizen/rc/blob/master/img/plasma-effect-sidef.png Plasma effect]
Line 1,940:
{{trans|Kotlin}}
{{libheader|DOME}}
<
import "dome" for Window
import "math" for Math
Line 2,003:
}
var Game = PlasmaEffect.new(640, 640)</
=={{header|XPL0}}==
Translation of Lode's RGB plasma, provided by link at the top of this page.
<
int X1, Y1, X2, Y2;
return sqrt( float((X1-X2)*(X1-X2) + (Y1-Y2)*(Y1-Y2)) );
Line 2,025:
];
until KeyHit;
]</
|