think.create word - code101x-handout-week2-code-examples.docx created date 9/29/2015 7:37:08 am
TRANSCRIPT
Think.Create.Code Code101x Handout
Course Details No Prerequisites Required Course Dates This course is self-paced. Start Date: 30th September 2015 0:00 AM UTC Finish Date: 31st March 2016 0:00 AM UTC Time Commitment Between 2 to 3 hours per week. Assessment Due Date This course is self-paced so you can complete your assessments when it suits you. Grading Scheme Pass (50% or higher) Fail (under 50%)
Week 2 Code Examples Some examples of the code used in WEEK 2: Building Blocks – Breaking It Down And Building It up: Examples from: 1. How is Data Used In Code? Example 1: line(10,10,120,10); strokeWeight(1); line(10, 30, 120, 30); strokeWeight(5); line(10, 60, 120, 60); strokeWeight(10); line(10, 90, 120, 90); strokeWeight(4); line(10, 150, 120, 150);
Example 2: strokeWeight(10); line(40, 40, 140, 40); strokeCap(SQUARE); line(40, 90, 140, 90); strokeCap(PROJECT); line(40, 140, 140, 140);
Example 3: strokeWeight(1); ellipse(100,100,90,90); strokeWeight(5); ellipse(100,100,70,70); strokeWeight(7); ellipse(100,100,50,50); strokeWeight(10); ellipse(100,100,30,30); strokeWeight(1); ellipse(100,100,10,10);
2 edx./adelaidex/code101x Code101x Course Handout
Example from: 2. Variables And Expressions Example 1: size(120,300); int y = 20; int distance = 10; int h = 10; rect(10,y,100,h); y = y + distance + h; h = h * 2; rect(10,y,100,h); y = y + distance + h; h = h * 2; rect(10,y,100,h); y = y + distance + h; h = h * 2; rect(10,y,100,h);
Examples from: 3. Variables Can Make Our Code Smarter These programs are used throughout the videos and are often re-used with minor changes to things like the size of the canvas. I’ve split the second program into two separate examples to show you what I mean by this. Example 1: size(200,200); background(120,40,40); rect(90,80,20,40);
Example 2a: size(200,200); background(120,40,40); rect(width/2-20,height/2-20,20,40);
Example 2b: size(300,300); background(120,40,40); rect(width/2-20,height/2-20,20,40);
3 edx./adelaidex/code101x Code101x Course Handout
Example 3: size(200,200); background(120,40,40); rect(width/2-20,height/2-20,width/10,height/5);
Example 4: size(200,200); background(120,40,40); int hwid=width/2; int hhei=height/2; int woffset=width/10; int hoffset=height/5; rect(hwid-(woffset/2),hhei- (hoffset/2),woffset,hoffset);