Created
February 18, 2012 11:42
-
-
Save dmberry/1858946 to your computer and use it in GitHub Desktop.
Iteration of Mark C. Marino's iteration of the original Iteracy Zajal code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ---------------------------------------------- | |
# CRITICAL CODE STUDIES: WEEK 2 LITERACIES | |
# | |
# David M. Berry Feb 2012 | |
# modified slightly by Mark C Marino Feb 2012 a bit later | |
# iterated by David M. Berry 18 Feb 2012 | |
# | |
# now uses nice truetype fonts for better visual image | |
# layout more carefully | |
# | |
# Based on the webpage: http://stunlaw.blogspot.com/2011/09/iteracy-reading-writing-and-running.html | |
# | |
# ITERATED.RB based on ITERACY.RB | |
# Programmed in Zajal - http://zajal.cc/ | |
# Many thanks to Ramsey Nasser | |
# | |
# ---------------------------------------------- | |
# ---------------------------------------------- | |
# This bit defines and fills the arrays used below | |
# Mark: I decided to break up your longer claims to smaller chunks | |
# ---------------------------------------------- | |
iteracy = ["1. Computational Thinking", "2. Algorithms", "3. Reading and Writing Code", "4. Learning programming languages", "5. Aesthetics of Code", "6. Data and Models"] | |
idesc = ["being able to devise and understand the way in which /ncomputational systems work", "to be able to read and write the code associated with them/n","for example abstraction, pipelining, hashing, sorting, etc./n", "understanding the specifically algorithmic nature /nof computational work/n","e.g. recessions, iteration, /ndiscretisation, etc./n", "practices in reading/writing code require new skills/n", "to enable the reader/programmer/n", "to make sense of and develop /ncode in terms of modularity, data, encapsulation, naming, /ncommentary, loops, recursion, etc./n","understanding one or more concrete programming languages/n", "to enable the student to develop a comparative dimension/n", "to hone skills of iteracy, e.g. procedural, functional, object-oriented, etc./n","developing skills related to appreciating the aesthetic /n dimension of code/n","here I am thinking of 'beautiful code' and 'elegance' as key/n concepts./n","understanding the significance and importance of /n", "data, /ninformation and knowledge and their relationships to /nmodels in computational thinking (abstract machines, etc.)./n"] | |
georgia = Font.new "/Library/Fonts/georgia.ttf", 30 # here, 30 is the size of the font | |
georgia2 = Font.new "/Library/Fonts/georgia.ttf", 12 # here, 12 is the size of the font | |
impact = Font.new "/Library/Fonts/impact.ttf", 14 # here, 14 is the size of the font | |
impact2 = Font.new "/Library/Fonts/impact.ttf", 12 # here, 12 is the size of the font | |
# ---------------------------------------------- | |
# This bit initalises the global variables used | |
# ---------------------------------------------- | |
x2, y2 = 250, 250 | |
current = "" | |
description = " " | |
counter = 0 | |
tcounter = 0 | |
xx = 10 | |
yy = 200 # DB corrected slight error that Mark introduced yy=200 | |
startcounter = 0 | |
setup do | |
# ---------------------------------------------- | |
# This bit initialises all the variables used | |
# ---------------------------------------------- | |
current = iteracy [counter] | |
description = idesc [counter] | |
counter = counter +1 | |
tcounter= tcounter +1 | |
size 500 | |
title "ITERATED ITERATED" | |
background 0 | |
fill false | |
alpha_blending true | |
smoothing true | |
circle_resolution 64 | |
end | |
draw do #main loop | |
# ---------------------------------------------- | |
# This bit asks the question | |
# ---------------------------------------------- | |
color 100,100,100 | |
georgia.draw "ITERACY:", 5, 460 | |
4.times do |n| | |
color 60*n,60*n, 60*n | |
georgia2.draw current[3..current.length], 200, 430+(10*n) | |
end | |
color :white | |
impact.draw " ------------ CODE LITERACY QUESTION --------------", 10,20 | |
impact.draw " @MARKCMARINO: Who has a good alternative to 'literacy' " , 5,50 | |
impact.draw " when it comes to programming or reading code? ", 5, 70 | |
color :yellow | |
impact.draw " @BERRYDM: 'ITERACY' based on the notion of iteration.", 5, 100 | |
impact.draw " Iteration deals with looping through a ", 5, 120 | |
impact.draw " collection (like an array) using loops.", 5, 140 | |
color :white | |
impact.draw " --------- click mouse for more details -----------", 5, 170 | |
# ---------------------------------------------- | |
# This bit answers the question from the array above | |
# ---------------------------------------------- | |
color :white | |
georgia2.draw current, xx, yy | |
textarray = description.split("/n") #break the description into lines based on '/n' | |
for startcounter in (0..textarray.count) # iteration (loop) to print paragraph description | |
georgia2.draw textarray[startcounter], xx, yy+30+(startcounter*18) | |
end | |
# ---------------------------------------------- | |
# This bit draws the funky iterative background | |
# ---------------------------------------------- | |
alpha = 0..200 #define variable alpha | |
radius = 100..500 #define variable radius | |
depth = 40 #define variable depth | |
depth.times do |n| | |
t = n/depth.to_f | |
color 200, alpha * t #define colour and shades | |
circle x2, y2 + sin(time * 0.001 + n * 0.25) * 30, radius * t**2 #draw circles | |
color 24 | |
end | |
end | |
mouse_down do |x, y, btn| #mouse press loop | |
# ---------------------------------------------- | |
# This bit iterates through the answers from the array above | |
# ---------------------------------------------- | |
current = iteracy [tcounter] | |
description = description + " " + idesc [counter] | |
counter = random max (14) #I wanted to radomize the combination | |
tcounter = tcounter +1 | |
if tcounter > 6 # DB added back the data and models which was missed out | |
tcounter = 0 | |
description = " " | |
current = " " #Mark: wanted to erase the board every so often | |
end | |
xx = 10 | |
yy = 200 # Leave in Place | |
startcounter = 0 # reset the startcounter | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment