Art & Programming
Dance Code
Introduction:
Since most jobs are collaborative in nature and coding is involved, prospective employers appreciate it when art students understand the mechanics and basic terminology and logistics of coding. This project involved collaboration. We combined talents to visualize ideas behind programming by applying connections with visual and performing arts. Writing a code involves applying certain steps into a sequence to achieve a goal. Dancing a particular dance is also based on following sequences following some pattern. This way we facilitated learning how to write programs by translating selected dance performances into computing codes. In this innovative task we constructed a knowledge-based set of learning projects by creating metaphors between the dance steps and steps in computer programs – lists of instructions written in order to tell a computer what task it should perform. The results of this phase are videos (at the end of this page), which will be translated into the dance performances, then recorded to obtain the time-based and graphical data. Videos and graphics were developed to serve as visual tools for learning programming as they will carry information with explanatory power.
This project offers and provides materials for students in Computer Graphics, Media, Digital Media to become familiar with some principles of coding, which is often demanded or requested by many prospective employers. There is a global need to help art students not being afraid of coding as it improves company's communication between the artists and the coders and bridge the gap between artists and the coders on the job. Collaboration skills are expected from students by their prospective employees.
Credits for the performance
Campus Commons Performance Hall (CCPH) stage, https://arts.unco.edu/campus-commons/
Anna Ursyn, Computer Graphics, UNC - Concept, Story, Directing, Video recording and Editing, Stage Design, and Codes with Outputs
Stuart Smith, Music and Computer Science, University of Massachusetts Lowell - Music, and Codes with Outputs
Brian Luedloff, Professor of Music, Director of Opera Theater, School of Music, UNC, and Advising, Organizing, Consulting, and Managing
Mohammad Majid al-Rifaie, Associate Professor in Artificial Intelligence, University of Greenwich London, United Kingdom
Md Fahim Islam JPMorgan Chase, Chicago, IL. - Codes with Outputs
Md. Asifur Rahman, Infozillion Teletech BD, Dhaka, Bangladesh, Codes with Outputs
Kim Clay, Assistant Professor of Dance, School of Theater Arts and Dance, UNC – dancing, leading ballet students
Mary Jo Lasky, student of Digital Media, UNC - Dancing at the Campus Commons Performance Hall (CCPH) stage.
Isabella Sajdak, Student of Digital Media, Art&Design, at UNC - Dancing, Drawing, Animation, Voice Recording, Singing, Reciting In the Music Studios labs, developed animations, videos, and recorded voices.
Adam Alduaij, Student of Graphic Design, Art&Design, UNC - Filming, Voice Recording
Jennifer Wagner, graduate student (MM) of Vocal Performance, UNC - reading script, acting, singing
Silas Vasquez, student of Musical Theater Department, UNC - reading script, acting, dancing
Brandon Ingold, Technical Director, PVA, CCPH), UNC - Stage Technical Assistance
Students from the Department of Dance - Dancing at the CCPH with their professor:
Spencer Bowman, Musical Theater and Dance Minor
Lauren Greiner, Musical Theater and Dance Minor
Joslyn Joseph, Dance and Theater major
Sabrina Patten, Musical Theater
Jeremiah Ulufanua, Musical Theater
Many thanks to everyone who participated in those collaborative endeavors.
This project supports transforming STEM into STEAM (http://stemtosteam.org) and fits into a STREAM movement.
What is Coding: Coding 101 tutorial:
https://www.bitdegree.org/tutorials/what-is-coding/
Coding:
Dance Simulator by Md Asifur Rahman
How to run:
python3 main.py
main.py
import turtle, time
from steps import *
"""
Set DANCE_INSTRUCTION
"""
DANCE_INSTRUCTION = FOXTROT_LADY by Mohammad Majid al-Rifaie
"""
Settings
"""
STEP_SIZE = 61
SCREEN_H = STEP_SIZE * 10
SCREEN_W = STEP_SIZE * 10
FOOT_RAD = STEP_SIZE//2
STEP_SPEED = 1 # 1:slowest to 10:fast, 0:fastest
FLOOR_COLOR = "white"
def wait(sec):
start = time.time()
while time.time() < start + sec:
pass
def draw_grid(floor_scr):
tur = turtle.Turtle()
tur.color("grey")
floor_scr.tracer(0)
tur.hideturtle()
for i in range(-SCREEN_H//2, SCREEN_H + STEP_SIZE, STEP_SIZE):
tur.up()
tur.goto(-SCREEN_W//2, -SCREEN_H//2 + i)
tur.down()
tur.forward(SCREEN_W)
tur.left(90)
for i in range(-SCREEN_W//2, SCREEN_W + STEP_SIZE, STEP_SIZE):
tur.up()
tur.goto(-SCREEN_W//2 + i, -SCREEN_H//2)
tur.down()
tur.forward(SCREEN_W)
floor_scr.update()
def init_foot_pos(feet):
font_size = 12
dance_floor.tracer(0)
feet["l"]["foot"].up()
feet["l"]["foot"].goto(-3 * STEP_SIZE//4, 3*STEP_SIZE//4)
feet["l"]["foot"].down()
feet["l"]["foot"].dot(FOOT_RAD, feet["l"]["color"])
cur_x = feet["l"]["foot"].xcor()
cur_y = feet["l"]["foot"].ycor()
feet["l"]["foot"].up()
feet["l"]["foot"].goto(cur_x, cur_y - font_size // 2)
feet["l"]["foot"].pencolor(feet["l"]["label_color"])
feet["l"]["foot"].write(feet["l"]["label"], font=('arial', font_size, 'bold'), align='center')
feet["l"]["foot"].up()
feet["l"]["foot"].goto(cur_x, cur_y)
feet["r"]["foot"].up()
feet["r"]["foot"].goto( STEP_SIZE//4, 3*STEP_SIZE//4)
feet["r"]["foot"].down()
feet["r"]["foot"].dot(FOOT_RAD, feet["r"]["color"])
cur_x = feet["r"]["foot"].xcor()
cur_y = feet["r"]["foot"].ycor()
feet["r"]["foot"].up()
feet["r"]["foot"].goto(cur_x, cur_y - font_size // 2)
feet["r"]["foot"].pencolor(feet["r"]["label_color"])
feet["r"]["foot"].write(feet["r"]["label"], font=('arial', font_size, 'bold'), align='center')
feet["r"]["foot"].up()
feet["r"]["foot"].goto(cur_x, cur_y)
def move(floor_scr, step_no, feet, direction):
cur_x = new_x = feet["foot"].xcor()
cur_y = new_y = feet["foot"].ycor()
for i, d in enumerate(direction):
if d == "l": new_x = new_x - STEP_SIZE
if d == "r": new_x = new_x + STEP_SIZE
if d == "f": new_y = new_y + STEP_SIZE
if d == "b": new_y = new_y - STEP_SIZE
floor_scr.tracer(0)
feet["foot"].pencolor(feet["color"])
feet["foot"].up()
feet["foot"].goto(new_x, new_y)
if i == len(direction) - 1:
floor_scr.tracer(0)
feet["foot"].up()
feet["foot"].goto(cur_x, cur_y)
floor_scr.tracer(1)
feet["foot"].down()
feet["foot"].goto(new_x, new_y)
floor_scr.tracer(0)
feet["foot"].dot(FOOT_RAD, feet["color"])
font_size = 12
feet["foot"].goto(new_x, new_y - font_size // 2)
feet["foot"].pencolor(feet["label_color"])
feet["foot"].write(str(step_no), font=('arial', font_size, 'bold'), align='center')
feet["foot"].up()
feet["foot"].goto(new_x, new_y)
def dance(floor_scr, feet, steps):
for i, step in enumerate(steps):
cur_foot = feet[step[0]]
cur_direction = step[1]
move(floor_scr, i+1, cur_foot, cur_direction)
if __name__ == "__main__":
# set size and color of screen and canvas
dance_floor = turtle.Screen()
dance_floor.setup(width=SCREEN_W + STEP_SIZE, height=SCREEN_H + STEP_SIZE)
dance_floor.title("Dance Step Sim")
dance_floor.screensize(canvwidth=SCREEN_W, canvheight=SCREEN_H)
dance_floor.bgcolor(FLOOR_COLOR)
# draw grid lines
draw_grid(dance_floor)
# set turtle object as foot
foot = {
"l": {
"foot": turtle.Turtle(),
"color": "DeepSkyBlue1",
"label": "L",
"label_color": "black",
},
"r": {
"foot": turtle.Turtle(),
"color": "coral",
"label": "R",
"label_color": "black",
},
}
foot["l"]["foot"].hideturtle()
foot["l"]["foot"].speed(STEP_SPEED)
foot["r"]["foot"].hideturtle()
foot["r"]["foot"].speed(STEP_SPEED)
# set initial foot position
wait(1)
init_foot_pos(foot)
# start dance step animation
wait(1)
dance(dance_floor, foot, DANCE_INSTRUCTION)
# notify user that the steps are completed
wait(1)
foot["l"]["foot"].goto(- SCREEN_W // 2 + 20, - SCREEN_H // 2 + 20)
foot["l"]["foot"].write("Done. Click on screen to exit.", font=('arial', 20, 'bold'), align='left')
turtle.exitonclick()
steps.py
"""
Instruction Syntax:
Feet:
left foot: l
right foot: r
Directions:
move left: l
move right: r
move forward: f
move backward: b
Multiple directions/sidesteps:
move forward-left: fl
move forward-right: fr
move backward-left: bl
move backward-right: br
Format:
List of tuples where each tuple contains two strings,
first one for indicating foot (left/right), and the
second one to indicate movement and direction.
DANCE_NAME_VARIABLE = [
(<foot>,<step>),
(<foot>,<step>),
.
.
(<foot>,<step>)
]
Here,
<foot> can be "l" or "r"
<step> can be "f", "ff", "fl", "bl", "ffl" ...etc
--------------------------------------------------------
Some example dance step is given below:
(Ref: https://www.dancing4beginners.com)
--------------------------------------------------------
"""
Dance Simulator by Md. Asifur Rahman
WALTZ_MEN = [
("l", "f"),
("r", "fr"),
("l", "r"),
("r", "b"),
("l", "bl"),
("r", "l"),
]
WALTZ_LADY = [
("r", "b"),
("l", "bl"),
("r", "l"),
("l", "f"),
("r", "fr"),
("l", "r"),
]
FOXTROT_MEN = [
("l", "f"),
("r", "ff"),
("l", "ffl"),
("r", "fl"),
("l", "b"),
("r", "bb"),
("l", "bbl"),
("r", "bl"),
]
FOXTROT_LADY = [
("r", "b"),
("l", "bb"),
("r", "bbr"),
("l", "br"),
("r", "f"),
("l", "ff"),
("r", "ffr"),
("l", "fr"),
]
CHA_CHA_MEN = [
("l", "l"),
("r", "bl"),
("r", "fr"),
("l", "r"),
("r", "r"),
("l", "fr"),
("l", "bl"),
("r", "l"),
]
CHA_CHA_LADY = [
("r", "r"),
("l", "fr"),
("l", "bl"),
("r", "l"),
("l", "l"),
("r", "bl"),
("r", "fr"),
("l", "r"),
]
SALSA_MEN = [
("l", "f"),
("l", "b"),
("r", "b"),
("r", "f"),
]
SALSA_LADY = [
("r", "b"),
("r", "f"),
("l", "f"),
("l", "b"),
]
TANGO_MEN = [
("l", "f"),
("r", "ff"),
("l", "ff"),
("r", "fr"),
("l", "fr"),
]
TANGO_LADY = [
("r", "b"),
("l", "bb"),
("r", "bb"),
("l", "bl"),
("r", "bl"),
]
RUMBA_MEN = [
("l", "f"),
("r", "fr"),
("l", "r"),
("r", "b"),
("l", "bl"),
("r", "l"),
]
RUMBA_LADY = [
("r", "b"),
("l", "bl"),
("r", "l"),
("l", "f"),
("r", "fr"),
("l", "r"),
]
SAMBA_MEN = [
("l", "f"),
("r", "f"),
("r", "b"),
("l", "b"),
]
SAMBA_LADY = [
("r", "b"),
("l", "b"),
("l", "f"),
("r", "f"),
]
JIVE_MEN = [
("l", "b"),
("l", "fl"),
("r", "l"),
("l", "l"),
("l", "r"),
("r", "r"),
]
JIVE_LADY = [
("r", "b"),
("r", "fr"),
("l", "r"),
("r", "r"),
("r", "l"),
("l", "l"),
]
SWING_MEN = [
("l", "l"),
("r", "l"),
("l", "l"),
("l", "r"),
("r", "r"),
("l", "br"),
]
SWING_LADY = [
("r", "r"),
("l", "r"),
("r", "r"),
("r", "l"),
("l", "l"),
("r", "bl"),
]
Tango Dance Steps in C# by Md. Fahimul Islam
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace DanceGraphics {
public partial class Form1: Form {
int L = 0;
int R = 1;
int x = 0;
int y = 1;
int Step = 0;
int[, , ] xy = new int[, , ] {
{
{
250,
400
}, {
310,
400
}
}, {
{
250,
274
},
{
310,
400
}
}, {
{
250,
274
},
{
310,
190
}
}, {
{
250,
76
},
{
310,
190
}
}, {
{
250,
76
},
{
450,
84
}
}, {
{
400,
76
},
{
450,
84
}
}, {
{
400,
76
},
{
200,
76
}
}, {
{
40,
66
},
{
200,
76
}
}, {
{
40,
66
},
{
100,
76
}
}, {
{
250,
76
},
{
100,
76
}
}, {
{
250,
76
},
{
450,
84
}
}, {
{
400,
76
},
{
450,
84
}
}, {
{
400,
76
},
{
450,
220
}
}
};
public Form1() {
InitializeComponent();
this.Text = "Tango Dance";
}
private void Form1_Load(object sender, EventArgs e) {
this.DoubleBuffered = true;
this.Paint += new PaintEventHandler(Form1_Paint);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) {
e.Graphics.DrawImage(Properties.Resources.LeftFoot, xy[Step, L, x], xy[Step, L, y], 40, 84);
e.Graphics.DrawImage(Properties.Resources.RightFoot, xy[Step, R, x], xy[Step, R, y], 40, 84);
Step++;
if (Step == 13) Step = 0;
}
private void timer1_Tick(object sender, EventArgs e) {
this.Refresh();
}
}
}
Foxtrot Dance Steps in Python by Mohammad Majid al-Rifaie
import turtle # this line makes sure the turtle object can be used
import random # this lines allows the program to generate random numbers when needed
# e.g. in order to decide the step size
import time
screen = turtle.Screen()
screen.screensize(300,300)
screen.colormode(255)
screen.bgcolor(0,0,0)
sleepTime = 0.3
# a function that takes the name of the turtle, the angle at which
# it should be rotated and the distance that it should move
def move(turtle, angle, distance):
turtle.left(angle)
turtle.forward(distance)
# this function takes the turtle name as well as
# the x and y distances that the turtle should move
def moveXY(turtle, dx, dy):
turtle.setpos(turtle.xcor()+dx,
turtle.ycor()+dy)
# four turtles are created
# lM for left foot of the man
# rM for right foot of the man
lM = turtle.Turtle()
rM = turtle.Turtle()
# lW for left foot of the woman
# rW for right foot of the woman
lW = turtle.Turtle()
rW = turtle.Turtle()
lM.hideturtle()
rM.hideturtle()
lW.hideturtle()
rW.hideturtle()
lM.shape("turtle")
rM.shape("turtle")
lW.shape("turtle")
rW.shape("turtle")
lM.showturtle()
rM.showturtle()
lW.showturtle()
rW.showturtle()
# adjust the direction of the foot to make sure that
# the man's feet are facing the woman's feet
move(lW, 90, 0)
move(rW, 90, 0)
move(lM, -90, 0)
move(rM, -90, 0)
screen.delay(10)
# this function takes two numbers (m and n) and generate a random integer number between m and n
def rand(m,n):
random.randint(m,n)
# this function places the feet of the dances in the starting position
def startingPosition():
# the initial position of the feet are marked and the pen is lifted
lM.stamp(); lM.penup()
rM.stamp(); rM.penup()
lW.stamp(); lW.penup()
rW.stamp(); rW.penup()
# a random colour is generated for the man
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
# a random colour is generated for the the woman
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
# initial position of the feet is randomly selected on the dance floor
initX = random.randint(-200,300)
initY = random.randint(-200,300)
# lowe and upper difference allows the feet to be slightly unsynched
# rather than precisely opposite each other
diffLower = 5
diffUpper = 10
lM.goto(initX,initY)
rM.goto(initX-50,initY)
rW.goto(initX+rand(diffLower,diffUpper),
initY-50+rand(diffLower,diffUpper))
lW.goto(initX-50+rand(diffLower,diffUpper),
initY-50+rand(diffLower,diffUpper))
# once the feet at their initial position, the pen of each foot is down
# and ready to show the traces of their feet's movements
lM.pendown()
rM.pendown()
lW.pendown()
rW.pendown()
# setting the the speed at which the dance should take place
screen.delay(0.1)
# this function checks if the feet inside the dance floor
# if not, a new position is generated and the dance starts over
def checkLoc():
if ( rM.ycor() > 300 or rM.ycor() < -300 or
lM.ycor() > 300 or lM.ycor() < -300 or
rW.ycor() > 300 or rW.ycor() < -300 or
lW.ycor() > 300 or lW.ycor() < -300):
startingPosition()
def rand(a,b):
return random.randint(a,b)
# this function performs one full cycle of the basic foxtrot basic dance steps
def foxtrot():
stepSize = rand(100,200) # a random step size is generated for each new cycle
# no. 1
for i in range(stepSize): # the FOR loop allows the relevant feet to move together one unit at a time
moveXY(rW, 0, -1)
moveXY(lM, 0, -1)
checkLoc() # once done, the position of the feet are checked to see that
# they are inside the dance floor, otherwise a new dance starts
time.sleep(sleepTime) # this allows the dancers to stop for a little while to show that once step is complete
#move(lM, 0, 100) # these line allows the fast movement of each foot separately
#move(rW, 0, -100)
# no. 2
for i in range(int(stepSize/2)):
moveXY(rM, 0, -1 )
moveXY(lW, 0, -1 )
checkLoc()
time.sleep(sleepTime)
#move(rM, -45, 100)
#move(lW, 180-45, 100)
# no. 3
for i in range(int(stepSize/4)):
moveXY(lM, 0, -1)
moveXY(rW, 0, -1)
for i in range(stepSize):
moveXY(lM, -1, 0)
moveXY(rW, -1, 0)
checkLoc()
time.sleep(sleepTime)
# no. 4
for i in range(int(stepSize*3/4)):
moveXY(rM, 0, -1 )
moveXY(lW, 0, -1 )
for i in range(int(stepSize)):
moveXY(rM, -1, 0 )
moveXY(lW, -1, 0 )
checkLoc()
time.sleep(sleepTime)
# ======================================
# initially the feet are located in an initial position
startingPosition()
# then the dance starts, in this case 100 cycle of the foxtrot basic step dance
for i in range(100):
foxtrot()
# saving the final image as a pdf file (without the background colour)
screen.getcanvas().postscript(file="Foxtrot.pdf")
Rumba (seq offset) Dance Steps in Python by Mohammad Majid al-Rifaie
import turtle # this line makes sure the turtle object can be used
import random # this lines allows the program to generate random numbers when needed
# e.g. in order to decide the step size
screen = turtle.Screen()
screen.screensize(300,300)
screen.colormode(255)
screen.bgcolor(0,0,0)
# a function that takes the name of the turtle, the angle at which
# it should be rotated and the distance that it should move
def move(turtle, angle, distance):
turtle.left(angle)
turtle.forward(distance)
# this function takes the turtle name as well as
# the x and y distances that the turtle should move
def moveXY(turtle, dx, dy):
turtle.setpos(turtle.xcor()+dx,
turtle.ycor()+dy)
# four turtles are created
# lM for left foot of the man
# rM for right foot of the man
lM = turtle.Turtle()
rM = turtle.Turtle()
# lW for left foot of the woman
# rW for right foot of the woman
lW = turtle.Turtle()
rW = turtle.Turtle()
lM.hideturtle()
rM.hideturtle()
lW.hideturtle()
rW.hideturtle()
# the pens are lifted until the feet are in the starting position
lM.penup()
rM.penup()
lW.penup()
rW.penup()
# the man's feet are blue and woman's feet are red
lM.fillcolor("blue")
rM.fillcolor("blue")
lW.fillcolor("red")
rW.fillcolor("red")
lM.pencolor("blue")
rM.pencolor("blue")
lW.pencolor("red")
rW.pencolor("red")
lM.shape("turtle")
rM.shape("turtle")
lW.shape("turtle")
rW.shape("turtle")
lM.showturtle()
rM.showturtle()
lW.showturtle()
rW.showturtle()
screen.delay(10)
# adjust the direction of the foot to make sure that
# the man's feet are facing the woman's feet
lM.setpos(200,200)
rM.setpos(150,200)
move(lM, -90, 0)
move(rM, -90, 0)
rW.setpos(200,150)
lW.setpos(150,150)
move(lW, 90, 0)
move(rW, 90, 0)
stepSize = 200
# once the feet at their initial position, the pen of each foot is down
# and ready to show the traces of their feet's movements
lM.pendown()
rM.pendown()
lW.pendown()
rW.pendown()
screen.delay(1)
# this function takes two numbers (m and n) and generate a random integer number between m and n
def rand(a,b):
return random.randint(a,b)
# Whenever this functin is called, one full basic rumba movement is executed
def rumba():
# a random colour is generated for the man
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
# a random colour is generated for the the woman
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
stepSize = rand(50,300) # a random step size is generated for each new cycle
r = 2; # this number offsets the location of the feet byt a small distance
# no. 0
move(rW, 720, 0) # turn woman's right foot 720 degrees anti-clockwise
# this is used as an indicated showing that the dance is about to start
# no. 1
# here woman's right foot and then man's left foot are moved along the y axis
moveXY(rW, 0, -stepSize+rand(-r,r))
moveXY(lM, 0, -stepSize+rand(-r,r))
# no. 2
moveXY(rM, -stepSize+rand(-r,r), -stepSize+rand(-r,r) )
moveXY(lW, -stepSize+rand(-r,r), -stepSize+rand(-r,r) )
#move(rM, -45, 100)
#move(lW, 180-45, 100)
# no. 3
moveXY(lM, -stepSize+rand(-r,r), 0)
moveXY(rW, -stepSize+rand(-r,r), 0)
# no. 4
moveXY(rM, 0, stepSize+rand(-r,r) )
moveXY(lW, 0, stepSize+rand(-r,r) )
# no. 5
moveXY(lM, stepSize+rand(-r,r), stepSize+rand(-r,r))
moveXY(rW, stepSize+rand(-r,r), stepSize+rand(-r,r))
# no. 6
moveXY(rM, stepSize+rand(-r,r), 0 )
moveXY(lW, stepSize+rand(-r,r), 0 )
#rM.stamp(); lM.stamp(); rW.stamp(); lW.stamp()
# MAIN
# Here, 100 cycle of the rumba basic step dance is executed
for i in range(100):
rumba()
# saving the final image as a pdf file (without the background colour)
screen.getcanvas().postscript(file="Rumba_couple.pdf")
Rumba (simultaneous) Dance Steps in Python by Mohammad Majid al-Rifaie
import turtle # this line makes sure the turtle object can be used
import random # this lines allows the program to generate random numbers when needed
# e.g. in order to decide the step size
screen = turtle.Screen()
screen.screensize(300,300)
screen.colormode(255)
screen.bgcolor(0,0,0)
# a function that takes the name of the turtle, the angle at which
# it should be rotated and the distance that it should move
def move(turtle, angle, distance):
turtle.left(angle)
turtle.forward(distance)
# this function takes the turtle name as well as
# the x and y distances that the turtle should move
def moveXY(turtle, dx, dy):
turtle.setpos(turtle.xcor()+dx,
turtle.ycor()+dy)
# four turtles are created
# lM for left foot of the man
# rM for right foot of the man
lM = turtle.Turtle()
rM = turtle.Turtle()
# lW for left foot of the woman
# rW for right foot of the woman
lW = turtle.Turtle()
rW = turtle.Turtle()
lM.hideturtle()
rM.hideturtle()
lW.hideturtle()
rW.hideturtle()
# the pens are lifted until the feet are in the starting position
lM.penup()
rM.penup()
lW.penup()
rW.penup()
# the man's feet are blue and woman's feet are red
lM.fillcolor("blue")
rM.fillcolor("blue")
lW.fillcolor("red")
rW.fillcolor("red")
lM.pencolor("blue")
rM.pencolor("blue")
lW.pencolor("red")
rW.pencolor("red")
lM.shape("turtle")
rM.shape("turtle")
lW.shape("turtle")
rW.shape("turtle")
lM.showturtle()
rM.showturtle()
lW.showturtle()
rW.showturtle()
screen.delay(10)
# adjust the direction of the foot to make sure that
# the man's feet are facing the woman's feet
lM.setpos(200,200)
rM.setpos(150,200)
move(lM, -90, 0)
move(rM, -90, 0)
rW.setpos(200,150)
lW.setpos(150,150)
move(lW, 90, 0)
move(rW, 90, 0)
stepSize = 200
# once the feet at their initial position, the pen of each foot is down
# and ready to show the traces of their feet's movements
lM.pendown()
rM.pendown()
lW.pendown()
rW.pendown()
screen.delay(0.00001)
# this function takes two numbers (m and n) and generate a random integer number between m and n
def rand(a,b):
return random.randint(a,b)
# Whenever this functin is called, one full basic rumba movement is executed
def rumba():
# a random colour is generated for the man
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rM.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
# a random colour is generated for the the woman
r = rand(0,255); b = rand(0,255); g = rand(0,255)
lW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
rW.pencolor(r,g,b)#; rM.fillcolor(r,g,b)
stepSize = rand(50,300) # a random step size is generated for each new cycle
# no. 0
move(rW, 720, 0) # turn woman's right foot 720 degrees anti-clockwise
# this is used as an indicated showing that the dance is about to start
# no. 1
for i in range(stepSize): # the FOR loop allows the relevant feet to move together one unit at a time
moveXY(rW, 0, -1)
moveXY(lM, 0, -1)
# no. 2
for i in range(stepSize):
moveXY(rM, -1, -1 )
moveXY(lW, -1, -1 )
# no. 3
for i in range(stepSize):
moveXY(lM, -1, 0)
moveXY(rW, -1, 0)
# no. 4
for i in range(stepSize):
moveXY(rM, 0, 1 )
moveXY(lW, 0, 1 )
# no. 5
for i in range(stepSize):
moveXY(lM, 1, 1)
moveXY(rW, 1, 1)
# no. 6
for i in range(stepSize):
moveXY(rM, 1, 0 )
moveXY(lW, 1, 0 )
#rM.stamp(); lM.stamp(); rW.stamp(); lW.stamp()
# MAIN
# Here, 100 cycle of the rumba basic step dance is executed
for i in range(100):
rumba()
# saving the final image as a pdf file (without the background colour)
screen.getcanvas().postscript(file="Rumba_Couple_simultaneous.pdf")
Tango (solo) Dance Steps in Python by Mohammad Majid al-Rifaie
import turtle # this line makes sure the turtle object can be used
import random # this lines allows the program to generate random numbers when needed
# e.g. in order to decide the step size
screen = turtle.Screen()
screen.screensize(300,300)
screen.colormode(255)
screen.bgcolor(0,0,0)
# the screen is made to be 300x300 with black background
l = turtle.Turtle() # l for left foot
r = turtle.Turtle() # r for right foot
# hiding the left and right foot until they are in their positions
l.hideturtle()
r.hideturtle()
l.penup()
r.penup()
# adjusting the speed and rhythom of the dance
speed = 50
l.speed(speed)
r.speed(speed)
# setting the shape of the feet to turtles
l.shape("turtle")
r.shape("turtle")
# initially the turtle is headed east,
# so they are rotated 90 degrees anti-clockwise to head upward (north)
# and go back 100 unit to be placed in the initial position
l.left(90); l.backward(100)
r.left(90); r.backward(100)
# here the right foot is given a distance from the left one
# (so they don't overlap)
r.right(90); r.forward(30); r.left(90)
# Now that each foot is in its place, they are made visible
l.showturtle()
r.showturtle()
# and the pen is down, so the user see the traces of their movements
l.pendown()
r.pendown()
# a stamp allows the trace of the feet to be printed whenever required
#l.stamp()
#r.stamp()
# Whenever this functin is called, one full basic tango movement is executed
def tango():
# a random colour is generated for the traces of the feet
red = random.randint(0,255)
green = random.randint(0,255)
blue = random.randint(0,255)
l.pencolor(red,green,blue)
r.pencolor(red,green,blue)
# No 1 & 2
l.forward(80) # left moves forward 80 units
r.forward(200) # right moves forward 200 units
#l.stamp()
#r.stamp()
# No 3
l.forward(200)
#l.stamp()
# No 4
r.forward(80)
r.right(90) # right foot is rotated to the right (clockwise) for 90 degrees
r.forward(100) # then it moves forward 100 units
r.left(90) # then rotated 90 degrees anti-clockwise
#r.stamp()
# No 5
l.right(90)
l.forward(100)
l.left(90)
#l.stamp()
# No 6
#r.left(90)
#r.forward(150)
#r.right(90)
r.circle(65, 180) # this lines allows a circle to be drawn showing the arc made during the dance
r.right(180)
#r.stamp()
# No 7
#l.left(90)
#l.forward(200)
#l.right(90)
l.right(180)
l.circle(-100, 180)
#l.stamp()
# No 8
r.left(90)
r.forward(50)
r.right(90)
#r.stamp()
# No 9
#l.right(90)
#l.forward(100)
#l.left(90)
l.circle(-65,180)
l.left(180)
#l.stamp()
# No 10
#r.right(90)
#r.forward(200)
#r.left(90)
r.left(180)
r.circle(110,180)
#r.stamp()
# No 11
l.right(90)
l.forward(100)
l.left(90)
#l.stamp()
# No 12
#r.right(180)
#r.forward(80)
#r.right(180)
r.backward(80)
#r.stamp()
# the FOR loop below makes sure that the lines are called n (n=100) times
for i in range(100):
#l.stamp(); r.stamp()
tango() # this line calls all the steps of tango dance
# once the first round is complete:
# the pen is lifted
l.penup(); r.penup()
# a new dance starts at a random position
# and feet left and right are places within the range of -300 to 300 which
# is the within the dance floor
randX = random.randint(-300,300)
randY = random.randint(-300,300)
l.goto( randX, randY)
r.goto( randX-50, randY)
# the pen is put down again to show the the movement of the feet
l.pendown(); r.pendown()
# saving the final image as a pdf file (without the background colour)
screen.getcanvas().postscript(file="Tango.pdf")
Sequence in Python by Stuart Smith
# SEQUENCE
from turtle import *
from math import *
import time
class Dancer(Turtle):
def __init__(self,x,y):
Turtle.__init__(self)
self.shapesize(2,2,1)
self.pu()
self.speed(0)
def arcright(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.rt(a)
self.fd(c)
def arcleft(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.lt(a)
self.fd(c)
def main():
t1 = Dancer(0,0)
t2 = t1.clone()
t3 = t1.clone()
t4 = t1.clone()
t5 = t1.clone()
t6 = t1.clone()
ts = t1.getscreen()
ts.bgcolor("black")
d = ts.delay(1)
#
t1.ht()
t2.ht()
t3.ht()
t4.ht()
t5.ht()
t6.ht()
#
t1.color("red")
t2.color("green")
t3.color("blue")
t4.color("magenta")
t5.color("cyan")
t6.color("yellow")
#
t1.goto(440,0)
t2.goto(520,0)
t3.goto(600,0)
t4.goto(680,0)
t5.goto(760,0)
t6.goto(840,0)
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.st()
t2.st()
t3.st()
t4.st()
t5.st()
t6.st()
#
# 1. All enter single-file stage left, 640 steps to starting positions.
#
for i in range(160):
t1.fd(4)
t2.fd(4)
t3.fd(4)
t4.fd(4)
t5.fd(4)
t6.fd(4)
time.sleep(0.5)
#
# 2. All turn left 90.
#
ts.tracer(1,10)
for i in range(30):
t1.lt(3)
t2.lt(3)
t3.lt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
time.sleep(0.5)
#
# 3. Circle outward 90, t1-t3 right, t4-t6 left.
#
for i in range(90):
t1.arcright(40,1)
t2.arcright(80,1)
t3.arcright(120,1)
t4.arcleft(120,1)
t5.arcleft(80,1)
t6.arcleft(40,1)
time.sleep(0.5)
#
# 4. All about face, 180.
#
ts.tracer(1,10)
for i in range(60):
t1.lt(3)
t2.lt(3)
t3.lt(3)
t4.rt(3)
t5.rt(3)
t6.rt(3)
time.sleep(0.5)
#
# 5. All move towards each other.
#
for i in range(10):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
t6.fd(1)
time.sleep(0.5)
#
# 6. Turn back inward 90, t1-t3 left, t4-t6 right.
#
# ts.tracer(1,10)
for i in range(90):
t1.arcleft(40,1)
t2.arcleft(80,1)
t3.arcleft(120,1)
t4.arcright(120,1)
t5.arcright(80,1)
t6.arcright(40,1)
time.sleep(0.5)
#
# 7. All turn left 90, facing stage right.
#
ts.tracer(1,10)
for i in range(30):
t1.lt(3)
t2.lt(3)
t3.lt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
#
# 8. All exit single-file stage right.
#
for i in range(375):
t1.fd(4)
t2.fd(4)
t3.fd(4)
t4.fd(4)
t5.fd(4)
t6.fd(4)
#
if __name__=="__main__":
msg=main()
print("DONE!")
mainloop()
Conditional in Python by Stuart Smith
# CONDITIONAL EXECUTION
from turtle import *
from math import *
import time
class Dancer(Turtle):
def __init__(self,x,y):
Turtle.__init__(self)
self.shapesize(2,2,1)
self.pu()
self.ht()
self.speed(0)
def arcright(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.rt(a)
self.fd(c)
def arcleft(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.lt(a)
self.fd(c)
def main():
t1 = Dancer(0,0)
t2 = t1.clone()
t3 = t1.clone()
t4 = t1.clone()
t5 = t1.clone()
t6 = t1.clone()
ts = t1.getscreen()
ts.bgcolor("black")
d = ts.delay(1)
#
t1.color("red")
t2.color("green")
t3.color("blue")
t4.color("magenta")
t5.color("cyan")
t6.color("yellow")
#
t1.goto(500,0)
t2.goto(500,0)
t3.goto(500,0)
t4.goto(500,0)
t5.goto(500,0)
t6.goto(500,0)
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.st()
t2.st()
t3.st()
t4.st()
t5.st()
t6.st()
#
t1.goto(440,0)
t2.goto(520,0)
t3.goto(600,0)
t4.goto(680,0)
t5.goto(760,0)
t6.goto(840,0)
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.st()
t2.st()
t3.st()
t4.st()
t5.st()
t6.st()
#
# 1. All enter single-file stage left, 640 steps to starting positions.
#
for i in range(160):
t1.fd(4)
t2.fd(4)
t3.fd(4)
t4.fd(4)
t5.fd(4)
t6.fd(4)
time.sleep(0.5)
#
# 2. t1-t3 turn left 90, t4-t6 turn right 90
#
for i in range(30):
t1.lt(3)
t2.lt(3)
t3.lt(3)
t4.rt(3)
t5.rt(3)
t6.rt(3)
time.sleep(0.5)
#
# 3. Circle clockwise.
#
for i in range(30):
t1.arcleft(100,3)
t2.arcleft(60,3)
t3.arcleft(20,3)
t4.arcleft(20,3)
t5.arcleft(60,3)
t6.arcleft(100,3)
time.sleep(0.5)
#
# 4. All face forward
#
for i in range(30):
t1.rt(3)
t2.rt(3)
t3.rt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
#
# 5. t1 becomes "traffic cop."
#
for i in range(60):
t1.rt(3)
t1.shape("arrow")
time.sleep(0.5)
for i in range(30):
t1.lt(3)
time.sleep(0.5)
#
# 6. Turn right 90.
#
for i in range(30):
t2.rt(3)
t3.rt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
time.sleep(0.5)
#
# 7. Circle clockwise 60.
#
for i in range(20):
t2.arcright(60,3)
t3.arcright(20,3)
t4.arcright(20,3)
t5.arcright(60,3)
t6.arcright(100,3)
time.sleep(0.5)
t1.color("black")
#
# 8. Wait for traffic signal.
#
t1.seth(0)
time.sleep(1)
t1.color("red")
#
# 9. Turn right 180.
#
for i in range(60):
t2.rt(3)
t3.rt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
time.sleep(0.5)
#
# 10. Circle left 60.
#
for i in range(20):
t2.arcleft(60,3)
t3.arcleft(20,3)
t4.arcleft(20,3)
t5.arcleft(60,3)
t6.arcleft(100,3)
time.sleep(0.5)
t1.color("black")
#
# 11. Wait for traffic signal.
#
t1.seth(0)
time.sleep(1)
t1.color("red")
#
# 12. Continue counterclockwise.
#
for i in range(20):
t2.arcleft(60,3)
t3.arcleft(20,3)
t4.arcleft(20,3)
t5.arcleft(60,3)
t6.arcleft(100,3)
time.sleep(0.5)
t1.color("black")
#
# 13. Wait for traffic signal.
#
t1.seth(180)
time.sleep(1)
t1.color("red")
#
# 14. Turn right 180.
#
for i in range(60):
t2.rt(3)
t3.rt(3)
t4.lt(3)
t5.lt(3)
t6.lt(3)
time.sleep(0.5)
#
# 15. Circle right 60.
#
for i in range(20):
t2.arcright(60,3)
t3.arcright(20,3)
t4.arcright(20,3)
t5.arcright(60,3)
t6.arcright(100,3)
time.sleep(0.5)
t1.color("black")
#
# 16. t1 rejoins the ensemble.
#
t1.seth(90)
t1.shape("classic")
t1.color("red")
for i in range(30):
t1.lt(3)
#
# 17. Circle right back into starting line.
#
for i in range(30):
t1.arcright(100,3)
t2.arcright(60,3)
t3.arcright(20,3)
t4.arcright(20,3)
t5.arcright(60,3)
t6.arcright(100,3)
time.sleep(0.5)
#
# 18. Turn to exit heading.
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
# 19. Exit single-file in order stage right.
#
ts.tracer(4,100)
for i in range(80):
t1.fd(1)
for i in range(80):
t1.fd(1)
t2.fd(1)
for i in range(80):
t1.fd(1)
t2.fd(1)
t3.fd(1)
for i in range(80):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
for i in range(80):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
for i in range(1200):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
t6.fd(1)
#
if __name__=="__main__":
msg=main()
print("DONE!")
mainloop()
Looping in Python by Stuart Smith
# LOOPING
from turtle import *
from math import *
import time
class Dancer(Turtle):
def __init__(self,x,y):
Turtle.__init__(self)
self.shapesize(2,2,1)
self.pu()
self.ht()
self.speed(10)
def arcright(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.rt(a)
self.fd(c)
def arcleft(self,r,a):
theta = 2*pi*(360-2*a)/360
c=2*r*sin(theta/2)
self.lt(a)
self.fd(c)
def main():
t1 = Dancer(0,0)
t2 = t1.clone()
t3 = t1.clone()
t4 = t1.clone()
t5 = t1.clone()
t6 = t1.clone()
ts = t1.getscreen()
ts.bgcolor("black")
d = ts.delay(1)
#
t1.color("red")
t2.color("green")
t3.color("blue")
t4.color("magenta")
t5.color("cyan")
t6.color("yellow")
#
t1.goto(500,0)
t2.goto(500,0)
t3.goto(500,0)
t4.goto(500,0)
t5.goto(500,0)
t6.goto(500,0)
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.st()
t2.st()
t3.st()
t4.st()
t5.st()
t6.st()
#
t1.goto(440,0)
t2.goto(520,0)
t3.goto(600,0)
t4.goto(680,0)
t5.goto(760,0)
t6.goto(840,0)
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.st()
t2.st()
t3.st()
t4.st()
t5.st()
t6.st()
#
# 1. All enter single-file stage left, 640 steps to starting positions.
#
for i in range(160):
t1.fd(4)
t2.fd(4)
t3.fd(4)
t4.fd(4)
t5.fd(4)
t6.fd(4)
time.sleep(0.5)
#
# 2. t1-t3 about face right.
#
for i in range(90):
t1.rt(2)
t2.rt(2)
t3.rt(2)
time.sleep(0.5)
#
# 3. Gather at center.
#
for i in range(40):
t3.fd(1)
t4.fd(1)
for i in range(120):
t2.fd(1)
t5.fd(1)
for i in range(200):
t1.fd(1)
t6.fd(1)
time.sleep(0.5)
#
# 4. Turn to initial dance headings
#
t1.seth(30)
t2.seth(90)
t3.seth(150)
t4.seth(210)
t5.seth(270)
t6.seth(330)
#
t1.pd()
t2.pd()
t3.pd()
t4.pd()
t5.pd()
t6.pd()
#
# 5. Begin loop (3 repetitions)
#
ts.tracer(2,50)
for i in range( 3 ):
# 5a. Move out from center.
for j in range(200):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
t6.fd(1)
# 5b. Turn right 90.
for j in range(30):
t1.rt(3)
t2.rt(3)
t3.rt(3)
t4.rt(3)
t5.rt(3)
t6.rt(3)
# 5c. Advance 1/6 circle.
for j in range(60):
t1.arcright(100,1)
t2.arcright(100,1)
t3.arcright(100,1)
t4.arcright(100,1)
t5.arcright(100,1)
t6.arcright(100,1)
# 5d. Turn right back toward center.
for j in range(30):
t1.rt(3)
t2.rt(3)
t3.rt(3)
t4.rt(3)
t5.rt(3)
t6.rt(3)
# 5e. Move back into center
for j in range(200):
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
t6.fd(1)
# 5f. Face back out from center.
for j in range(60):
t1.rt(3)
t2.rt(3)
t3.rt(3)
t4.rt(3)
t5.rt(3)
t6.rt(3)
#
# End loop
#
# 6. Turn to exit heading.
#
t1.seth(180)
t2.seth(180)
t3.seth(180)
t4.seth(180)
t5.seth(180)
t6.seth(180)
#
t1.speed(1)
t2.speed(1)
t3.speed(1)
t4.speed(1)
t5.speed(1)
t6.speed(1)
#
# 7. Exit single-file in order stage right.
#
for i in range(80):
t1.pu()
t1.fd(1)
for i in range(80):
t2.pu()
t1.fd(1)
t2.fd(1)
for i in range(80):
t3.pu()
t1.fd(1)
t2.fd(1)
t3.fd(1)
for i in range(80):
t4.pu()
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
for i in range(80):
t5.pu()
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
for i in range(1200):
t6.pu()
t1.fd(1)
t2.fd(1)
t3.fd(1)
t4.fd(1)
t5.fd(1)
t6.fd(1)
#
if __name__=="__main__":
msg=main()
print("DONE!")
mainloop()
Acknowledgments
This work was made possible by the Provost Research Dissemination and Faculty Development (RDFD) Competition, Office of Sponsored Programs (OSP), University of Northern Colorado Through Lines grant from the College of Performing and Visual Arts and the Grant from the Office of Undergraduate Research (OUR), University of Northern Colorado.
Thank you to the dance class members for agreeing to be photographed and videotaped while dancing.
Link to the Dance Code Video:
A theater performances at the Campus Commons Performance Hall (CCPH)>****
https://www.youtube.com/watch?v=0YED8KkB7wE
Explanatory Video about steps in coding and in dance
The UNC's Campus Commons Performance Hall
https://arts.unco.edu/campus-commons/
Rule Breaking - A Danced Poem
This is a short story about miscommunication when two different disciplines are discussed resulting of unintentional breaking of the rules in coding and those in dancing. When learning new discipline wh have to remember there are hidden codes and and some unspoken rules that only come with practice through interaction.
Rule-Breaking Poem
He introduced her to performing functions, accurate guiding, path planning and following trajectories, automatic avoidance of objects, version interface, autonomous navigation, replication of movements. She used hard coding with messy formatting code, several things in one function, variables with magic numbers and strings, and no comments. She told him about the principles, centering, gravity, alignment, contraction then release, breath use, falling, then recovering, balancing, then off balancing, opposition and succession, tension, then relaxation, spiral, swing and momentum. He crossed his arms, then put them on his hips when listening. He told her about safety, security, reliability testability, maintainability, then portability. Those, she applied to her work, respectively.
Link to the video:
https://youtu.be/dsb-p7fFo_o
Prepartaory animated video:
https://youtu.be/thpcqGwEEnE