% draw(Size) % draws a graphics with a given Size draw(Size) :- % prepare a Display to draw the object on % generate a new display name gensym(w,Display), free('@'Display), % define size of the display (picture size + scroll bar area) SizeD is Size+20, % create a new display and open it new('@'Display,picture('*** Your picture''s name ***',size(SizeD,SizeD))), send('@'Display,background,colour(black)), send('@'Display,open), % draw the object on the display draw_object('@'Display,Size,Size). % draw_object(Display,Size,CurrentSize,*** add additional parameters here, if needed ***) % draws a gradient graphics of size Size into Display % CurrentSize is decreased recursively fom Size to 0 draw_object(_,_,0, *** add additional parameters here, if needed ***). draw_object(Name,Size,CSize, *** add additional parameters here, if needed ***) :- % *** insert the computation of graphical parameters here *** % *** create and draw the current graphical object here *** % *** send all additional parameters to the current graphical object *** % decrement CurrentSize and call draw_object recursively CSizeNew is CSize - 2, draw_object(Name,Size,CSizeNew), % if desired save the display as .jpg write_ln('Save the graphics (y/n): '), get_single_char(A), pu_code(A),nl, A=:=121 -> (write_ln('enter file name: '), read_line_to_codes(user,X), atom_codes(File,X), atom_concat(File,'.jpg',FileName), get('@'Display,image,Image), send(Image,save,FileName,jpeg) ). % Call the program and see the result :- draw(*** specify desired display size here ***).