What that? UI Stuffs?

Pictures are always more fun than text…

One of the many graphics books I have is simply “Computer Graphics”, by: Amarendra N Sinha, and Arun D Udai.  I picked this book up in India a couple of years back.  The copyright is 2008.  It’s kind of an interesting book because it talks about quaint subjects such as cathode ray tubes, light pens, glove input devices, as well as pen plotters.

Many of the programming examples are written using TurboC! (Gasp)

But, for all it’s quaintness, it covers topics such as scan conversion of graphics primitives, mouse input, matrix math, space curves and surfaces, and the like.  All of this in about 470 pages, including pictures, and embedded code listings.  It’s quite a dense and readable book, complete with color pictures.  All this came at a price of 395 rupees (roughly $10 USD).  Considering any graphics book I purchase in the US is a minimumn of about $50, this book is quite the bargain.

One of the most nifty things I like about the book is that it has nice illustrations in it.  While I was going through different things, I got to thinking, how hard can it be to actually represent these things in Banate CAD?  Of course I’m already doing the basics to represent things like lines, curves, surfaces, and every manner of geometric object, including text with full font support, so why not basic illustrations as well?

Another book that I have is: “Algorithms In C++ (Third Edition)”, by Robert Sedgewick

Now this book is way cool.  First printing in 1998, now it’s in it’s 19th printing.  This is the source for many an algorithm study, including sorting, searching, data structures, etc.  Now, this book is very cool not only because of the treatment of the various subjects, but for the illustrations as well.  These illustrations are even more interesting because there is an animation component to them.  The above image shows the progress of a selection sort algorithm.  The code in HeadsUp is quite simple.  Basically I just map the array indices along the x-axis, and the value of the element at that position along the y-axis.  If the animation is simply run, you see the elements drop into their proper order one after another in rapid order.

This is really good because you can visually inspect whether your routine is working properly or not. You can also fairly easily calculate the order of the routines.

This is where things get much more interesting.  This is another animation.  Of course, with animations, enough words can not be used to explain what’s going on.  When you run this script in HeadsUp, you see those circles pulsating with the outline color, and the little red dots shooting from left to right.

Which begs the question.  When will BanateCAD be able to export animations as movies, or something interesting like that?  Well, wouldn’t it be interesting if one of the export formats was an animated GIF or .mpg, or something?  Well, surely that can’t be that far off.

One more for the road…

Another thing I find in a lot of the books that I read are these curly brace things.  Here’s where things get really interesting.  In order to construct such a thing, I want to actually layout a path using bezier curves, line segments, arcs, and the like.  So, there is an object for that.  The ShapeBuilder is a nice little object that has an interface like this:

AddBezier(pt1,pt2, pt2)

With this sort of interface, you can fairly quickly layout shapes of any variety, including fancy shapes based on superellipse, and other formulas. Then of course there’s the connection to UI elements. Take for instance the lowly Button. It’s just some drawing with the ability to respond to mouse and keyboard actions. The drawing can be anything, as long as you can respond to whether or not a point is inside or outside the drawing (hit detection).  But, that’s a coming exercise.

One of the things I’ve been contemplating is how to rapidly turn some objects into graphs that I can use.  I have been considering SVG, and DrawingML primarily.  Both of these formats have tons of graphics material available.  They’re both XML formats, so they’re fairly easy to deal with.  I might lean towards DrawingML primitives first, because these shapes are more meant for graphs, and that’s what I want to use them for.  On the other hand, there are plenty of SVG parsers in the world, which makes it fairly easy to consume those.

At any rate, they both simply represent a persistant format for vector graphic information.  The core system (BanateCAD) has to be able to render the same primitives, no matter which representation.

One interesting side effect of going down this rabbit hole is that I am also able to rasterize 2D primitives.  If you’re thinking in terms of 3D printing, you know this is a good thing, because layer slicing is essentially about rasterizing on a local level.  So, we’ll see how this shapes up.

And so it goes.  Progress continues towards visualization, and 3D modeling.

As an aside, I’ve separated out the many BanateCAD examples into their own project.  I was finding that as I add more and more examples, the directories were becoming unwieldy.  Now, when there is a release, there can be a separation between the package proper, and the set of examples that one might to play with.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s