my first IronPython program

June 18th, 2008
nexium 40 mg p.o.q. daily
cialis online pharmacy
viagra online
effexor pen drug rep
celebrex caps 200mg side effects
buy levitra without prescription levitra
generic medicines like wellbutrin
cheap acomplia no prescription
prednisone without prescription pet
discount viagra, cialis
propecia women
overdose celebrex 200mg
how to wean off wellbutrin
where to buy viagra cheap
buy acomplia online dream pharmaceutical
viagra without prescription canadian pharm
where to buy safe acomplia
tell me about the drug effexor xr and the effecthas
cheap female viagra
buy clomid overnight
viagra 4 sale by zip code
acomplia diet pills
drug interactions celebrex prednisone
buy celebrex no prior prescrition
buy acomplia online dream pharmaceutical
clomid drug
generic prednisone tablets
is generic same as lipitor
propecia and impotence
buy prednisone without perion
viagra line
lipitor drug
prednisone 1 mg
allergic to zyban should i take wellbutrin xl
viagra online sale
lipitor coenzyme
generic viagra no priscription
clomid ovulation day
buy lipitor
cialis or viagra without prescription
cialis from mexico
clomid en espanol
lipitor patch 10 mg po qd
one month of not taking clomid
why prednisone raises white blood count
viagra online paypal cheap price
buy cialis next day delivery
buy viagra online without prescription
buy online celebrex
how does zyban work
prescription drugs comparable to nexium
drug used to wean people off prednisone
nicorette zyban
effects of lowering the drug prednisone
oral prednisone iv methylprednisolone
prednisone 20mg in dogs
buy pet prednisone without prescription
cialis comparison levitra price viagra
cialis levitra sales viagra
clomid pain
antidote for lasix
acomplia weight loss
mexico online pharmacy for acomplia
lipitor and muscle pain
prednisone diet pills
generic, nexium
zyban vs. wellbutrin xl
what he is acomplia used for
levitra opinioni
clomid 100mg not working residual cysts
buy cialis pills
getting off prednisone
propecia habit
prednisone cheap no preion
viagra on line ordering
discount viagra pay with check
drug prednisone is used for
generic for wellbutrin sr
buy nexium online
wellbutrin sr side effects memory
generic wellbutrin no perscription
viagra non prescription
buy celebrex online without prescription
mg for effexor xr
generic viagra canada
what is propecia used for
buy canada generic viagra
para que serve o acomplia 10mg
effexor hot flashes
what dose levitra have in it
buy viagra online london
does propecia work
weaning off of prednisone
charitable car donation celebrex
side effects of taking prednisone
cialis order australia
buy clomid without a perscription
celebrex and gout
purchase prednisone online
buy lipitor where

After seeing the cools stuff Chris Anderson is doing with Python in his AvPad program, I dicided to take his advice and learn Python. I read an ebook on the flight to Redmond, and today I wrote my first program. It uses IronPython and the .NET framework to make a webspider that searches for mp3s and downloads them.

It works great on the one site (secret site) I tried it on, but I’m sure it will barf on anything else. Here’s the code anyways.

from System.Net import *
from System.IO import *
import System
import re

def GetPage(url):
s = WebRequest.Create(url).GetResponse().GetResponseStream()
sr = StreamReader(s)
page = sr.ReadToEnd()
sr.Close()
return page

def GetLinks(pagestring):
links = ()
rex = re.compile(\”href=\”([^\”]*)\”\”)
m = rex.search(pagestring)
while m != None:
links = links + m.groups()
pagestring = pagestring[m.end():]
m = rex.search(pagestring)
return links

def GetPageLinks(url):
return GetLinks(GetPage(url))

def FixURL(url):
return url.replace(\”&\”, \”&\”)

def FixFile(file):
return file.replace(\”%20\”, \” \”)

def DownloadFile(file, intofile):
intofile = FixFile(intofile)
s = WebRequest.Create(file).GetResponse().GetResponseStream()
input = BinaryReader(s)
Directory.CreateDirectory(Path.GetDirectoryName(intofile))
output = BinaryWriter(File.Open(intofile, FileMode.OpenOrCreate))
size = 1024*8
filepart = input.ReadBytes(size)
while filepart.get_Length() > 0:
output.Write(filepart)
filepart = input.ReadBytes(size)
output.Close()
s.Close()

def SpiderPage(baseurl, intodir):
urls = [baseurl]
for url in urls:
print \”Searching: \” + url
try:
links = GetPageLinks(FixURL(url))
except IOError:
print \”failed!!!\”
mp3s = [url + link for link in links if link[-4:] == ‘.mp3′]
newurls = [url + link for link in links if link[-1:] == ‘/’ and link != ‘/’ and link[:1] != ‘/’]
urls.extend(newurls)
for mp3 in mp3s:
print \” Downloading: \” + mp3
DownloadFile(mp3, intodir + mp3[len(baseurl):])

How’s it look? Anything that I could have done better?

Dan Lash’s interview

April 22nd, 2005

Here is the story of Dan Lash’s interview at Microsoft in January. Pics and Videos included:

http://danlash.com/qwix/seattle.html

It’s spring, go geocaching!

April 18th, 2005

The sun is shining and I feel like doing something outside. It’s been a few years, but I’m planning on doing a bit of geocaching this spring/summer. Don’t know what this is? Here is the official FAQ. The basic idea is that you get a few buddies and a GPS device and you hike around looking for ‘caches’. These are usually ammo boxes or tin containers that contain random, mostly worthless, treasures. The website lets you look for caches near you, so you can usually find a few hundred without travelling too far. When you find one, you sign the guest book, take an item, add an item, and then report your find on the website. Its pretty fun, and is a great way to make good of the sunny weather.

More info: http://www.geocaching.com/about/.

Anyone else geocache?

Avalon March CTP whitespace issues

April 13th, 2005

The issue of whitespace preservation often comes up when working with XML. XAML, being XML, is no exception. Take this for example:

<StackPanel>
<TextFlow><Bold>i’m Bold</Bold> <Italic>i’m Italic</Italic></TextFlow>
</StackPanel>

You might expect this to render with a space between the Bold and the Italic text, but this is not the case.

it will instead look like: i’m Boldi’m Italic

This is because the whitespace between the </Bold> and <Italic> is not reported to Avalon. Technically, you shouldn’t expect it to, because the above is generally thought of as equivalent to:

<StackPanel>
<TextFlow>
<Bold>i’m Bold</Bold>
<Italic>i’m Italic</Italic>
</TextFlow>
</StackPanel>

And I would argue that the above in no way indicates that there should be a space between the two.

So, the question is, how do you force a space between the two tags? Either of the following work, but neither is all that friendly to the typical non-xml person.

<StackPanel>
<TextFlow><Bold>i’m Bold</Bold><![CDATA[ ]]><Italic>i’m Italic</Italic></></TextFlow>
</StackPanel>

<StackPanel>
<TextFlow><Bold>i’m Bold</Bold><Inline xml:space=”preserve”> </Inline><Italic>i’m Italic</Italic></TextFlow>
</StackPanel>

What would be nice is to have a <Space /> object that is similar to <LineBreak /> or <PageBreak /> that takes care of forcing a space where needed. I’m told that an open task to address this issue is in the queue, so we’ll have to use one of the two methods above for now.

How to learn a .net API

April 12th, 2005

So I’m going to Redmond in less than 2 months (after E3 of course), and I need to become capable with the Avalon API so I can jump right in there and get some work done. Here are some tips I’ve discovered on how to learn a [huge] .net API.

1) download the docs and browse though them a bit (including a few quickstarts and samples)
  a) if it’s a beta api like Avalon, you wont sent too much time here initially because the docs are still very incomplete.
2) load the entire api into a class diagram in Whidbey, expand all nodes, auto adjusts the widths, and layout the diagram.
  a) yes, this will take like 1/2 a gig of ram. it’s worth it as you will see later.
  b) this may take upwards of 20 minutes to fully create on a fast computer for a large api like Avalon, move on to step 3 while you’re waiting
3) load the APIs dlls into .NET reflector. In my case, presentationcore.dll and presentationframework.dll
4) explore what you opened in step 1), 2), and 3) like so:
  a) pick a good, non trivial example program from the docs or elsewhere. I chose AvPad.
  b) when you come across a class you dont understand:
    i) look it up in the docs to get an idea of its parent/children and a basic description
    ii) find it in the class diagram to understand where it sits with regard to other classes
    iii) look at all the members of this class, and each parent class all the way up until you get to Object in the class diagram
    iv) if you see a member variable/property/function that you don’t understand, look it up in the docs & check out the source from .net reflector
    v) use the callee/caller graph in .net reflector to see what objects use this class and explore them as well
5) once you get through the sample, write a few simple (but non-trivial) demos to use what you’ve learned. You will no-doubt encounter more areas of the API that you thought you understood, but didn’t really. Do step 4b) on them.
6) rinse, repeate, until you feel you’re ready for a real project.

There you have it. This may not suit everyone’s taste, but so far it’s working for me. Please add any other tips to the comments.

Ballistic Demo

April 3rd, 2005

can we pretend I didn’t take a two+ month absence from blogging? Lets just say I’m lazy + I broke my tablet and lost most of my stuff.

To make up for this I decided to post and EARLY demo of the game I’m currently working on. A few of us at MSU decided to team up and make a game for next years independent game festival student competition.

The concept for the game is that you’re trying to navigate one or more balls through a course and to a goal. You cannot directly effect where the ball goes, but you can indirectly move it by rotating the whole world. The ball (and everything else) will fall downwards with gravity, so you just have to make it fall into the goal. The game is currently not much more than a tech demo, but as things evolve it will have more of a point, much nicer graphics, sound, lots of levels, etc. Right now, if you download this zip, extract it, and run buildistic you can make a level and play it.

Controls:
q,e - rotate world
w - zoom out
f - change focus ball

Level Objects:
track - the actual static course
ball - the ball(s) that you’re trying to get to the goal
dead ball - a bigger ball that just gets in the way
bumper - a cylinder type object that ‘bumps’ object
reverse gravity bumper - same as bumper, but also reverses gravity
spawner bumper - same as bumper but also spawns new balls
turbine - a cross shaped object that rotates around with time
free turbine - smaller turbine that rotates freely
teleporter entrance - enter this and get teleported
teleporter exit - where the entrance pops you out. right now every entrance randomly picks and exit…this will change
hinged door - a rectangular trap door type object that is hinged on one end
peg - a small cylinder that gets in the way plinko style
goal - where you wanna get the balls!

This list will grow quickly as more features are added, please leave suggestions in the comments.

The editor looks like this:

Here you see a zoomed out view of the editor with my levelx.lvl file loaded

The game looks like this (right now currently just using a debug shader):

In this image you see the ball (white) next to a dead ball (bigger round object), both above the goal.

and here’s a zoomed out view of part of the level:

this is mostly for debugging

Our dev environment:
- Ballistic is done in C++ with VS 2005 beta 1
- Buildistic (level editor) done in C# with VS 2005 beta1
- Subversion for source control
- Novodex for physics
- OpenGL +CG for graphics (GDI+ in editor)

If it doesnt run (probably without error message), please let me know. I’ve got a lot of work to do, so compatibility is currently quite low. You will need shader support of some kind.

Understanding ClearType

February 11th, 2005

In my previous attempt to describe a problem that I believe exists in the current implementation of ClearType on XP, I forgot one important thing. A picture is worth a thousand words. The problem is that you can’t just blow up a bitmap to show sub-pixels. That’s why I decided to write a little C# app that would visualize sub-pixels for me so I could take another stab at describing how ClearType works, and why I feel it should support vertical ClearType for tablet users.

If you want to play with the program yourself, here is the source and executable.

First of all, what does clear type look like? Here is a blown up image of an “F” with ClearType turned on using RGB sub-pixel mode.

You should notice a few things. First of all, some pixels are tinted red’ish and some are tinted blue’ish. Further more, the red’ish pixels are all on the left side and the blue’ish pixels are all on the right side of the “F”. Finally, pixels on the top/bottom of the “F” are not affected by ClearType. In other words, it only functions in the horizontal direction.

Now, before I said that the above image is with ClearType in “RGB” mode. What does that mean? It means that the ClearType algorithm is going to assume that your physical pixels have the red, green, and blue elements in left to right order. This is in fact the case on my tablet when in landscape mode, so all is good. Let’s see how it looks on a sub-pixel level:

This is the same image, only blown up on a sub-pixel level. You can see that the top-left pixel (white in the source image) is fully red, green, and blue. You may also notice that if you stand back and squint your eyes, it looks like a nice anti-aliased “F”. You see, as you un-zoom the image the pixels get so small that you don’t notice the red/blue tints and instead it looks like a smooth black character on a white background.

The problems start when your physical pixels are not in RGB order, and yet your ClearType thinks they are. The following image show the same “F” as it would look on a monitor with BGR sub-pixels. (ie, with ClearType still configured for RGB)

Looks pretty bad huh? Try sqinting your eyes on this one…not so clear. To see exactly what’s going on, take a look at this area of the images side by side.

In the first image you can see that the red sub-pixel is slightly darkened because it is near the dark part of the pixels to it’s left. However when the order is reversed the darkened red pixel on the second image is not next to the dark pixels on it’s left. Instead it has bright green and blue sub-pixels between it and the dark pixels of the “F”.

This is exactly why the Microsoft typography webpage has a ClearType utility that lets you pick RGB or BGR ordering. If you choose the wrong one it looks horrible.

You might be thinking, “gee wiz, they let you choose both modes so it should work for everyone”. WRONG. If you’re a tablet user then you tend to rotate your screen into portrait mode. In this scenario your sub-pixels are ordered vertically. Furthermore, if you have an RGB display and you rotate clockwise 90 degress your pixels will be RGB vertically, but if you rotate counter-clockwise (I do) then they will be BGR vertically. The trouble is that neither way looks good with horizontal ClearType. Take a look:

The above images show vertical RGB and BGR respectively with the same source image as before. You can see that it doesn’t look right at all. The trouble is that you can’t place a darkened red pixel to the right of dark pixels because the red is either on the top or bottom. The highlighted areas below emphasize where the problems is compared to the nice looking RGB sub-pixels.

When you view the text un-zoomed it looks like its fuzzy and you can clearly make out red/blue tints.

The solution is to either automatically do the ClearType vertically when in portrait mode, or to automatically turn off ClearType in portrait mode. The ClearType tuning utility only lets me pick horizontal ClearType, so I have to assume vertical ClearType is not supported. So either solution would probably require a change on Microsoft’s end.

As I understand it, they did some initial usability studies and found that vertical ClearType is not needed. I disagree.

p.s. If there is in fact a hidden way to enable it, please tell. Oh and here’s a screen shot of the program I made to render the sub-pixels:

Vertex Buffer Objects

February 7th, 2005

As much as I love DirectX, I’ve been using OpenGL for the past few weeks. This semester I started TA’ing for cse472 - Computer Graphics and OpenGL is used exclusively. Anyways, I’ve been making little demo’s and tutorials during the down time of my lab (ok and at night in my free time). Most of them are pretty boring and just show how to do some super-basic OpenGL features, but I thought I’d post this one because it looks kinda goofy.

Also, this is the first time I’ve done VBO’s in OpenGL so I thought I’d post it. While this extension isn’t exactly hard to use, it might be helpful for someone else doing VBO’s for the first time. Most of the example VBO code out there is either too basic or horribly wrong, so another demo couldn’t hurt.

Here’s the screenies. The program just loads up an image and creates a landscape from it based on the pixels intensity. I’ve still got one small bug, but I’ll deal with that later.



and


using my face as the input image looks kinda creepy huh? The source and executable are here, and it will require glut which you can get here.

Interviewing with Microsoft

January 17th, 2005

Looks like I’m going to be interning with Microsoft on the Windows Client Platform team (aka Avalon) this summer! Interviewing at Microsoft was the most fun I’ve had in a long time. Seattle is beautiful, and everyone I talked to during my interview was extremely friendly.
I wanted to wait to hear their response before I posted anything…but now that I’ve got an offer I’ll unload.
First the rundown of my trip, then some tips, and finally the specific questions they asked me.

Here’s the rundown of any whole trip in painful detail:

Saturday
———
-woke up at 4:00am
-got on my plane to Chicago/O’Hare (where I had a 2 hour layover)
-took a huge 777 to Seattle
-picked up my rental car (an Alero)
-missed my exit and I was lost within 10 minutes
-made my way (the long way) to Redmond
-checked into the Fairfield Inn
-went to the Cheesecake Factory for lunch with my buddy Casey and his girlfriend
-visited the space needle and rode the bumper cars with Dan Lash and my brother Steve
-met Shailish and a few interviewees from back home at Daniels for dinner (best steak ever!)

Sunday
——-
-drove into Seattle with my brother and went on the Underground Tour (highly recommended)
-Spent the rest of the day reviewing my interview preparation material and being nervous

Monday
——
-Woke up early to cool my nerves
-Arrived on Microsoft campus around 12:00 (my interview was scheduled for 12:30)
-shot the shit with other interviewers and played Xbox until my recruiter came and got me around 1:00pm (this really helped cool the nerves…now I was ready to knock them dead)
-I did a quick interview with my recruiter Rondell where he asked me basic interview questions and told me about the rest of the day
-He told me I would be interviewing with Shell and D2 for an internship this summer
-My first interview was with Shell and I felt like it went quite well
-After my first interview there was some confusion as to where I was going next. Apparently I was originally going to do another interview with shell, but after the day started they changed my second interview to Avalon.
-My next interview was great. I talked about my demo scene project and asked some good questions specific to Avalon
-After that I had another interview with one of the Avalon rendering architects. This interview also went really well because my interviewer a hardcore 3d graphics geek like me.
-Finally I interviewed with D2. They are a new’ish group formed from the Printing/Imaging group. This interview seemed to go well also, but was different from the others because I didn’t do any whiteboard problems.
-around 6:30 my interview ended
-I then checked out of my hotel and drove back into Seattle to pick up a little something for my girlfriend
-Got to the airport around 10, and took off at about 11:45pm
-Arrived in Chicago around 5am, and had a 3 hour layover
-Took a little jet back to Lansing and was home by 10:30am…very tired.

Now for a few tips for other people interviewing at Microsoft. Note that these tips are based on my experience alone. Things may be different for you, so just take it easy and use common sense.

1) Don’t overdress but don’t underdress. I didn’t see anyone all day in a suit, but I did notice that one of the other guys that was interviewing was wearing ripped jeans and a Microsoft t-shirt. That struck me as sloppy and I imagine it wouldn’t help his chances. You are still trying to leave the best possible impression in your interviewer’s minds, and so you should look good. I wore a sweater with a button down shirt underneath and felt comfortable all day.
2) Always ask what team your interviewers are on, they may not think to tell you. I made the mistake of assuming my second interviewer was on Shell (my first one was after all), and I felt like an idiot when I asked him 20 min. into it. I was elated that they snuck in Avalon to my loop, so I quickly got over this blunder
3) Constantly talk during white board problems…and evaluate even stupid ideas. I got stuck a few times and by putting out random ideas I was able to get back on track.
4) Write out function prototypes and compare/contrast all decisions. My first interviewer said I did a good job of not jumping into the code too soon.
5) Don’t forget error checking (obviously) and think about how to best convey error conditions.
6) If you come up with multiple ways to solve a problem talk about each one and compare/contrast time and space complexity. This shows that you are good at evaluating real world problems where you don’t always have a single solution.
7) Prepare to answer questions like “Why do you want to work for Microsoft”, “What was your most difficult project”, “Tell me about a time you worked on a team project”. These are so common that you need to have a solid answer with specific details.
8) Bring a water bottle with you. You are talking for like 5 hours, so you will need water. They have free soda, but it saves precious time to just bring your own.
9) Don’t forget receipts everywhere you go. Microsoft will reimburse for lots of stuff (even tourist things), but you need the receipt. I made the mistake of forgetting to pick it up after a very expensive dinner at Daniels. I’m not sure if I’m going to have to take a hit on this or not, but it’s safer to just remember.
10) Don’t take the red-eye flight home. It sucks trying to sleep on a plane.
11) HAVE FUN! I was nervous up until the day of my interview, at which time I was just really excited. They want to hire someone to fill their openings, so all you have to do is give them a reason.

Finally, my interview questions (the best I can remember them):
1) Why Microsoft?
2) Tell me about your most difficult project.
3) write a function (on whiteboard) that evaluates a basic math string like “1+4/2-(9+5)*7″
4) How would you store the data for a tic-tac-toe board, minimizing storage?
5) write a function to check if the tic-tac-toe board has an X (or O) at a column/row
6) write a function to check if a move causes the player to win tic-tac-toe
7) given an array of integers of size n, where each integer is in the range 1..m and no values are duplicated and m>n…write a function to return the smallest integer not in the array in the range 1..m
8) How would you debug a program that had heap corruption?
9) Tell me about a team project that didn’t work well
10) How would you explain the benefits of OOP to an expert in C who has never used C++?
11) What is your favorite programming language?
12) Do you have any questions?

I was probably asked 5-6 more questions that don’t come to mind at the moment, but these were the big ones.

Wow, two overly-long posts in a row.

Hope this helps…

More Avalon requests and bugs

December 22nd, 2004

I’ve been tinkering around with Avalon CTP lately (without actually making anything useful) and I’ve run into a few things that may be bugs. Also, coming from a web development background I’ve got a question that may be naive. First the bugs…

Here’s the short list of what I’ve found so far.
1) I get an InvalidOperationException when trying to use a VisualStyle for a Rectangle’s Style. This works with Button, and a Style works with Rectangle, but a VisualStyle in a Style does not work with Rectangle. In other words, this XAML file gives an exception, but the same thing with a Button works fine.

2) I made a XAML file with a Window that has a Grid that has a TextBox in one of the cells. This works fine when run standalone, but if I try to use a TextBox in a Grid from an Avalon application in Visual Studio 2005 Beta I get a UIContextAccessException. For example, this XAML file works fine, but making a new Avalon application in VS using this XAML file give the exception. Note that all I did was add the class definition, it’s virtually the same file.

3) This may be a VS bug, but it only happens with Avalon applications. When I run an Avalon application in debug mode from VS I get 99% CPU usage AFTER I stop debugging. This doesnt go away until I close Visual Studio.

That’s all for now. Please let me know if you get the same problems or if I’m just dumb.

Now for a request!

I think that it would be great if the XAML processor (and .NET 2.0 for that matter) supported XInclude. Why? Because Styles can get very complex and I feel that they clutter up the XAML file. What I would like to do is to define them in external files and then include them in the XAML.

This would have multiple benefits, the first is reusability. Imagine having a library of styles where each one is defined in it’s own file. I could then include just the ones I want and use them on multiple pages/projects. I can currently define styles in the application xaml and use them in multiple pages, but I still cant define styles in stand alone files (At least not that I’m aware of).

The second benefit deals with separation of concerns. I am not a graphic designer, and I’m glad for that. Instead I write code and I use the resources that the designers make. Long ago I learned that when making webpages the easiest way to get things done is to separate the graphic design completely from the page markup. This means my code should generate XHTML with lots of div’s so I can then hand that off to a graphic designer and he can do his CSS magic. Meanwhile I can work on other things and feel good that everyone is working nicely in parallel. The key is to give the designers some XHTML early on, so they can build the CSS based off it, and then I can use the same div classes for the rest of the website. The best part is that the designers don’t have to deal with code and I don’t have to deal with design issues, things just get done faster that way.

Now to translate this to XAML there are two scenarios. First, I could be making some standalone application where I make a XAML files with programmer art for styles. Then I give this to a designer and tell him to make it sexy. The designer doesn’t want to see my 500KB page just to make a button style, he just cares about the button. I don’t want to see a 500KB style, I just care that my button uses a style. Solution: separate the two. The designer can work incrementally on making my button look sexy while I work on making the UI. If I had xinclude I wouldn’t ever have to manually merge the designers XAML with the UI XAML. Now, I’ve moved on to another application and I want a similar button. Simply xincluding the xml for that style only makes sense. The designer can then make a change to the style file and the next time I compile both projects the button style will be updated automatically.

The second scenario may or may not be the intended use of XAML. I can imagine that after Avalon comes out, some people will want to use it as a replacement from HTML. I’m not talking about making a web application that is hosted in IE, I’m talking about dynamically generating XAML much like HTML is currently dynamically generated on a page by page basis. Not only would this mean the user wouldn’t have to download a whole application, but also it’s an easier transition for existing sites. So the problem is that these pages wouldn’t be part of an application, they would be stand alone XAML files and each one would need to include all of the styles that are used. If instead XAML supported XInclude, the styles could be defined externally and downloaded once. They could then be cached for the remaining pages and save the client some downloading.

This post is already too long for such a simple request, but now that my fingers are warmed up I’ll go on with a question. This has little to do with the above babble, but rather something that I’m missing from my understanding of XAML. How is the current styling system going to support application themes? I’m talking about defining multiple themes (sets of Styles) that the user can pick from at runtime, and the applications UI will be styled to their liking. The way I understand Avalon is that the XAML is more or less transformed into code and then compiled into the assembly. My lack of understanding is in what the “{someStyle}” syntax is actually doing. Is this telling the XAML parser to look in the resource dictionary, and insert a reference to the style referenced with the someStyle key? Is this lookup done at compile time or runtime? Even if it’s at runtime, changing the style in the resources won’t affect UI elements that are already created. I’m curious if there is any built in support for this scenario? Would I have to write code to go through all the element and reset their styles based on a theme, or is there some way to tell all the controls to re-lookup their styles in the resource dictionary based on how they defined in the XAML. I didn’t see anywhere that they style’s name is stored in the control, so I suspect it may be done at compile time. Anyone care to fill me in on this gap in my understanding? I’m probably over-thinking this…

Wow, sorry for such a long post. I wouldn’t have read it, but at least it’s nice to get some thoughts out of my head.

HL2 on my tablet

December 22nd, 2004

Halflife 2 actually runs fairly well on my Toshiba Portege M200 (1.7GHz Pentium-M). The graphics settings certainly aren’t maxed out, but it still looks quite good. Playing a first person shooter with the stylus was…well…fun.

I think I better get one of those little laptop mice if I’m going to continue.

Tablets and cleartype, and a requested feature of Avalon

December 15th, 2004

Currently, tablets and cleartype don’t mix. Well, not in portrait mode at least. Why is this? I’m going to tell you! Read on.

Cleartype is an extremely cool technique for making text look good on LCD monitors. As you may or may not know, LCD monitors typically have rectangular pixels that are split into red, green, and blue parts horizontally. This is in contrast to many CRT monitors that use an alternating triangular configuration. Cleartype takes advantage of the layout of the subpixels (each color channel in a pixel) to give an effective 300% increase in horizontal resolution. This is especially important for small text because you don’t have many pixels to work with and that 3x horizontal resolution can really make the difference in readability.

So why on earth would running your tablet in portrait mode make a difference? Take a look at this picture from Microsoft’s typography site.

This shows the subpixels blown up, and how cleartype works. You can see at the top of the “f” that the cleartype only does the subpixel rendering in the horizontal direction. This is to take advantage of the horizontal subpixels, so you get the appearance of 3 effective pixels per true pixel…but only in the horizontal direction. The XP implementation of cleartype supports LCD’s the have the pixels in RGB and BGR configuration, but not
R
G
B

or

B
G
R

so when you turn your monitor into portrait mode, the horizontal subpixels become vertical, and cleartype starts to look like crap-type.

Try this:
From landscape mode, run the accessibility Magnifier. (it turns off cleartype, so turn it back on.) Zoom to 9x and look at some text. Predictably, black text will look kind of colorful horizontally when zoomed because you can see the subpixel rendering. For example, the top of an “F” will be black, but the vertical stroke will probably be kind of red and blue because of this. Now turn your LCD into portrait mode (and obviously turn your tablet upright). The zoomed text still looks the same. IT SHOULDN’T. In portrait mode your subpixels are vertical, so the “F” should be black on the vertical stroke, and should be red/blue on the top horizontal stroke. XP continues to do cleartype horizontally and it’s very bad looking. It would be a simple change to fix this, but I don’t think it’s an available option in XP.

And this brings me to my requested feature for Avalon. Please support vertical subpixel layouts in Avalon. It should be a simple matter of doing clear type vertically instead of horizontally. I assume this is done with a pixel shader, so it should be an extremely easy feature to implement. Moreover, the Longhorn version of Windows should allow you to setup cleartype with 2 profiles on a tablet. One for portrait mode and one for landscape mode. Or they could get smart and require the display driver to tell Windows how the pixels are laid out physically, and account for the portrait/landscape thing automatically.

Over and out.

ArtRage, a digital canvas

December 9th, 2004

Many graphics programs are floating around out there that have paint brushes, pencils, markers, etc…but a program called ArtRage takes it to a new level. This is the first program I’ve seen that makes you really feel like you’re painting. The paint brushes on the canvas unevenly and with bump mapping. You can scrape the paint to smooth it out and blend it with other colors. Painting with red on top of blue paint will cause the two to smear together. You even have to clean your brush. Obviously it works best with a tablet, but it’s fully functional with just a mouse.

Here’s my first attempt at painting. And, no this masterpiece is not for sale. ;-p

BTW the software is FREE! So go download it, give them feedback, and have fun painting!

my handwriting font

December 8th, 2004

one of the tablet pc powertoys allows you to quickly (less than 5 min) make a font that looks like your own handwriting. I’ve always wanted my own font!

Download my font here.

it look like this:

the new tablet

December 8th, 2004

I finally got my new tablet PC today and I must say I’m loving it. I got the Toshiba M200 with a 1.7 Ghz Pentium M and 512 MB of ram. (mostly due to the higher than 1024×768 resolution)

Here’s a picture of me with my new baby.

my take on it so far:

1) The handwriting recognition HATES my normal handwriting. I use all caps, and it doesn’t like that. I quickly found that it loves cursive, so after a few hours of remembering how to write like that I’m rocking out. It’s actually kinda nice to re-learn cursive because the pen glides nice and smooth over the tablets screen.
2) The tablet power toys are amazing (well some of them). The physics simulator is particularly impressive.
3) OneNote is also amazing. I took notes in my Advanced AI class today with it and it was so easy to use. Mad props to the wizards that created it.
4) The battery life puts my old laptop to shame. I am so use to always having it plugged in that it blew my mind to go most of the day on a single charge.
5) I only have one pen, and I fear it will be lost by the end of this post. I think a replacement pen would make a good stocking stuffer (yes mom, i’m looking at you)
6) I love drawing shit. yes I said shit. That’s all I can draw right now, but I’m getting better. This thing came with Alias Sketchtbook Pro trail and I’m getting my 15 days worth.
7) I didn’t even realize it when I bought it, but it has an SD reader built in, so that just makes transferring my picture over easier.
8) EVERYONE SHOULD BUY A TABLET FOR CHRISTMAS

I really do think that tablets are the way of the future. Not just for portables, but I think it would be cool to see the pen technology built into LCD’s. The UI’s of today have been geared toward keyboard and mouse for nearly 20 years, so it’s going to take along time before you can throw them out, but having a pen on every desktop would really change how UI’s are designed.

Add the inking API to the list of things to play around with over winter break…

Avalon font animation

December 6th, 2004

Ian Griffith is the man. After I posted about not being able to animate the font size he went ahead and did it. He’s posted the code on his site and more importantly got the attention of Elizabeth and Matt from the Avalon Animation team (via Chris Sells).

While Ian’s solution is really cool because it shows how to roll your own font size animation, the Avalon teams response reveals that this feature is infact already present via TextEffect. I’ll have to look into that over winter break.

Ok, on a totally different note, this was my first post using a tablet PC. It took too long to hand write it, but I’m getting faster as I go along. Im using my bosses Tablet, but mine should be arriving soon. I can hardly wait.

XAML thoughts

November 21st, 2004

I got the new Avalon preview on XP last night and spent about 8 hours (ok, maybe 14) reading the docs and playing with XAML. IT BLOWS MY MIND. I really think WinFX this is going to fundamentally change applications of the near future. I’m not just talking about bouncy-rotating-colorchanging buttons, I’m talking about new user experiences. I have tons of ideas brewing already, but I’ll save them for another post. Right now I just wanna point out a few things I’ve noticed that you might want to be aware of or stay clear of.

1) Because Avalon is built on my favorate api (Direct3D) it tesselates rendering primatives into triangles. This includes text. Under normal use you will never notice because as the font gets bigger, it tesselates the text finer. This means FontSize 500 will have lots of triangles and very smooth curves. BUT, the problem is that it tesselates based on the FontSize. If you scale the text (think ViewBox or TransformDecorator), it does NOT retesselate and you may notice the blockiness.

You might be thinking “Big deal, you told it to scale, so that’s what it did!”. But there are reasons for re-tesselating. Imagine being able to pan/zoom your desktop…kinda like virtual desktops but Avalon style. If you dont re-tesselate when you zoom in all of the curved shapes (not just text) will be noticably blocky.

To see what I mean, take a look at the difference between test1.xaml and test2.xaml.
null

[UPDATE] I just noticed that if you open up test1.xml with a large window it will be blocky. Then slowly shrink the window and at some point it pops from blocky to smooth. I dont know what’s going on here…

[UPDATE 2] Save As the xaml files from this post, because my webserver doesnt like them.

2) FontSize is not animatable. You typically just set FontSize with a number like FontSize=”32″ but it is not actually a number, but rather a structure. This means you cant use DoubleAnimation or Int32Animation of anything on it. I think they should have a FontSizeAnimation. I think they dont have it animatable because tesselation is too slow and they can’t do it without killing the frame rate. It seems like they could cache several LOD’s of the glyphs to improve the performance. Games do this often.

3) ImageEffects could be very cool but they aren’t very usable yet. Hopefully this will change as it gets closer to the release. They are VERY slow, they mess with ClearTyped text, and finally it’s hard to not get articacts like these:
test3.xaml and test4.xaml.

4) VS 2005 beta 1 has intellisense on XAML but it’s not very good/reliable yet. I KNOW this will change soon. I’m pretty sure the schema is just old and doesn’t have all the possible tags/attributes. For one it doesn’t like TransformDecorator as the root node. (yet this compiles fine)

5) I didn’t see anything in the docs about inking, but I hope that they take the opportunity of starting fresh with the UI and add better pen input support. How cool would it be if you could click on a text box, a small pen input button would appear like with Windows Tablet PC 2005, but when you click it, Avalon zooms in on the text box and you can write on top of it ranther than a seperate window.

Just throwing some stuff out there. I’m planning a simple Avalon based game (kinda like the hang man example) to get more practice, so I’ll post that soon.

Halo 2 beat, bring on HL2

November 14th, 2004

Tomorrow night at midnight I will be in geeky-nirvana. My pre-cache on steam has been mocking me, but I’ll show it who’s boss in due time.

Here is the game plan for tuesday morning (monday night in my book):
12:01am - Finish downloading HL2 final cache
12:03am - setup my controls and video options (if it doesnt keep them from CS:S)
12:04am - begin playing the could-be greatest game of the year (if not ever)
12:20am - pause game play and reflect on how truely great this game is
1:00am - close HL2 and fire up HL:S to see what’s new.
2:00am - go to sleep and dream about more HL2.

and that’s it until christmas break. I have so much school work that I can’t get sucked into it before finals are over. I think I might explode.

EA is NOT a good company to work for

November 10th, 2004

Jason Olson pointed out this. Read it and post similar experiences in my comments. I wouldn’t have a problem with working overtime (read: 50-55 hours/week) for a month or so to get a project done on time, but this is just ridiculous. Makes you wonder how many other companies do this to their employees.

What do you think the best way to send a message to EA is? Passing the link around is a start, but I kind of don’t want to buy anything EA makes now. Unfortunately this could hurt the very same dev’s that this lady is writing about, but it could send a message to EA. Any better ideas? Any similar stories about other companies?

Choosing between a turd sandwich and a giant douche

November 2nd, 2004

I went with the turd sandwich. I hope he wins.