" /> Primordial Ooze: July 2004 Archives

« June 2004 | Main | August 2004 »

July 26, 2004

Cool Fractals

I just downloaded a trial version of Ultra Fractal 3. Why? I happened upon it and I can't remember how.

It's written in Delphi, of all things, and I must admit I'm impressed by the feature set. The programmer basically created a fractal program that does everything you would expect a fractal program to ever do. From a high level, the Ultra Fractal 3 has these impressive features:

  • Renders fractals in true color.
  • Renders fractals on layers, which can be freely mixed.
  • Renders to PNG, Adobe Photoshop native format (for layers), JPEG, etc..
  • Renders fractals based on user-defined formulas, including a bunch of pre-made formulas.
  • Connects to a user-formula site on the Internet and can download new formulas on the fly.
  • Distributes fractal rendering using a Ultra Fractal Server process that can be placed on machine on your network.
  • Complete control over color gradient, layer transparency, zooming (up to 1040000!), and lots more

So, what's the big deal? Check out what the community has produced:

 

After googling further, I was more and more amazed.

From what I understand, fractals are created by testing whether an arbitrary point satisifies an equation. I think this means whether a point is within the set or outside of the set. It's possible that the first test is indeterminate, so a more precise test is performed. This subsequent test can also be indeterminate and the process continues until the point is found to be in or out of the set (satisfying the equation, or whatever). Depending on how many increasingly precise iterations are performed, the color is defined within a gradient spectrum.

I've seen ray traces that used each iteration as an elevation point and some spectacular results have been produced. Here are a few images I found on the web:


(written with POV ray tracer)

Then you can get really crazy with something called Quaternions, which are more sophisticated than simple height-models like I described above. Check this out

Check out these videos and this amazing gallery.

 

July 22, 2004

Look out Luna, Royale is here!

I downloaded a leaked version of Microsoft's Royale XP theme, which was originally developed for their Media Edition 2005 beta. This all happened almost a month ago, but I'm just about that far behind on my blogs. More information here, here, and here (random Google links).

Anyway, it seems like the horrid over-use of gradients in Office 2003 is not  the fault of Office 2003 after all, but of the default XP theme, Luna. After installing Royale, Office 2003 looks like this:

My task bar looks like this:

If anyone has used the latest Yahoo! Messenger, they'll be familiar with this glassy look as Yahoo! went and used the Theming API's to make their latest offering look, well, delicious.

July 21, 2004

Shadow on the rings of Saturn

I like to see pictures taken of the planets that could not possibly be taken from an Earth-based camera.

Read more here: http://antwrp.gsfc.nasa.gov/apod/ap040721.html

July 19, 2004

I, Robot—I, Saw It

I wrote about the movie way back in March when I saw the original trailer.

Well, I'm glad to say that I didn't boycott the movie. It was good, real good. Asimov would have enjoyed it. The movie is good for a laugh, good for the action and special effects, and quite surprisingly, good to ponder on... ponder about... whatever!

Go see it.

 

 

July 16, 2004

On the way to partial classes, I nearly pulled out all of my hair...

I have an project written in Visual Studio .NET 2003 at home. Around midnight, I get the bright idea to take my two forms and convert them to the newer style of form, which uses partial classes to separate the designer-inserted code and the user-code for a form class.

Great.

The first step was to remove Main() from my form. When you create a new project in Visual Studio .NET 2005, you get a Program.cs file which contains the global main. It looks like this:

#region Using directives using System; using System.Collections.Generic; using System.Windows.Forms; #endregion namespace WindowsApplication1 { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.EnableRTLMirroring(); Application.Run(new Form1()); } } }

The ApplicationModel class above is my experiment, not default code. The second step is to divide your form class into two sections. So, I generated a new project and used it as a reference. I noticed a few things:

  • The designer class dosn't show up in the IDE's file list. I saw in the csproj file (a simple XML file) that the designer file is simply a dependent file to the main form file that you own.
  • The designer file has the definition for Dispose(),
  • It is home to all of your control member variables,
  • It doesn't specify a base class (this is done by your main form class, though no error is generated if you re-specify it... this has some interesting implications).
  • Finally, the designer file declares the components IContainer variable.

So, in about 5 minutes I cut and paste myself into a corner and was left with a form with no controls on it and multiple compilation errors.

I resolved the compilation errors and guess what? I still have a form with no controls on it.

I decide to re-do my entire form, using my old form as a reference. Note that it's about 12:30am and I'm getting tired.

Now I have a form with controls on it, but the designer code is inserted into my regular class file and not the designer file.

Bitch!

I decide to go to bed, leaving my code in ruin. This is almost as bad as going to bed mad at your spouse. I really wanted to make up with the code, but it left me on the couch and a fitful sleep it was.

 

July 15, 2004

if comparisons in properties

In C++, when I compare variables against constants and "value" in a property "set" method, I put “value” first like so:

if (value == _myProp)

This habit prevents the following catastrophic typo:

if (_myProp = value)

For most types, this statement won't compile in C#. The resulting statement is equal to the resulting type and the if clause expects only a bool. The above line would fail to compile If _myProp were an int. Seeing this for the first time, I was almost ready to switch back to the more attractive form:

if (_myProp == value)

Then I thought what if _myProp is a bool? As you can expect, the line compiles just fine. Therefore, I'm back to the "safe" form of the if statement:

if (value == _myProp)

 

July 12, 2004

Mono 2.0

I see on the Mono web site, that they plan on delivering Mono 2.0 around Q2 2005. Not coincidentally, they plan on providing updates to System.Xml, ASP.NET, and Windows Forms to match the .NET 2.0 API.

I'd love to experiment with writing assemblies in Windows and deploying them on MacOS X. Is that possible? I suppose as long as the referenced libraries are available (like Windows Forms), this should work right out of the box.

I've pretty much decided that my mapper program is going to be written in C# 2.0 running under the .NET Framework 2.0. This ties me to the "Whidbey" timeframe, but that's ok. I can be in beta for a very long time and get lots of feedback.

Getting back to Mono, I also see that Code Access Security (CAS) is missing. This basically means that all applications running on Mono require/have full trust capabilities.

If you want to read more about the Mono roadmap, go to the Mono Roadmap page, which has lots of interesting info.

July 10, 2004

Scrollable control fixed in 2.0 Framework

In my first .NET Annoyances post, I talked about how the ScrollableControl class was broken. There was no way to be notified when a scroll occurred. Well, this seems to have been remedied in the .NET Framework 2.0.

All I had to do was to write a delegate to handle their new Scroll event. The new Scroll event addresses my earlier concerns about knowing the type of scroll. They address this with a new ScrollEventArgs class, which has a Type property of type ScrollEventType.

Anyway, life is good now.

Microsoft Visual C# 2005 Express

I downloaded Microsoft's new Visual C# 2005 Express beta today. Here's a [very] brief overview of my experience.

Installation

You can get the distribution here: http://lab.msdn.microsoft.com/express/vcsharp/

My hopes are that the beta won't mess with my existing installation of Visual Studio 2003. So far, the experience has been a pleasant one.

The installation has minimal steps to it, but it had some quirks. After installing the .NET Framework 2.0, I had to reboot. When my system restarted, the ISO image wasn't mounted so the installation halted with an "Abort, Retry, Cancel"-like message. I mounted  the volume and said retry, but that didn't work. I restarted the installation and it picked up right where it left off.

My version installed these components:

  • Microsoft .NET Framework 2.0 Beta
  • Visual C# 2005 Express edition Beta
  • Microsoft MSDN Express Library 2005 Beta
  • SQL Server 2005 Express Edition Beta

I'm writing a little Battlemap program in C# using VS 2003 and I'm going to try and code it up in the beta for a little while. If I send the build to anyone, they will have to install the .NET Framework 2.0 Beta 1 distribution.

Project Migration

Project migration from VS 2003 was a snap. In fact, a Wizard came up and asked me if I wanted to backup my project in case the upgrade didn't go well. I had no problems.

Editing

It's fast! Invoking the IDE is fast and editing is butter smooth.

I use a plugin called C# Refactory from XtremeSimplicity for refactoring in Visual Studio 2003. However, the refactoring support in the beta seems more solid. I guess that feeling is mainly based on the fact that the refactoring dialogs are invoked much more quickly.

There are numerous other editing enhancements that I'm sure to like, but I won't go into them here.

Designing

What can I say? The beta's form designer is light years ahead of where it was in VS 2003. The toolbox is organized better and gives you a better idea of where your components and controls are coming from.

Help

Finally, MSDN help is integrated both locally and on the Internet. If a help item isn't found locally, it searches the Internet. It took way too long for this to happen.

Conclusion

The download is small (267MB) and it seems to work side by side with my regular development tools. I'll find it hard to go back to VS 2003.

 

July 6, 2004

.NET Annoyances #1

The Annoyance

I have a control that derives from System.Windows.Forms.ScrollableControl. Great. I write my control, which is a kind of square grid that extends beyond the Window's bounds. Great. I scroll my control and see that my control is not repainted the revealed areas. Curious. I think to myself, oh, simple, I'll just override the scroll event and invalidate my Window. I mean, a ScrollableControl has to have a bloody Scroll event, right?

Wrong!

There is no scroll event for a Scrollable Control. I thought I would inaugurate my new column with a gem like this. Providing a Scrollable Control that doesn't have a Scroll event is like providing a custom control that can't be customized. Or, to put it in everyday terms, it's like going into a candy store with your son and leaving without buying him so much as a lollipop.

The Solution

I wanted my lollipop. As usual Code Project came to the rescue. However, once I saw the solution I kicked myself since I should have thought of it myself. The key to the solution is the override of the WndProc and simply handling the WM_HSCROLL, WM_VSCROLL, and SBM_SETSCROLLINFO messages. Here is the class that I found on Code Project, written by Martin Randall:

    public class ScrollableControlEx : System.Windows.Forms.ScrollableControl

    {

        private sealed class NativeMethods

        {

            public const int SBM_SETSCROLLINFO = 0x00E9;

            public const int WM_HSCROLL = 0x115;

            public const int WM_VSCROLL = 0x114;

        }

 

        [Browsable(false)]

        public Point ScrollPosition

        {

            get { return new Point(-AutoScrollPosition.X, -AutoScrollPosition.Y); }

            set { AutoScrollPosition = value; }

        }

 

        public event EventHandler Scroll;

 

        protected virtual void OnScroll()

        {

            if (Scroll != null)

            {

                Scroll(this, EventArgs.Empty);

            }

        }

 

        protected override void WndProc(ref Message m)

        {

            base.WndProc (ref m);

 

            if (m.Msg == NativeMethods.WM_HSCROLL ||

                m.Msg == NativeMethods.WM_VSCROLL ||

                m.Msg == NativeMethods.SBM_SETSCROLLINFO)

            {

                OnScroll();

            }

        }

    }

 

Discussion

 

If your drawing is particularly expensive, you probably want to invalidate only the portion of the Window that gets exposed as a result of the scroll. The above code doesn't do that since the Scroll event doesn't contain the needed information. This information is contained in the low and high words of the WParam property of the Message class shown above. In addition, you'll need the page size found in the SCROLLINFO structure (see the Win32 SDK).

 

A more complete implementation of this extended class would provide this information to the Scroll event so you should be able to invalidate the proper portions of the display.

 

In my case, invaliding the Window was fast enough so I didn't bother. If this changes, I'll write up the solution and post it.