Package TurtleGraphics

Similar documents
A Guide to the TurtleGraphics Package for R

Python 3 Turtle graphics. Lecture 24 COMPSCI111/111G SS 2017

Package PetfindeR. R topics documented: May 22, Type Package Title 'Petfinder' API Wrapper Version Author Aaron Schlegel

1 Turtle Graphics Concepts

Fractal. Fractals. L- Systems 1/17/12

Recursion with Turtles

Writing Simple Procedures Drawing a Pentagon Copying a Procedure Commanding PenUp and PenDown Drawing a Broken Line...

Reference Guide Playful Invention Company

Lecture 1: Turtle Graphics. the turtle and the crane and the swallow observe the time of their coming; Jeremiah 8:7

Code, Draw, and 3D-Print with Turtle Tina

PYTHON FOR KIDS A Pl ayfu l I ntrodu ctio n to Prog r am m i ng J a s o n R. B r i g g s

Turtle Ballet: Simulating Parallel Turtles in a Nonparallel LOGO Version. Erich Neuwirth

Lab 10: Color Sort Turtles not yet sorted by color

5 State of the Turtles

6. 1 Leaping Lizards!

Recursion with Turtles

Scratch Lesson Plan. Part One: Structure. Part Two: Movement

Maze Game Maker Challenges. The Grid Coordinates

Lab 7: Experimenting with Life and Death

In this project you will use loops to create a racing turtle game and draw a race track.

The City School. Learn Create Program

SEDAR31-DW30: Shrimp Fishery Bycatch Estimates for Gulf of Mexico Red Snapper, Brian Linton SEDAR-PW6-RD17. 1 May 2014

Lab 5: Bumper Turtles

Half-Lives of Antibiotics

Activity 1: Changes in beak size populations in low precipitation

Geometry from Scratch

HALE SECURITY PET DOOR CAT GUARDIAN patent pending

Grade: 8. Author: Hope Phillips

Lab 6: Energizer Turtles

Hello Scratch! by Gabriel Ford, Sadie Ford, and Melissa Ford. Sample Chapter 3. Copyright 2018 Manning Publications

The Effect of Phase Shifts in the Day-Night Cycle on Pigeon Homing at Distances of Less than One Mile

Comparative Evaluation of Online and Paper & Pencil Forms for the Iowa Assessments ITP Research Series

Biology 164 Laboratory

AKC Rally More Advanced Signs

Scratch. To do this, you re going to need to have Scratch!

CS108L Computer Science for All Module 7: Algorithms

Grade 5 English Language Arts

Workbook. Version 3. Created by G. Mullin and D. Carty

Dasher Web Service USER/DEVELOPER DOCUMENTATION June 2010 Version 1.1

~~~***~~~ A Book For Young Programmers On Scratch. ~~~***~~~

StarLogo Complete Command List (Edited and reformatted by Nicholas Gessler, 6 June 2001.)

All Dogs Parkour Exercises (Interactions) updated to October 6, 2018

SUBNOVICE OBJECTIVES. Successful completion of this class means that the following objectives were obtained:

The Lost Treasures of Giza

Code Documentation MFA (Movable Finite Automata) Eric Klemchak CS391/CS392

Getting Started! Searching for dog of a specific breed:

Elicia Calhoun Seminar for Mobility Challenged Handlers PART 3

SUGGESTED LEARNING STRATEGIES:

Teaching Assessment Lessons

COMPARING DNA SEQUENCES TO UNDERSTAND EVOLUTIONARY RELATIONSHIPS WITH BLAST

3. $ rosrun turtlesim turtlesim_node (See the turtle with Blue Background leave terminal window running and view turtle)

RUBBER NINJAS MODDING TUTORIAL

The FCI Initiative for Young Dog Lovers Worldwide. Basic recomendations ORGANIZING YOUTH ACTIVITIES FOR CYNOLOGICAL VENUES.

GEOG 490/590 SPATIAL MODELING SPRING 2015 ASSIGNMENT 3: PATTERN-ORIENTED MODELING WITH AGENTS

09/17/18 1 Turtlesim Cheat Sheet pages (PG) in book ROS Robotics By Example 2nd, Fairchild and Harman

Level 2 Signs with Explanations A4.indd 1 09/04/ :35:50

Grandparents U, 2018 Part 2

Required and Recommended Supporting Information for IUCN Red List Assessments

Math 506 SN. Competency Two Uses Mathematical Reasoning. Mathematics Science Option. Secondary 5. Student Booklet

THE EFFECT OF DISTRACTERS ON STUDENT PERFORMANCE ON THE FORCE CONCEPT INVENTORY

General Judging Standards & Course Design for UKI

Florida Fish and Wildlife Conservation Commission Fish and Wildlife Research Institute Guidelines for Marine Turtle Permit Holders

Getting Started with Java Using Alice. 1 Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Finch Robot: snap levels 1-3

AKC Trick Dog EVALUATOR GUIDE

The Cat Sentence-Building Exercise 1

A Creature Went Walking A Lesson for Gr. 4-6

Subdomain Entry Vocabulary Modules Evaluation

Lab 7. Evolution Lab. Name: General Introduction:

Discussion and Activity Guide for. Nobody s Cats: How One Little Black Kitty Came in from the Cold Written by Valerie Ingram & Alistair Schroff

Maps Chris Piech CS106A, Stanford University. Piech, CS106A, Stanford University

Machine Learning.! A completely different way to have an. agent acquire the appropriate abilities to solve a particular goal is via machine learning.

Where the Red Fern Grows: A 4 th Grade Literary Focus Unit Created by Allison Kesteloot

Biol 160: Lab 7. Modeling Evolution

Elicia Calhoun Seminar for Mobility Challenged Handlers PART 2

Multi-Frequency Study of the B3 VLA Sample. I GHz Data

VETERINARY SCIENCE CURRICULUM. Unit 1: Safety and Sanitation

Microsoft Dexterity. Comprehensive Index Release 12

Our class had 2 incubators full of eggs. On day 21, our chicks began to hatch. In incubator #1, 1/3 of the eggs hatched. There were 2 chicks.

Math 290: L A TEXSeminar Week 10

Sketch Out the Design

Andy Hartman Director of Agility. August, Dear Agility Judges:

Two-queen colony management

Help the Scratch mascot avoid the space junk and return safely back to Earth! Start a new Scratch project. You can find the online Scratch editor at

CAPABILITIES AND RESTRICTIONS OF ORTHOPHOTO PROCUCTION SYSTEMS FOR TERRESTRIAL ARCHAEOLOGICAL SURVEYS

Do the traits of organisms provide evidence for evolution?

Timing is Everything By Deborah Palman

ESWDA. Police Service Test

Handling missing data in matched case-control studies using multiple imputation

A few other notes that may be of use.

Supplementary Fig. 1: Comparison of chase parameters for focal pack (a-f, n=1119) and for 4 dogs from 3 other packs (g-m, n=107).

A New Twist on Training

Name: Date: Algebra I - Unit 3, Lesson 4: Writing and Graphing Inequalities to Represent Constraints

DELTA INBOUNDS. Owner s Manual

Rear Crosses with Drive and Confidence

Virtual Dog Program in Scratch. By Phil code-it.co.uk

Trapped in a Sea Turtle Nest

Dog Years Dilemma. Using as much math language and good reasoning as you can, figure out how many human years old Trina's puppy is?

November Final Report. Communications Comparison. With Florida Climate Institute. Written by Nicole Lytwyn PIE2012/13-04B

Muppet Genetics Lab. Due: Introduction

Transcription:

Version 1.0-7 Date 2017-10-23 Title Turtle Graphics Suggests knitr VignetteBuilder knitr Depends R (>= 3.0), grid Package TurtleGraphics October 23, 2017 An implementation of turtle graphics <http://en.wikipedia.org/wiki/turtle_graphics>. Turtle graphics comes from Papert's language Logo and has been used to teach concepts of computer programming. License GPL (>= 3) URL http://www.gagolewski.com/software/turtlegraphics/ BugReports https://github.com/gagolews/turtlegraphics/issues RoxygenNote 6.0.1 NeedsCompilation no Author Anna Cena [aut], Marek Gagolewski [aut], Marcin Kosinski [aut], Natalia Potocka [aut], Barbara Zogala-Siudem [aut, cre] Maintainer Barbara Zogala-Siudem <zogala@rexamine.com> Repository CRAN Date/Publication 2017-10-23 20:40:56 UTC R topics documented: TurtleGraphics-package................................... 2 turtle_do........................................... 3 turtle_getpos........................................ 4 turtle_goto.......................................... 4 1

2 TurtleGraphics-package turtle_init.......................................... 5 turtle_move......................................... 6 turtle_param......................................... 7 turtle_reset......................................... 8 turtle_show......................................... 9 turtle_status......................................... 9 turtle_turn.......................................... 10 turtle_up........................................... 11 Index 12 TurtleGraphics-package Turtle Graphics in R Learn computer programming while having a jolly time Move the Turtle with commands that are relative to its own position, e.g., "move forward 100 pixels" or "turn right 30 degrees". From these building blocks you can build more complex shapes like circles, fractals, etc. Combined with R control flow, functions, and recursion, the idea of Turtle graphics allows students to get familiar with computer programming in a very accessible and pleasant way. Author(s) Anna Cena [aut] Marek Gagolewski [aut] Marcin Kosinski [aut] Natalia Potocka [aut] Barbara Zogala-Siudem [aut, cre] Other TurtleGraphics: turtle_do, turtle_getpos, turtle_goto, turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up

turtle_do 3 turtle_do Evaluate a Larger Portion of Turtle Drawing Code turtle_do evaluates an R expression with the Turtle temporarily hidden (for performance reasons). turtle_do(expr) Arguments expr expression to evaluate The terrarium must be initialized prior to using these functions, see turtle_init. In order to decrease the evaluation time of expr, it is evaluated with Turtle temporarily hidden. Basically it means that if a Turtle image is visible (see turtle_show and turtle_hide) turtle_do removes it, evaluates expr and redraws it on the function exit. Other TurtleGraphics: TurtleGraphics-package, turtle_getpos, turtle_goto, turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up turtle_do({ for (i in 1:4) { turtle_forward(50) turtle_right(90) } })

4 turtle_goto turtle_getpos Get the Turtle s Current Position and Direction Value turtle_getpos returns the Turtle s current position on the plane. turtle_getangle returns the Turtle s current direction, in degrees. An angle of 0 represents a north-facing Turtle. turtle_getpos() turtle_getangle() The terrarium must be initialized prior to using these functions, see turtle_init. Both functions return a (named) numeric vector. turtle_getpos returns a vector of length two which specifies the x and y coordinates. The turtle_getangle returns the angle. Other TurtleGraphics: TurtleGraphics-package, turtle_do, turtle_goto, turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up turtle_getpos()["x"] # x coordinate turtle_getpos()["y"] # y coordinate turtle_goto Set the Turtle s Position and Direction turtle_goto and turtle_setpos move the Turtle to a given location without changing its direction. turtle_setangle rotates the Turtle to a given (absolute) angle, where 0 denotes a north-facing Turtle.

turtle_init 5 turtle_goto(x, y) turtle_setpos(x, y) turtle_setangle(angle) Arguments x, y numeric; coordinates specifying new Turtle s location. angle numeric; rotation angle in degrees. The terrarium must be initialized prior to using these functions, see turtle_init. If the given location (x, y) lies outside the terrarium, the behavior of these functions depends on the mode argument in turtle_init. turtle_goto may draw the path between the current Turtle s position and the new location. Its behavior depends on the current plot settings, see turtle_up, turtle_down. In case of turtle_setpos, however, the path drawing is always disabled. Other TurtleGraphics: TurtleGraphics-package, turtle_do, turtle_getpos, turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up turtle_init Set Up a New, Shiny Terrarium This function creates a new empty plot with the Turtle centered on the board and facing to the north. turtle_init(width = 100, height = 100, mode = c("error", "clip", "cycle")) Arguments width height mode numeric; plot width. numeric; plot height. character string; one of "error", "clip", or "cycle".

6 turtle_move The mode argument determines what happens if the Turtle tries to move outside the terrarium. clip allows it to do that, but the drawing will be clipped to the predefined plot region. error throws an error. cycle makes the Turtle appear on the other side of the board. After the function has been called you can e.g. move the Turtle with the turtle_forward function, turn its direction with turtle_right or set display parameters of the Turtle s trace, see turtle_param. turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up turtle_move Move the Turtle Forward or Backward turtle_forward moves the Turtle in forward direction and turtle_backward moves the Turtle back. turtle_move(distance, direction = c("forward", "backward")) turtle_forward(distance) turtle_backward(distance) Arguments distance direction single numeric value; specifies the distance to make. Negative distance results in moving in the opposite direction. character string; moving direction. One of "forward" or "backward". The Turtle must be initialized prior to using these functions, see turtle_init. These functions make use of the Turtle s display options specified by the turtle_param function (or if not, use the default options set by turtle_init). Note that if turtle_up or turtle_down was called, the Turtle s trace will be or not be drawn, respectively. If you are willing to call these functions in an R loop, you may want to hide the Turtle temporarily (see turtle_hide and turtle_do) before making actual moves. This will increase the drawing performance significantly.

turtle_param 7 turtle_init, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up turtle_left(30) turtle_forward(2) turtle_up() turtle_forward(1) turtle_down() turtle_right(60) turtle_forward(9) turtle_param Set Display Options Sets the display options for the Turtle s trace. It is possible to change its color, line type and line width. turtle_param(col = NULL, lwd = NULL, lty = NULL) turtle_col(col) turtle_lwd(lwd) turtle_lty(lty) Arguments col lwd lty numeric or character; trace color, see e.g. colors and gpar. numeric; trace line width, see gpar. numeric; trace line type, see gpar. The Turtle must be initialized prior to using this function, see turtle_init. turtle_init, turtle_move, turtle_reset, turtle_show, turtle_status, turtle_turn, turtle_up

8 turtle_reset turtle_forward(5) turtle_up() turtle_forward(3) turtle_down() turtle_left(90) turtle_forward(5) turtle_param(col = "red", lwd = 2, lty = 2) turtle_forward(5) turtle_reset Reset the Turtle s Position and Direction This function resets the Turtle s position, direction, and graphical options. turtle_reset() The Turtle must be initialized prior to using this function, see turtle_init. After a call to this function, the Turtle will be placed in the terrarium s center and it will be directed to the north. The drawing remains unchanged. turtle_init, turtle_move, turtle_param, turtle_show, turtle_status, turtle_turn, turtle_up turtle_forward(4) turtle_param(col="red", lty=2, lwd=3) turtle_reset() turtle_left(45) turtle_forward(3)

turtle_show 9 turtle_show Show or Hide the Turtle These functions enable or disable displaying the Turtle s image on the screen. turtle_show() turtle_hide() The Turtle must be initialized prior to using this function, see turtle_init. It is recommended to hide the Turtle when performing multiple Turtle moves, for efficiency reasons, see also turtle_do. turtle_init, turtle_move, turtle_param, turtle_reset, turtle_status, turtle_turn, turtle_up turtle_forward(4) turtle_hide() turtle_left(30) turtle_forward(3) turtle_status Read the Turtle s Status This function gives information about the current Turtle s position, direction, and on display options. turtle_status()

10 turtle_turn The Turtle must be initialized prior to using this function, see turtle_init. Value Returns a list with three elements. turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_turn, turtle_up turtle_turn Turn (Rotate) the Turtle Turn the Turtle in the given direction by the given angle. turtle_turn(angle, direction = c("left", "right")) turtle_left(angle) turtle_right(angle) Arguments angle direction single numeric value; rotation angle in degrees. A negative value turns the Turtle in the opposite direction than the given one. character string; direction of the turn. Possible values are "left" and "right". The Turtle must be initialized prior to using this function, see turtle_init. turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_up turtle_left(30) # equivalent to turtle_turn(30, "left") turtle_right(40) turtle_turn(30, sample(c("left", "right"), 1)) # random turn

turtle_up 11 turtle_up Turn on or off Turtle Trace Drawing When the Turtle moves, it may or may not leave a visible trace. These functions control such a behavior. turtle_up() turtle_down() The Turtle must be initialized prior to using this function, see turtle_init. turtle_init, turtle_move, turtle_param, turtle_reset, turtle_show, turtle_status, turtle_turn

Index colors, 7 gpar, 7 turtle_backward (turtle_move), 6 turtle_col (turtle_param), 7 turtle_do, 2, 3, 4 11 turtle_down, 5, 6 turtle_down (turtle_up), 11 turtle_forward, 6 turtle_forward (turtle_move), 6 turtle_getangle (turtle_getpos), 4 turtle_getpos, 2, 3, 4, 5 11 turtle_goto, 2 4, 4, 6 11 turtle_hide, 3, 6 turtle_hide (turtle_show), 9 turtle_init, 2 5, 5, 6 11 turtle_left (turtle_turn), 10 turtle_lty (turtle_param), 7 turtle_lwd (turtle_param), 7 turtle_move, 2 6, 6, 7 11 turtle_param, 2 7, 7, 8 11 turtle_reset, 2 7, 8, 9 11 turtle_right, 6 turtle_right (turtle_turn), 10 turtle_setangle (turtle_goto), 4 turtle_setpos (turtle_goto), 4 turtle_show, 2 8, 9, 10, 11 turtle_status, 2 9, 9, 10, 11 turtle_turn, 2 10, 10, 11 turtle_up, 2 10, 11 TurtleGraphics-package, 2 12