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 https://michael0x2a.com/blog/turtle-examples#example-8-jumping-around-and-changing-speed 013*/ 014public class NinjaTurtle extends Turtle 015{ 016 /** 017 @param model a reference to the {@link Model} that this {@code Turtle} is builing 018 @param n number of radial lines 019 */ 020 public NinjaTurtle(final Model model, 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 radial lines 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 NinjaTurtle(final Model model, 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 radial lines 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 NinjaTurtle(final Model model, int n, 047 final double xPos, final double yPos, double z) 048 { 049 super(model, xPos, yPos, z); 050 ninja(n); 051 } 052 053 054 private void ninja(final int n) 055 { 056 for (int i = 0; i < n; ++i) 057 { 058 forward(1.0); 059 turn(30); 060 forward(0.2); 061 turn(-60); 062 forward(0.5); 063 turn(30); 064 065 penUp(); 066 moveTo(xHome, yHome); 067 penDown(); 068 069 turn(360 / n); 070 } 071 } 072 073}//NinjaTurtle