aboutsummaryrefslogtreecommitdiffstats
path: root/lib/gs/doc/src/examples/ex16.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
committerErlang/OTP <[email protected]>2009-11-20 14:54:40 +0000
commit84adefa331c4159d432d22840663c38f155cd4c1 (patch)
treebff9a9c66adda4df2106dfd0e5c053ab182a12bd /lib/gs/doc/src/examples/ex16.erl
downloadotp-84adefa331c4159d432d22840663c38f155cd4c1.tar.gz
otp-84adefa331c4159d432d22840663c38f155cd4c1.tar.bz2
otp-84adefa331c4159d432d22840663c38f155cd4c1.zip
The R13B03 release.OTP_R13B03
Diffstat (limited to 'lib/gs/doc/src/examples/ex16.erl')
-rw-r--r--lib/gs/doc/src/examples/ex16.erl40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/gs/doc/src/examples/ex16.erl b/lib/gs/doc/src/examples/ex16.erl
new file mode 100644
index 0000000000..9c995d16bf
--- /dev/null
+++ b/lib/gs/doc/src/examples/ex16.erl
@@ -0,0 +1,40 @@
+-module(ex16).
+-copyright('Copyright (c) 1991-97 Ericsson Telecom AB').
+-vsn('$Revision: /main/release/3 $ ').
+
+-export([start/0,init/0]).
+
+start() -> spawn(ex16, init, []).
+
+init() ->
+ I=gs:start(),
+ Win=gs:create(window, I,
+ [{width, 200},{height, 200},
+ {title,"Default Demo"},{map, true}]),
+ gs:create(canvas, can1,Win,
+ [{x,0},{y, 0},{width,200},{height,200},
+ {default,text,{font,{courier,bold,19}}},
+ {default,text,{fg,blue}},
+ {default,rectangle,{fill,red}},{default,text,{text,"Pow!"}},
+ {default,oval,{fill,green}}]),
+ {A,B,C} = erlang:now(),
+ random:seed(A,B,C),
+ loop().
+
+loop() ->
+ receive
+ {gs,_Id,destroy,_Data,_Arg} -> bye
+ after 500 ->
+ XY = {random:uniform(200),random:uniform(200)},
+ draw(random:uniform(3),XY),
+ loop()
+ end.
+
+draw(1,XY) ->
+ gs:create(text,can1,[{coords,[XY]}]);
+draw(2,XY) ->
+ XY2 = {random:uniform(200),random:uniform(200)},
+ gs:create(rectangle,can1,[{coords,[XY,XY2]}]);
+draw(3,XY) ->
+ XY2 = {random:uniform(200),random:uniform(200)},
+ gs:create(oval,can1,[{coords,[XY,XY2]}]).