.  377 s 17  . 
    ☆ Coming Attractions! ☆
⇒ FINAL: M, 5/08 2pm - code day
⇒ Cube / 3js / 3d / d3?: due W, 5/10 d2l 10pm
Projects      
CANVAS INTRO+       GOL 2dCA / FLOOD       IMAGE PROCESSING       PARTICLE SYSTEM       PLACE       CUBE      
readable code       web code       html/css reference       javascript reference       firebug & the console
codepen.io       my codepen       * codepens   
w3 schools       tryIt editor       google web fundamentals       codeacademy.com      mozilla
42 class calendar
week 1 2 3 4 5 6 7 8 9 10 11 12 13 14
23 25 27 | 30 01 03 | 06 08 10 | 13 15 17 | 20 22 24 | 27 01 03 | 06 08 10 | * | 20 22 24 | 27 29 31 | 03 05 07 | 10 12 14 | 17 19 21 | 24 26 28 | 01 03 05
class 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
syllabus (pdf) / addendum (pdf) / student rights (pdf)   -   2gb: see me
Text Home   --   Text Code Online   --   Text Code Local
 
Course Intro - About CIS 377
* CIS 270 is a prerequisite. Should be ~comfortable with: 1. integrating html, css AND JAVASCRIPT!! 2. create listener with a callback 3. callback should be able to access a specified HTML element (by ID) 4. functions, loops, if statements, objects, arrays About 377 (syllabus, grades, code) syllabus(pdf)/addendum(pdf) faq: grades, honesty, readable code, submit assignments, tests and CAP, editors labs on campus, macs firefox developer sw engineering as a career
Fundamentals Review 1
html, css, js integrated get el by id to modify html and css in javascript js function loop accumulator

See the Pen Template 0 - 9 lines by Joseph (@wynottwynott) on CodePen.


See the Pen Template 1: link and css by Joseph (@wynottwynott) on CodePen.


See the Pen Template 2 - CSS and JS by Joseph (@wynottwynott) on CodePen.


See the Pen 270 Adding JavaScript by Joseph (@wynottwynott) on CodePen.

html, css, js integrated get el by id to modify html and css in javascript js var, scope loop if % accumulator
QUIZ: WRITE the JavasSript to create this

See the Pen 377 start 0 by Joseph (@wynottwynott) on CodePen.


QUIZ: SHOW the Output

See the Pen 377 start by Joseph (@wynottwynott) on CodePen.

Fundamentals Review 2 & HTML5 Canvas
canvas - new to html5 width height attributes must be specified, don't use css for sizing may style otherwise needs id as a hook for JS the rendering "context" provides a 2d object which as an api used to draw
simple canvas Canvas rectangles and ellipses // x,y,w,h ctx.fillRect(Math.floor(Math.random()*400), Math.floor(Math.random()*250), Math.floor(Math.random()*140), Math.floor(Math.random()*100)); .... // x, y, radius, startAngle, endAngle, anticlockwise ctx.arc( Math.floor(Math.random()*450), Math.floor(Math.random()*250), Math.floor(Math.random()*40), 0.0, (Math.PI * 2), true); ctx.fill();// actually draws here

See the Pen Template 3 - Canvas by Joseph (@wynottwynott) on CodePen.


trig boxes circles colors listeners callbacks!! Canvas: Boxes, Circles, Trig, Listeners, Call-backs

Diving Into HTML5: canvas text Mozilla canvas tutor JS: Spirals and Trig JS: Snow
Debugging an HTML5 Canvas Page: trig, mouse and keyboard listeners
Canvas: Boxes, Circles, Trig, Listeners, Call-backs(*LOCAL)

See the Pen Canvas: boxes and trig by Joseph (@wynottwynott) on CodePen.


Canvas: Assignment w/ trig mouse, keyboard, shapes (*LOCAL)
listeners callbacks!! trig boxes circles colors keyboard event mouse events
A Detour into CSS
The hardest part of CSS is controlling the layout, especially allowing for reponsive design that accomodates a variety of screen widths. My CSS: responsive css and the other page My Grid: responsive & fixed using CSS float and box-sizing
Canvas & Arrays, 2d and Objects, Cellular Automata
var a=[]; var EL=100; var colors=["black", "white"]; function dataStruct() { for(var i=0; i<EL; i++) { a[i] = new Array(EL); for(var j=0; j<EL; j++) { a[i][j] = {}; a[i][j].x=i; a[i][j].y=j; a[i][j].color=colors[Math.floor(Math.random()*colors.length)]; a[i][j].z= function(){ $("rep").innerHTML="I am pixel at: " + this.x + " " + this.y + " " + this.color; } } } GOL Video & Assignment Page Flood Video Page 244/a/aXFlood/floodpage.html
Flood Canvas(*LOCAL)
Sierpinski 1d CA Gasket & Image Intro
From Wolfram on additive cellular automata: "An additive cellular automaton is a cellular automaton whose rule is compatible with an addition of states. Typically, this addition is derived from modular arithmetic. Additive rules allow the evolution for different initial conditions to be computed independently, then the results combined by simply adding. The results for arbitrary starting conditions can therefore be computed very efficiently by convolving the evolution of a single cell with an appropriate convolution kernel (which, in the case of two-color automata, would correspond to the set of initially "active" cells)." wolfram: sierpinski sieve wolfram: additive CA wolfram: rule 102 1d CA Can write arrays that are generated in code to the canvas as an image.
Image Processing
// display image img4 = new Image(); img4.src = 'myPicture.jpg'; img4.onload = function(e) { // draw after image is loaded ctx.drawImage(img4, 0, 0); } // gets rgb for all pixels from image (entire canvas) // 1-d array // num pixels = canvas.width x canvas.height // num data items = pixels x 4 imgData = ctx.getImageData(0, 0, canvas.width, canvas.height); // holds total length of rgba array imgData.data.length // data organized as rgba / rgba / rgba /... imgData.data[i] - contains 1 byte of data (rgba) at index 'i' // average the rgb of one pixel at "i" // assign the avg to each rgb component var avg = imgData.data[i] + imgData.data[i+1] + imgData.data[i+2]; imgData.data[i] = imgData.data[i+1] = imgData.data[i+2] = avg; // writes data array to canvas at 0,0 ctx.putImageData(imgData, 0, 0);
☆   Test 1
TEST 1 Review short answer: day 1 code read/write: day 2 Create a CAP
Objects, Constructors, Prototypes: Vectors
A Euclidean vector is defined as an entity that has both magnitude and direction. A vector is typically drawn as a arrow where direction is where the arrow is pointing, and velocity by the length of the arrow. Source: https://software.intel.com/en-us/html5/hub/blogs/build-a-javascript-particle-system-in-200-lines function Vector(x, y) { this.x = x || 0; this.y = y || 0; } // Add a vector to another Vector.prototype.add = function(vector) { this.x += vector.x; this.y += vector.y; } // Gets the length of the vector Vector.prototype.getMagnitude = function () { return Math.sqrt(this.x * this.x + this.y * this.y); }; // Gets the angle accounting for the quadrant we're in Vector.prototype.getAngle = function () { return Math.atan2(this.y,this.x); }; // Allows us to get a new vector from angle and magnitude Vector.fromAngle = function (angle, magnitude) { return new Vector(magnitude * Math.cos(angle), magnitude * Math.sin(angle)); };
Particle Systems
In 1982, William T. Reeves, a researcher at Lucasfilm Ltd., was working on the film Star Trek II: The Wrath of Khan. Much of the movie revolves around the Genesis Device, a torpedo that when shot at a barren, lifeless planet has the ability to reorganize matter and create a habitable world for colonization. During the sequence, a wall of fire ripples over the planet while it is being “terraformed": “A particle system is a collection of many many minute particles that together represent a fuzzy object. Over a period of time, particles are generated into a system, move and change from within the system, and die from the system.” —William Reeves, "Particle Systems—A Technique for Modeling a Class of Fuzzy Objects," ACM Transactions on Graphics 2:2 (April 1983), 92. Jarrod Overson demo: http://jarrodoverson.com/static/demos/particleSystem/ function Particle(point, velocity, acceleration) { this.position = point || new Vector(0, 0); this.velocity = velocity || new Vector(0, 0); this.acceleration = acceleration || new Vector(0, 0); } Particle.prototype.move = function () { // Add our current acceleration to our current velocity this.velocity.add(this.acceleration); // Add our current velocity to our position this.position.add(this.velocity); };
Place
Framework Integration Closure - controlling scope Shuffling an Array: Fisher-Yates bostock
Cube
3d on canvas Trig Transformations: rotate, translate
WebGL / Three.js
☆   Test 2
Canvas Basics: representation, colors, shapes, drawing, trig Closures - see w3s Constructors - see w3s Collision var circle1 = {radius: 20, x: 5, y: 5}; var circle2 = {radius: 12, x: 10, y: 5}; var dx = circle1.x - circle2.x; var dy = circle1.y - circle2.y; var distance = Math.sqrt(dx * dx + dy * dy); if (distance < circle1.radius + circle2.radius) { // collision detected! } Animation and Shuffling an Array: Fisher-Yates bostock (d3) bostock 2 (d3) bostock 3 (d3) Architecture / Framework / Integration (architecture) submitting code naming convention/standard api creation and publication no interference fairness in scheduling protection / security support unit testing ease of use I & T trackback disasters
Create a CAP CUP Registrar: see "Final Exam Schedule"
Student is responsible for notes, readings and classroom discussions.   Notes may be changed, emphasized, re-ordered or skipped over.
 
Software
Text Editor:
    Notepad ++ ( hints and tips )
    Atom

Browser / Debugger:
    Firefox Developer and add-ons
            firebug replacement: dev tools (built into firefox developer)
            web developer extension
            html validator
            colorzilla identifies color
            ruler measures object size
            fireFTP
            screenshot captures screen as an image

Image Editor:
    Paint.net    
    Gimp image editor
Text

    1. Core HTML5 Canvas: Graphics, Animation, and Game Development, Geary, 2012
        [REQUIRED] ISBN-13: 978-0132761611
        (Amazon)     (Bookstore)
        Read chapter 1 on-line free
        Text Web Site   -   Code from Text (view or download) (local)

    2. HTML5 Canvas, Fulton & Fulton, 2013
        [OPTIONAL] ISBN-13: 978-1-449-33498-7
        (Amazon)     (Bookstore)
        Code   Errata
        Read Online

    3. Dive Into HTML 5 by Mark Pilgrim (web) -- (pdf)
        [OPTIONAL]   (free web book)