Thursday, February 13, 2020

I Heart Delphi

On February 14th, 2020, Delphi celebrates its 25th anniversary.

Wow.

It's no secret that I'm an unapologetic Delphi fan. I like the language, the IDE and the community. I've had the pleasure of meeting and working with some uncommonly smart people. But the reasons I keep using Delphi for serious projects are mostly practical. The longevity of the product (whither SilverLight), a high degree of code compatibility between versions, wicked fast compile times, XCopy installs, Code that's easy to read and therefore maintain, etc. Things that make me more productive and help pay the bills.

But that's a conversation for another day.

Since Delphi's anniversary falls on February 14th, Valentine's day memes are always appropriate. This seems like something you could have some fun with.

I thought it might be interesting to use Delphi and FireMonkey to draw one or two unusual heart shapes. And maybe a little bit of animation. Ooh, and 3D... One thing led to another and the project experienced what could generously be described as "feature creep".




The source code can be found here. Some of the code is a little quick and dirty, so it could probably stand some refactoring. Eventually.

Here's what made the final (so far) cut:

Pixelated


Using a two-dimensional array where non-zero elements represent pixels in this low-resolution heart.

Elements with numbers greater than one are for later use.

Graph


Based on an image with simple coordinates like you might draw on graph paper.

Heart Equations


Using a few of the many equations that draw heart shaped curves.

Sine Wave


Another equation that draws different variations of a heart shape as you change the frequency. I had to tweak the equation a little from the original.

Times Table Cardioid


Inspired by this Mathologer video, we create a curve using straight lines. Cardioids are cool and show up in lots of different places.

String Art Heart


Similar to the cardioid, but following a different pattern.

Mandelbrot


There's that cardioid shape again. This is the single most complicated shape in the application. Fortunately, I could reuse code that I wrote for a user group meeting and before that, I had lots of help understanding the math.

Delphi Heart


I know that the "DX" logo was officially adopted, but the Spartan helmet still says "Delphi" to me.

Maple Leaf


So, you might be asking yourself what this has to do with Valentine's day. Or Delphi.

A maple leaf and a heart can be used interchangeably. Everyone knows that, right?

3D Scene


This brings us back to the pixelated heart, but with rounded cubes. And those array elements with numbers greater than one? They're used to add depth.

The fading and zooming were surprisingly straight forward using TAnimator and running a bunch of different animations simultaneously.

1 comment:

Warren said...

Wow the time has flown eh?