Wednesday, January 11, 2012

Programming in Paris

Still in Paris. Things are going ok. Did you know that there are NOT fireworks around the Eiffel Tower on New Years? We didn't. No biggie, but still... a pinch of a let down. Adam emailed the Rick Steves Paris 2012 travel book we have with the correction.

So, yeah... no fireworks. And there was this whole being sick for a week thing... Spent a lot of time in our rental sleeping... and... sleeping... there was some reading at least. And sadness.

But! But! Things have been getting done! One of which was the porting of my Java Stereogram program to HTML5! The algorithm is from which is great. Very dry, but I did eventually wrap my head around everything it was doing... back when I implemented it the first time ~3.5 years ago... It was a sample code project for a job application, and after combing through what I wrote back then I'm shocked I ever got hired. It was my first Java project after school and clearly I had a lot to learn. Amusing that I'm using the same project to learn/poke at HTML5 with... I've no doubt I'll look back later and wince at how ugly it all looks...

Took a little under a week of scattered work. Mostly debugging. Fucking lack of typed variables! Ran into lots of "Javascript doesn't have ints" problems... yes, yes, you can cast the value... but remembering to cram everything back into int format is not the same as/far more trixy then just having values that are and will always be int. Grrr...

----- Java ------

int b, c;

int a = b - c/2;

----- javascript ------

var a = Math.floor(b + c/2); // WRONG

var a = b + Math.floor(c/2); // CORRECT

Adam gave me a hard time about it after I found the problem. I mean, *yes* I know the difference between the two and I realize why I was getting problems.... but... when I'm re-writing code quickly, I feel like it was an easy mistake to make... :(

Another gotcha I ran into was with Canvas (a major part of the learning exercise). When trying to scale an image, remember to transform before drawing the image.... This makes total sense when I think about it (and given how other graphics stuff works) but, again, slipped my mind.

ctxt.scale(scale, 1); //don't be retarded, remember this goes BEFORE the .drawImage call
ctxt.drawImage(otherCanvas, 0, 0);

A final thing to note is that I'm using this project as an excuse to finally work with git. Yes, I know I can set git on my own, but I didn't see the harm of using github to track the work. Now all I need is an actual web hosting service to host the page! Anyway, I'm still very much working on the Stereogram code so don't judge too harshly by what you see uploaded now... I'll post again when it's pretty (and hosted) :

  • Lift code to let you save canvas images
  • Made the page less ugly
  • Make sure everything works (just now fixed another rounding bug)
  • Add some tests
  • Provide sample images for depth maps and tiles (the quality of the tile can greatly affect the result!)
  • Find hosting for it
  • remove JQuery need- only used that because I was lazy initially

1 comment:

  1. github can be a real pain in the ass because the command-line commands you use make no damn sense. ("Checkout" means switch to a new branch. Umm... kay.)

    But they do have a UI for Macs that's pretty good. At least you don't have to know all their stupid commands by heart.

    Otherwise I like it.