001/*
002 * Renderer Models. The MIT License.
003 * Copyright (c) 2022 rlkraft@pnw.edu
004 * See LICENSE for details.
005*/
006
007package renderer.models_L.turtlegraphics;
008
009import renderer.scene.Model;
010
011/**
012
013*/
014public class PentagasketTurtle extends Turtle
015{
016   /**
017      @param model  a reference to the {@link Model} that this {@code Turtle} is builing
018      @param n      number of levels for the Pentagasket
019   */
020   public PentagasketTurtle(final Model model, final int n)
021   {
022      this(model, n, 0.0, 0.0, 0.0);
023   }
024
025
026   /**
027      @param model  a reference to the {@link Model} that this {@code Turtle} is builing
028      @param n      number of levels for the Pentagasket
029      @param xPos   the intial x-coordinate for this {@link Turtle}
030      @param yPos   the intial y-coordinate for this {@link Turtle}
031   */
032   public PentagasketTurtle(final Model model, final int n,
033                            final double xPos, final double yPos)
034   {
035      this(model, n, xPos, yPos, 0.0);
036   }
037
038
039   /**
040      @param model  a reference to the {@link Model} that this {@code Turtle} is builing
041      @param n      number of levels for the Pentagasket
042      @param xPos   the intial x-coordinate for this {@link Turtle}
043      @param yPos   the intial y-coordinate for this {@link Turtle}
044      @param z      the z-plane for this {@code Turtle}
045   */
046   public PentagasketTurtle(final Model model, final int n,
047                            double xPos, double yPos, double z)
048   {
049      super(model, xPos, yPos, z);
050      pentagasket(n);
051   }
052
053
054   private void pentagasket(final int level)
055   {
056      if (0 == level)
057      {
058         // draw a pentagon
059         for (int i = 0; i < 5; ++i)
060         {
061            forward(1);
062            turn(72);
063         }
064      }
065      else
066      {
067         for (int i = 0; i < 5; ++i)
068         {
069            resize(0.5);
070            pentagasket(level - 1);
071            resize(2.0);
072            move(1);
073            turn(72);
074         }
075      }
076   }
077
078}//PentagasketTurtle