# Main Command: Go # Blancmange Curve by Guy Walker # www.logoarts.co.uk to new # set default screen, pen and turtle ResetAll SetScreenSize [400 400] HideTurtle SetSC Black SetPC Green SetPS 1 PenUp end to init # create empty list Make "Y [ ] Repeat 257 [ Make "Y LPut 0 :Y ] end to display # write header title SetPC White PenUp SetPos [-190 180] Label [Blancmange Curve] end to blancmange # calculate heights Make "Index 256 For [N 1 8] [ For (List "M 1 256 :Index) [ Make "Average ((Item :M :Y) + Item (:M + :Index ) :Y) / 2 Make "Y SetItem :Y (:M+:Index/2) (:Index + :Average) ] Make "Index :Index / 2 ] end to draw # draw curves from list Make "Index 256 For [N 1 8] [ Wash Display PenUp SetPos [-127 -100] PenDown SetPC Pink For (List "P 1 257 :Index) [SetPos List :P-128 (Item :P :Y) / 2 -100] Make "Index :Index / 2 Wait 80] end to go New Init Blancmange Draw end