Created
February 4, 2012 22:32
-
-
Save nasser/1740735 to your computer and use it in GitHub Desktop.
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 | |
# | |
# Based on the webpage: http://stunlaw.blogspot.com/2011/09/iteracy-reading-writing-and-running.html | |
# | |
# ITERACY.RB | |
# Programmed in Zajal - http://zajal.cc/ | |
# Many thanks to Ramsey Nasser | |
# | |
# ---------------------------------------------- | |
# ---------------------------------------------- | |
# This bit defines and fills the arrays used below | |
# ---------------------------------------------- | |
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 /nand write the code associated with them. For /nexample abstraction, pipelining, hashing, sorting, etc. ", "Understanding the specifically algorithmic nature /nof computational work, e.g. recessions, iteration, /ndiscretisation, etc.", "Practices in reading/writing code require new skills to /nenable the reader/programmer to make sense of and develop /ncode in terms of modularity, data, encapsulation, naming, /ncommentary, loops, recursion, etc.", "Understanding one or more concrete programming languages /nto enable the student to develop a comparative dimension /nto hone skills of iteracy, e.g. procedural, functional, /nobject-oriented, etc.","Developing skills related to appreciating the aesthetic /ndimension of code, here I am thinking of 'beautiful code' /nand 'elegance' as key concepts.","Understanding the significance and importance of data, /ninformation and knowledge and their relationships to /nmodels in computational thinking (abstract machines, etc.)."] | |
# ---------------------------------------------- | |
# This bit initalises the global variables used | |
# ---------------------------------------------- | |
x2, y2 = 250, 250 | |
current = "" | |
description = " " | |
counter = 0 | |
xx = 10 | |
yy = 150 | |
startcounter = 0 | |
setup do | |
# ---------------------------------------------- | |
# This bit initialises all the variables used | |
# ---------------------------------------------- | |
current = iteracy [counter] | |
description = idesc [counter] | |
counter = counter +1 | |
size 500 | |
title "ITERACY" | |
background 0 | |
fill false | |
alpha_blending true | |
smoothing true | |
circle_resolution 64 | |
end | |
draw do #main loop | |
# ---------------------------------------------- | |
# This bit asks the question | |
# ---------------------------------------------- | |
color :green | |
text " ------------ CODE LITERACY QUESTION --------------" | |
text "" | |
text " @MARKCMARINO: Who has a good alternative to 'literacy' " | |
text " when it comes to programming or reading code? " | |
text "" #add a space | |
color :yellow | |
text " @BERRYDM: 'ITERACY' based on the notion of iteration." | |
text " Iteration deals with looping through a " | |
text " collection (like an array) using loops." | |
text "" #add a space | |
text " --------- click mouse for more details -----------" | |
# ---------------------------------------------- | |
# This bit answers the question from the array above | |
# ---------------------------------------------- | |
color :white | |
text 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 | |
text textarray[startcounter], xx, yy+30+(startcounter*13) | |
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 255, alpha * t #define colour and shades | |
circle x2, y2 + sin(time * 0.001 + n * 0.25) * 30, radius * t**2 #draw circles | |
end | |
end | |
mouse_down do |x, y, btn| #mouse press loop | |
# ---------------------------------------------- | |
# This bit iterates through the answers from the array above | |
# ---------------------------------------------- | |
current = iteracy [counter] | |
description = idesc [counter] | |
counter = counter +1 | |
if counter > iteracy.count-1 | |
counter = 0 | |
end | |
xx = 10 | |
yy = yy + 50 # Increase the y coordinate | |
if yy>400 # Test to see if yy too large if so... | |
yy = 150 # Reset the y coordinate value | |
end | |
startcounter = 0 # reset the startcounter | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment