;;; -*- logo -*-

;; a logo for logo written in logo ;-)
;; version 0.1
;; by AKFoerster

Make "Startup [UCBLogo  wait 300  ucblogo.reset]

to ucblogo.reset
  cs
  SetPen [pendown paint [0 0] 7 [-1]]
  setbg 0
  clearScreen ShowTurtle
  Wrap
  TextScreen
  erase [ucblogo ucblogo.DrawUCBLogo ucblogo.StartPos ucblogo.DrawUCB]
  erase [ucblogo.DrawLogo ucblogo.LetterSpace ucblogo.HalfWidth ucblogo.Next]
  erase [ucblogo.DrawU ucblogo.DrawC ucblogo.DrawB]
  erase [ucblogo.DrawL ucblogo.DrawO ucblogo.DrawG ucblogo.reset]
  ern "Startup
  end

;; Homeposition: Turtle at bottom/center of letter/Line

to UCBLogo
  Localmake "Title word "Berkeley\ Logo\ version\   :LogoVersion

  Localmake "LetterHeight 70
  Localmake "LetterWidth 30
  Localmake "LetterSpace 25
  Localmake "HalfLineSpace 15
  Localmake "MyPenSize 10

  Localmake "FontColor 4
  Localmake "ShadowColor 0
  Localmake "BorderColor 2
  Localmake "FillColor 6
  Localmake "LabelColor 0

  ;; just guessing: (!!!)
  Localmake "LabelLetterWidth ifelse equalp LogoPlatform "Windows [4] [3]

  HideTurtle ClearScreen Window FullScreen
  setPenSize list :MyPenSize :MyPenSize
  
  ;; Background
  ;; "Q should also be dependant on "LetterHeight (!!!)
  localMake "Q Product ucblogo.LetterSpace 4
  
  setbg :fillcolor
  setpc 0
  fill
  setPenColor :BorderColor
  PenUp
  setXY :Q  0
  PenDown
  setXY 0  :Q
  setXY -:Q  0
  setXY 0  -:Q
  setXY :Q  0
  PenUp 
  Home setPenColor :FillColor fill

  ;; shadow
  setXY :myPenSize*0.7  -:myPenSize*0.7
  setPenColor :ShadowColor
  ucblogo.DrawUCBLogo
  
  ;; coloured Logo
  Home
  setPenColor :FontColor
  ucblogo.DrawUCBLogo

  ;; Label - doesn't work on windows (!!!)
  PenUp
  Home
  Back :LetterHeight
  repeat 3 [Back :HalfLineSpace]
  setPenColor :LabelColor
  setX minus product count :Title :LabelLetterWidth
  setPenSize [1 1]
  label :Title

  wait 30
  setx 0
  fd 15
  rt 120
  setpc :FontColor
  setPenSize [7 7]
  pd arc 120 :LetterHeight pu
  seth 0 bk 30 setx -20 pd fd 2 bk 2 pu setx 20 pd fd 2 bk 2 pu

  print :Title
  end
  
to ucblogo.DrawUCBLogo
  localMake "HomePos Pos

  PenUp
  SetHeading 0
  Forward :HalfLineSpace
  ucblogo.DrawUCB
  
  setPos :HomePos
  SetHeading 0
  PenUp
  back :HalfLineSpace
  back :LetterHeight
  ucblogo.DrawLogo
  end

to ucblogo.StartPos "Letters
  ;; assume Turtle in center of text
  PenUp
  setheading 270
  Forward quotient ( product :Letters ucblogo.LetterSpace ) 2
  back quotient ucblogo.LetterSpace 2
  wait 30
  end
  
to ucblogo.DrawUCB
  ucblogo.StartPos 3
  ucblogo.DrawU ucblogo.Next
  ucblogo.DrawC ucblogo.Next
  ucblogo.DrawB
  end
  
to ucblogo.DrawLogo
  ucblogo.StartPos 4
  ucblogo.DrawL ucblogo.Next
  ucblogo.DrawO ucblogo.Next
  ucblogo.DrawG ucblogo.Next
  ucblogo.DrawO
  end

to ucblogo.LetterSpace
  output sum :LetterWidth :LetterSpace
  end
  
to ucblogo.HalfWidth
  output quotient :LetterWidth 2
  end
  
to ucblogo.Next
  PenUp
  setheading 90
  Forward ucblogo.LetterSpace
  wait 30
  end

to ucblogo.DrawU
  ;; lower arc
  setheading 0
  PenUp
  Forward ucblogo.HalfWidth
  Right 90
  PenDown
  arc 180 ucblogo.HalfWidth

  ;; Right side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Left 90
  Forward difference :LetterHeight ucblogo.HalfWidth
  
  ;; Left side
  PenUp
  Left 90
  Forward :LetterWidth
  PenDown
  Left 90
  Forward difference :LetterHeight ucblogo.HalfWidth
  
  ;; Move to Homeposition
  PenUp
  Forward ucblogo.HalfWidth
  Left 90
  Forward ucblogo.HalfWidth
  end

to ucblogo.DrawC
  ;; lower arc
  setheading 0
  PenUp
  Forward ucblogo.HalfWidth
  Right 90
  PenDown
  arc 180 ucblogo.HalfWidth

  ;; Right side
  PenUp
  Forward ucblogo.HalfWidth
  Left 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; upper arc
  PenUp
  Left 90
  Forward ucblogo.HalfWidth
  PenDown
  arc 180 ucblogo.HalfWidth
  
  ;; Left side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Left 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; Move to Homeposition
  PenUp
  Forward ucblogo.HalfWidth
  Left 90
  Forward ucblogo.HalfWidth
  end

to ucblogo.DrawB
  localMake "QuaterHeight Quotient :LetterHeight 4
  
  ;; Move to startposition
  setheading 270
  PenUp
  ;; the width is equal :QuaterHeight 
  Forward Quotient :QuaterHeight 2
  
  ;; Draw
  PenDown
  Right 90
  Forward :LetterHeight
  back :QuaterHeight
  arc 175 :QuaterHeight
  back :QuaterHeight
  back :QuaterHeight
  arc 175 :QuaterHeight
  
  ;; Move to Homeposition
  PenUp
  back :QuaterHeight
  Right 90
  Forward Quotient :QuaterHeight 2
  end

to ucblogo.DrawL  
  ;; Move to top of L
  setheading 270
  PenUp 
  Forward ucblogo.HalfWidth
  Right 90
  Forward :LetterHeight
  Right 180
  
  ;; Draw
  PenDown
  Forward :LetterHeight
  Left 90
  Forward :LetterWidth
  
  ;; Move to Homeposition
  PenUp
  back ucblogo.HalfWidth
  end
  
to ucblogo.DrawO
  ;; lower arc
  setheading 0
  PenUp
  Forward ucblogo.HalfWidth
  Right 90
  PenDown
  arc 180 ucblogo.HalfWidth

  ;; Right side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Left 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; upper arc
  PenUp
  Left 90
  Forward ucblogo.HalfWidth
  PenDown
  arc 180 ucblogo.HalfWidth
  
  ;; Left side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Left 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; Move to Homeposition
  PenUp
  Forward ucblogo.HalfWidth
  Left 90
  Forward ucblogo.HalfWidth
  end

to ucblogo.DrawG
  ;; lower arc
  setheading 0
  PenUp
  Forward ucblogo.HalfWidth
  Right 90
  PenDown
  arc 180 ucblogo.HalfWidth

  ;; Right side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Right 90
  Forward ucblogo.HalfWidth back ucblogo.HalfWidth
  Right 90
  Forward ucblogo.HalfWidth back ucblogo.HalfWidth
  PenUp
  Right 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; upper arc
  PenUp
  Left 90
  Forward ucblogo.HalfWidth
  PenDown
  arc 180 ucblogo.HalfWidth
  
  ;; Left side
  PenUp
  Forward ucblogo.HalfWidth
  PenDown
  Left 90
  Forward difference :LetterHeight :LetterWidth
  
  ;; Move to Homeposition
  PenUp
  Forward ucblogo.HalfWidth
  Left 90
  Forward ucblogo.HalfWidth
end
