*Coder Blog

Life, Technology, and Meteorology

Month: November 2006

Midwest Snow Storm

If you live in the Midwest, either you are getting hit with this storm right now or you will be getting hit with it soon. This storm has the potential to be the first big snow for the year in many areas. The forecast models have been all over the board with predicting this event. At least, that was the case up until earlier today when the 0Z and 12Z runs of the GFS and NAM, along with some other models are now much more agreeable with this storm’s track. When the models line up, that’s a pretty good sign of an accurate path.

The image below shows the precipitation forecast for Friday between 12 and 18Z (7am – 1pm EST). Right now, this system is starting to form in Texas. The storm will be traveling NNE over the next 36 hours to around Ohio in the time period of the image below. The precipitation “arrow” is pretty much pointing in the direction this thing is moving. The lightest blue is between 0.75 and 1 inch of liquid equivalent precipitation… However, if you follow the deep blue line marked 0 degrees C, all of this area will be getting either a rain/snow mix or all snow. 1 inch of liquid precipitation can equate to anywhere between 6-10 inches of snow depending on the temperature. Since this image just shows the precipitation for a 6 hour time period (and not the entire storm’s precipitation), there is a real potential of a bunch of snow being dumped along it’s path. Some models have forecasted up to 17 inches here in central Michigan, but I think that’s really overshooting it. I’m guessing it will drop around 6-8 inches of heavy snow for our area, and definitely more in some other areas.

Anyway, here’s hoping we’ll get enough snow to go sledding this weekend. 🙂

Mac360 Reviews Seasonality

I’m a bit behind on this one, but a few weeks ago Jack Miller over at Mac360 reviewed Seasonality

It’s one thing to know if it’s sunny or cloudy, cool or cold, warm or hot. Many Mac utilities give you quick access to the weather.

Seasonality becomes your weather center. It does everything but control the weather.

I ran across a problem in the latest betas of Seasonality where the graphs would show up blank when printing. It took me awhile to fix this issue, so I thought I would post my solution here in the hopes that it might save someone else time in the future. Here’s a screenshot of print output before the fix:

The problem is that the Seasonality graphs are drawn using Core Graphics routines instead of the higher-level Quartz routines. I did this to squeeze a little more speed out of the drawing code, and also gained more customization with transparency settings and layered drawing. Basically, I grab a CGGraphicsRef using [[NSGraphicsContext currentContext] graphicsPort], and use it to draw all the other elements.

From what I could find online, it seemed that the problem was that while printing, the context isn’t referenced until later than it is when drawing it to screen, so the context doesn’t stick around long enough for the printing code to pick up on it and draw. So either I could find a way to retain the graphics context long enough for the printing to complete, or I could find a new way to draw my view for the printer. I didn’t want to retain a graphics context object because I think that makes the code a little messy, so I tried to find a new way to draw my view.

The first thing that came to mind was to not use all the Core Graphics routines to draw the graphs when printing. That would be a very large code change, and it’s a lot of extra code that isn’t used too frequently. The better solution I found was to draw everything to an NSImage first, and then draw the NSImage to the printer. Here’s some code…

- (void)drawRect:(NSRect)rect {
   NSImage *lockedImage;
   BOOL printing = ![NSGraphicsContext currentContextDrawingToScreen];
   if (printing) {
      lockedImage = [[NSImage alloc] initWithSize:rect.size];
      [lockedImage lockFocus];
   }

   // Get our graphics context.
   CGContextRef cgContext = [[NSGraphicsContext currentContext] graphicsPort];

   // Drawing code here...

   if (printing) {
      [lockedImage unlockFocus];
      [lockedImage drawInRect:rect
                     fromRect:NSMakeRect(0, 0, rect.size.width, rect.size.height)
                    operation:NSCompositeCopy
                     fraction:1.0];
      [lockedImage release];
   }
}

Here’s a screenshot of the output after the fix:

This solution has a small disadvantage, you don’t get the ability to print using the printer’s full resolution. Since Seasonality users don’t print too often, this tradeoff is okay, but it might be an issue to consider for other applications.

Experience Colombia

Logtar posted a pretty cool video about the country and culture of Colombia. It’s part of Proyecto Colombia, a website he created to inform people of the finer aspects of Colombia and to counter negative portrayals of the country made by the media.

© 2017 *Coder Blog

Theme by Anders NorenUp ↑