Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
35
Task/Chaos-game/Sidef/chaos-game.sidef
Normal file
35
Task/Chaos-game/Sidef/chaos-game.sidef
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
require('Imager')
|
||||
|
||||
var width = 600
|
||||
var height = 600
|
||||
|
||||
var points = [
|
||||
[width//2, 0],
|
||||
[ 0, height-1],
|
||||
[height-1, height-1],
|
||||
]
|
||||
|
||||
var img = %O|Imager|.new(
|
||||
xsize => width,
|
||||
ysize => height,
|
||||
)
|
||||
|
||||
var color = %O|Imager::Color|.new('#ff0000')
|
||||
var r = [(width-1).irand, (height-1).irand]
|
||||
|
||||
30000.times {
|
||||
var p = points.rand
|
||||
|
||||
r[] = (
|
||||
(p[0] + r[0]) // 2,
|
||||
(p[1] + r[1]) // 2,
|
||||
)
|
||||
|
||||
img.setpixel(
|
||||
x => r[0],
|
||||
y => r[1],
|
||||
color => color,
|
||||
)
|
||||
}
|
||||
|
||||
img.write(file => 'chaos_game.png')
|
||||
Loading…
Add table
Add a link
Reference in a new issue