2 import gfxprim
.core
as core
3 import gfxprim
.backends
as backends
4 import gfxprim
.gfx
as gfx
13 class plotter(object):
15 self
.x0
= random
.uniform(0, W
)
16 self
.y0
= random
.uniform(H
*0.2, H
*0.8)
17 self
.a
= H
* (0.06 + random
.uniform(0, 0.1) + random
.uniform(0, 0.2))
18 self
.period
= 4.0 + random
.expovariate(4.0/W
)
19 self
.speed
= random
.uniform(0.04, min(max(0.05, 0.5 * self
.period
/ self
.a
), 1.0))
21 x
= self
.x0
+ self
.speed
* t
22 y
= self
.y0
+ sin(x
/ self
.period
) * self
.a
26 128 + 120 * sin(t
/ (self
.a
+ 10.0)),
27 128 + 120 * sin(t
/ (self
.y0
+ 3.0)),
28 128 + 120 * sin(t
/ (self
.x0
+ 5.0)))
32 bk
= backends
.BackendSDLInit(W
, H
, 16, 0, "Sinplots AA")
35 print("Modify source for parameters,")
36 print("Kill to terminate ;-)")
37 black
= bk
.pixmap
.RGBToPixel(0, 0, 0)
39 ps
= [plotter() for i
in range(N
)]
40 t
= random
.uniform(0.0, 10.0 * W
)
45 (r
, g
, b
) = p
.color(t
)
49 bk
.pixmap
.gfx
.VLineAA(x
+ 0x100, y
- 0x200, y
+ 0x200, black
)
50 bk
.pixmap
.gfx
.PutPixelAA(x
, y
, bk
.pixmap
.RGBToPixel(int(r
), int(g
), int(b
)))
54 bk
.pixmap
.gfx
.VLine(x
+ 1, y
- 2, y
+ 2, black
)
55 bk
.pixmap
.core
.PutPixel(x
, y
, bk
.pixmap
.RGBToPixel(int(r
), int(g
), int(b
)))
58 if __name__
== '__main__':