|
I'm wrapping up alpha channel/alpha blending support in my graphics library.
It's really cool, but it highlighted a bunch of issues with my drawing routines - particularly my ellipse and arc drawing routines.
As it happens, they are drawing in the same place more than once for part of the draw operation, leading to - say you have yellow with an alpha of 50% - well if you layer it on itself you effectively get a yellow with an alpha of 75% so that's not a happy thing to draw twice with alpha blending.
I need to retool my drawing.
However, this highlights a performance issue as well, as the less I draw, the faster things go, so this is both setback and opportunity.
I'm really proud of the alpha channel support. It was not trivial to do, since there's no hardware support for it.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: particularly my ellipse and arc drawing routines Good old Bresenham, I assume?
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
not quite. there's a variant of it that does a mirrored technique so it only computes one corner, and then it uses integers to compute successive "widths". I'm not sure what it's called. There was a description of it on tutorialspoint and I used that as a guide for implementing it.
Real programmers use butterflies
|
|
|
|
|
Careful here. Exploiting symmetry is not a bad thing, but it might lead to having a SetPixel(x,y,color) method. That's a performance killer for Bresenham-type algorithms because of the address calculation that has to be done at every call. I prefer to have a memory pointer that is only incremented for horizontal steps or needs only a simple addition at every vertical step. Drawing a circle as four line segments (one for every quadrant) this way may be a lot faster than exploiting symmetry at all cost.
Maybe you should take a look at this old book from the days of Doom and Quake: Michael Abrash's Graphics Programming Black Book Special[^]
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
I used to own that book.
I only use setpixel when drawing outlined ones, and line segments when drawing filled ones.
however, I have been meaning to optimize the former to use line segments like my line drawing does. horizontal and vertical line segments are fast, because you can address entire rectangles at a time and set the color. I haven't gotten around to it yet. With alpha blending it doesn't matter anyway - i have to draw pixel by pixel.
I don't gain any advantage for drawing diagonal lines using this system, because of how most of the displays work.
Real programmers use butterflies
|
|
|
|
|
Nice.
It's not often that adding new features improve performance!
|
|
|
|
|
|
That's still amateur level. Next level is to tell them the truth and not say anything directly at all:
"Do you think I'm fat?"
"That's the smallest of your problems."
Instant stack overflow. If they can't love me, they shall fear me.
I have lived with several Zen masters - all of them were cats.
His last invention was an evil Lasagna. It didn't kill anyone, and it actually tasted pretty good.
|
|
|
|
|
Sometimes I wonder about F#...
I remember a while ago I spent the effort of learning all the syntax and then.. I dropped it.. perhaps because I found it hard to interact with F# and not worth the effort for only fuzzy benefit...
Can anyone enlighten me and motivate me to give F# another try?
|
|
|
|
|
Well, it's three letter "better" than C# ... and that's all I know about it.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
So You must be waiting for A# then.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
What happened to B flat then?
|
|
|
|
|
Good Point.
Devs don't really like the word "Flat" as it has negative connotations. E.G. Flat Tyre and feeling flat.
So probably not such a good name for a programming language.
Sharp is well accepted as we think that it refers to our minds, our intelligence and our wit.
On the other hand, being a rather sedentary job, I noticed that Bb or B Flat is a supposedly an expensive fat burning belly cream that is supposed to flatten your stomach and remove stretch marks.
Just looked this up but I don't believe it.
In addition I should add that I know what you are doing here.
When A# is finally released, just don't tell the Devs that it has equivalence with Bb, else it is doomed.
"Rock journalism is people who can't write interviewing people who can't talk for people who can't read." Frank Zappa 1980
|
|
|
|
|
I'm not a musician, but I thought the sequence of sharps in the major scales was
0. (C major)
1. F# (G major)
2. C# (D major
3. G# (A major)
4. D# (E major)
5. A# (B major)
6. E# (F# major)
7. B# (C# major)
...
6000000. (Lee Majors)
|
|
|
|
|
People that does a lot of math coding seems to like it, as F# give less noisy code.
|
|
|
|
|
Super Lloyd wrote: Sometimes I wonder about F#... Sometimes I wonder about F-all.
|
|
|
|
|
It's kind of less useful than it once was since C#'s LINQ and lambdas/anonymous methods are pretty mature and together provides functional programming within an imperative language, giving you the best of both worlds, so to speak. F# is geared toward purely functional programming like Scheme or Haskell, and as such is basically a glorified query language. It's great for mathematical style code, or query code, but not much else, honestly. While there's some modicum of state it's not really geared for stateful programming.
Real programmers use butterflies
|
|
|
|
|
yeah I had this feeling too...
my amin hobby interest is desktop UI app.. and F# seems to bring little here...
|
|
|
|
|
yeah it's really not geared for that. You need state.
Real programmers use butterflies
|
|
|
|
|
Super Lloyd wrote: Can anyone enlighten me and motivate me to give F# another try?
It is simpler than C#. The latter has more alterations in clef.
"In testa che avete, Signor di Ceprano?"
-- Rigoletto
|
|
|
|
|
If this list of F# attributes looks interesting, it might be worth your while giving it another go - otherwise probably not.
For me, the conciseness of F#, together with the rich type system make it the .NET language I prefer (not that I do much .NET programming - C++ is where I normally live).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Nice links, thanks!
|
|
|
|
|
I learned Haskell at school.
Never did anything with it, but...
It gave me another way of thinking about code and that's priceless.
Since I've taken that course, my C# code looks different.
I've taken out the global variables and reduced side effects by a lot.
Most of my code is just thread-safe by default now.
And when it isn't, I know it isn't and I know the implications.
If that didn't happen to you after learning F# the last time, it may not have landed and you may want to give it another try.
C# isn't a functional language, so you may not reap all the benefits of functional programming, but at least all the best ones
|
|
|
|
|
I took the same course, with exactly the same results
And F# is a natural extension to it.
|
|
|
|
|
I've read part of an F# book years ago, when it just came out (I think it was F# 2.0).
I think the language is beautiful and in some respects ahead of C#, but I've never done anything with it since then
Sometimes I think F# is the playground for new C# features though.
|
|
|
|