Home / Logo / HyperCube Code
Site Index

HyperCube in Logo

The hypercube on my Home Page was created using MSWLogo, a free implementation of LOGO by George Mills. MSWLogo now includes commands to save images in gif format and allows you to create gif animations.

The gif animation created in MSWLogo was combined with the graphics using GIF Movie Gear 2.5.

The LOGO code for the hypercube appears below:

to hypc2 :len

; :ps is pensize 
; :homexy is the center of the hyper square
; :ohd is the original heading
; :origpen is the original pen status
	(local "ps "homexy "ohd "origpen)

;
; save pen modes
	make "origpen pen

	make "ps (list 2 2) 
	make "centerxy pos
	make "ohd heading

	setpensize :ps
	pu 
	lt 90 
	fd :len + :len/5 
	rt 90 fd :len/2 
	pd
	
	(gifsave "hypc.gif 50 "False -1)
	repeat 8 	
	[	
		sq :len 	
		lt 45 
		bk :len 
		(gifsave "hypc.gif 50 "True -1)
	]

	pu
	setpos :centerxy
	setheading :ohd
	setpen :origpen
end

to sq :len
	repeat 4 [fd :len rt 90]
end