Keep Away Game in HTML5 Canvas

 Keep Away Game
Expand to entire article to play.

The Keep Away game was the last assignment in my Flash class and this is the port to HTML5 canvas, programmed in Javascript. Flash is declining for a number of reasons, including its proprietary nature and that it's not supported by the iPhone. Too bad, because Flash's ActionScript 3.0 is a thoroughgoing object oriented approach to graphics programming similar to Javascript. For the programmer, a circle or rectangle or any other figure suitable to be part of a display list is just an object with properties and methods. Many artists know Flash through the sophisticated Flash Pro environment, where they can create and store images efficiently with "symbols". Think Adobe Photoshop, apt in a couple ways considering that Adobe acquired Flash and developed ActionScript 3.0. Even animations are possible with "tweens". It's a nice in-between technology, where artists can experience Flash as as they always do, but be gently introduced to programming those objects in the code window. My approach is to forgo the environment entirely, except as a medium to execute ActionScript. The environment can be skipped entirely with Abobe's free compiler which turns ActionScript into .swf, which executes in the (free) Flash Player.

Tutorial: HTML5 Canvas Demo in Drupal

The image of the Old Glory below was created with HTML5 canvas and there are a few tricks involved in getting it to work with Drupal 7. The first step is to get the HTML5 doctype at the top of all your Drupal pages. You can modify html.tpl.php, the template determining this, but careful if you do, and maybe the simplest approach is to install the Elements and HTML5 Tools modules. Before enabling those modules, viewing the page source shows doctype references to xhtml, afterwards it does not. Don't forget to clear the cache after enabling the modules and before viewing the source if you want to check (Configuration > Performance > Clear all caches). Then this HTML/CSS puts the rectangle at the upper right:

 <div id="canvasContainer" style="float:right; border:1px solid black; margin:0 0 15px 15px">
  <canvas id="flag" width="296" height="156"></canvas>
 </div>

Teaching at MATC

 MATC circa 1912

After driving truck for eleven years, it was time for a change. Education was important in my household coming up. I have a Latin book from a great-great-grandfather on Mom's side. Half of Mom's family were teachers, including her parents for brief stints as young people in Iowa - two of my first cousins became Math and Computer Science professors in Canada. Mom did her entire high school through correspondence on the plains of Saskatchewan; she said trig just about sunk her. Dad too, where education was seen as a deliverance from poverty. He was an engineering student at the University of Manitoba and struggled through school for many years, having to support himself from a very young age. Struggled academically too, but was in awe of mathematics. I told him once as a kid I wanted to be an engineer like him; he said, oh no, shoot higher - go for mathematics. I still have his calculus book and gave his rebound copy of Men of Mathematics to my daughter Lydia when she graduated with a major in mathematics. On occasion I'd get some recognition at school, the honor roll or something, and would throw it aside as of little interest. Later it would appear framed and on the wall in Dad's home office. I essentially ended up teaching software engineering, that was typically my job title when working in the field; I think he would've been Ok with that.

MathJax

Every few years I'd check to see if there was a good system for putting mathematical notation in a web page and always disappointed until now. Eureka, as Archimedes would say - MathJax is the solution. It is open source, extraordinarily easy to use, works in all browsers, and is text based, hence scalable on the page as text. A single line of setup in the header of an html document enables you to include LaTeX right in the html and have it render beautifully. Here's Cauchy-Schwarz, for example:

\[ \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right) \]

My Life in the Labor Movement

 Mike on Square Feb 2011

We moved around a lot when I was a kid, people always asked if my Dad was in the army. No, he was a construction superintendent for S S Kresge, later to become Kmart. He was born in Winnipeg in 1914. The family was large and poor, a poverty that sat heavily on an unhappy family and was close to an obsession for all of them. Aunt Sonya's stories at 75 sounded like they had happened the day before and it was like that with Dad. Grandma was a strait-laced Irish lady, grandpa an illerate elevator operator at the train station. I remember visiting her in Los Angeles when I was thirteen or so. I'm named after her revered brother, who died young, and she sat me down and told me never to forget that I'm Irish (I'm 25% Irish). They say the Nazis are bad, but they're nothing compared to the British, who oppressed us for hundreds of years. Brash even at that age, I wasn't so stupid as to utter a word of opposition. The girls were to start in show business in order to meet wealthy men and find one to marry; the boys' path was education. The girls left home in their teens and became show girls (I've got pictures!). Uncle Wally got a PhD, but Dad was on the ten year plan for an engineering degree at the University of Manitoba. Grandpa beat the boys and Dad knocked him down once when he was starting in on Uncle Ed, said I'll kill you next time. So that was the end of life at home and up to the gold mines at 14, the Rio Grande Mine in northern Manitoba.

High School English

 Jesuit High Dallas - 1943

I always laugh when people deprecate Catholicism as mindless superstition, because I know better from direct experience as a product of four years of Catholic high school. I started out at Jesuit High in Dallas in 1961. Mr. Joubert was my home room, religion, and English teacher. A lot of French names - it was the New Orleans Province after all, not missionaries from Chicago (like my grade school, St. Luke's in Irving). So a tip of the hat to Mr. Vavasseur, my sophomore geometry teacher, a tall, skinny, kind and intelligent man who knew and valued his subject and also knew how to transmit intellectual excitement. He was an important milestone in my mathematical education, especially considering that geometry is where students first encounter the axiomatic method and proofs, the cornerstones of modern mathematics. Between proofs, Mr Vavasseur regaled us with stories of how geometry had been the canonical science for two thousand years, even people like Spinoza modeling their philosophical speculations on Euclid. He quite rightly mentioned Giovanni Girolamo Saccheri, S. J., who foreshadowed non-Euclidean geometry. He was hell on wheels when crossed though; I remember him thundering more than once, "I'll be in Room 214 after school, Jones, be there" (emphasis on the last two words).

Calendar

 August 2013 calendar

My original calendar program was on the Casio fx-3600p calculator in 1980 or so - my first programming venue and exercised partly in spare moments when driving truck out on the route; a precursor mobile device you could say. My buddy Dave got me started. I might have scarred myself permanently though. The transition from math to software engineering is always tricky, considering that there are many commonalities, but just as important differences to snag the self-taught and perhaps obstinate and all-too-confident mathematician (perish the thought). The 3600 had this bizarre little macro language providing for a trade-off between memory and program size. You could have (say) fifty memory locations and 400 instructions or twenty locations and 600 instructions. They're really variables of course, but the memory locations were designated K0 through K19 or something.

Pittsburgh

 Cathedral of Learning Flying back to Pittsburgh with an old Elmore Leonard in hand (The Big Bounce, 1969) jogged some memories. Our man Jack Ryan, someone pulled his chain, the same phrase an upperclassman used on me the first day on campus in August 1969 and the first time I'd heard it. You're in the big leagues now, boy.

What a great English teacher the first semester and after a string of them in high school; the reading list as much as anything - he was a part-timer and probably wanted an excuse to read or reread some favorites. He had Swann's Way under his arm one day. For us it was Iris Murdoch (The Severed Head), Hard Times (Gradgrind!), and Middlemarch, the last my all-time favorite after many re-readings. I remarked in class one day that among the main characters in The Severed Head, almost every possible romantic combination had been consummated or at least entertained. He liked that and rejoined that two female characters were always touching each other, seemingly casually or mistakenly, he thought it was pretty funny. He was making the point with us one day that people can walk through their own lives as zombies without even noticing their remarkable surroundings, most appropriate in the immediate environment of Pitt with the amazing buildings. He said, consider the Civil War Museum, how many columns are there in front of it? Eight, I said (Math Department reporting). He was a little miffed, as if I'd interfered with his lesson.

The Chinese Revolution

 Mao Tse-Tung and Chu Teh Two works by Americans are canonical references for anyone who really wants to understand this monumental, cataclysmic event:

  • Red Star over China, by Edgar Snow
  • Fanshen, by William Hinton
I

Edgar Snow worked as a journalist in China as a young man and traveled to Yenan, the remote base of the Chinese Communists, shortly after the Long March brought them there in 1935. This was a period where little to nothing was known of Mao Tse-Tung and his associates or the Communist movement in China, extensive as it was. There had been a number of Soviet areas in south China governing millions of people in the early thirties - it was because of their encirclement by the Chiang Kai-shek forces of the Kuomintang (KMT) in the fifth anti-Communist extermination campaign that the legendary Long March was necessary to escape the old bases and relocate in the northwest at Yenan in Shaanxi. Snow interviewed Mao and other top leaders fresh from this epic campaign; till that point and long after, his account was the only one known in the West. He somehow got Mao to open up about his own background, something almost irregular among these self-effacing revolutionaries.

The Art of Mathematical Problem Solving

I still remember the day in seventh grade when, alone in the classroom, I found the geometry problems section in the appendix of one of our books and started to work them out, tentatively at first, but increasingly confidently as they started falling into place. Joyfully too -- bitten by the bug and still infected after all these years. The problem notebooks become buried under files with more pressing business, always to be brought back to the top after a time to receive another solution.

The preoccupation can become an ongoing part of your psyche. Ramanujan used to say that a Hindu goddess came to him in dreams with his formulas and he would write them down first thing in the morning. Poincaré has a story (as I remember it) that he had hit a stone wall on a problem after considerable application. He decided he needed a break and took a trip to the country by bus. When disembarking, as his foot rose from the last step and before it fell on the ground, the solution came to him. I was waiting for a friend at a bar once and drew a diagram of a geometry problem I'd been working on unsuccessfully on a napkin, not even applying myself, just doodling absent-mindedly, when the solution revealed itself.

Pages

Subscribe to Ex Libris RSS