Jump to content

Plasma effect: Difference between revisions

Added Sidef
m (formatting of task description)
(Added Sidef)
Line 444:
( $r, $g, $b ) = map { (($_+$m) * 255).Int }, $r, $g, $b;
}</lang>
 
=={{header|Sidef}}==
{{trans|Perl 6}}
<lang ruby>require('Imager')
 
class Plasma(width=400, height=400) {
 
has img = nil
 
method init {
img = %s|Imager|.new(xsize => width, ysize => height)
}
 
method generate {
for y,x in (^height ~X ^width) {
var hue = (4 + sin(x/19) + sin(y/9) + sin((x+y)/25) + sin(hypot(x, y)/8))
img.setpixel(x => x, y => y, color => Hash(hsv => [360 * hue / 8, 1, 1]))
}
}
 
method save_as(filename) {
img.write(file => filename)
}
}
 
var plasma = Plasma(256, 256)
plasma.generate
plasma.save_as('plasma.png')</lang>
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.