|
Sorry if my answer might come across as a bit harsh.
Quote: but it doesn't teach the newest features, nor does it teach super complicated constructs. But is the super complicated stuff really necessary? I come from the era of Literate Programming and still have a strong belief that programs should be written for humans and only executed by computers. In case of a lot of template meta-programming, if mere mortals have difficulty grasping it, maybe we should just stay with simpler stuff.
Looking at your code fragment, a const object (we don't know what it is because auto hides that - could be a color by the name of it, but who knows) has a property channelr (whoever that may be) changed to 0.5. Oh, and this is an instantiation of a templatized function for some parameter channel_name::A . You say that makes the red color half transparent and I believe you but let me tell you that it's not apparent from your code and it's the exact opposite from the ideal of literate programming where code should read like a novel. Your code is efficient, generic, compact, whatever you want but easy to understand, it ain't.
Seems to me you are slaving for the computer instead of the other way around.
Mircea
|
|
|
|
|
Prior to C++20 many of the metaprogramming techniques in C++ are effectively “hackish” because while C++ does support this kind of thing, it wasn’t originally designed for it.
I've hidden those complicated constructs I needed behind usable facades, but the code to make them work is necessarily ... difficult.
In my pixel class it would have been impossible performance wise to create a pixel in an arbitrary binary format with an arbitrary set of named channels without doing metaprogramming.
In C++17 and particularly 14 which I target, some of the code is necessarily complicated. Like you, I don’t like it. But, it is C++ and it is metaprogramming, and so this is par for the course. You either cope with it and the mess it brings, or avoid it altogether.
Furthermore, of course you aren't going to understand it without knowing anything about it.
If I were to explain the concept of pixels and channels you would get it. (I didn't invent the concept of channels either - they're just what individual values of a particular color model are called) - the alpha channel in graphics parlance is the channel that specifies the transparency of a pixel.
If you have an rgba8888 pixel that's 4 channels, 8 bits each, specifying red green blue and alpha. This is the standard pixel format in .NET.
But the pixel format for an ILI9341 display device is rgb565 with no alpha channel.
JPGs use YbCbCr pixels, so it's not even an RGB color model.
My library supports all of these and whatever else you define because it is cross platform, which was one of the goals - to be device agnostic.
I didn't expect you to understand exactly what that code was doing.
Now, if you didn't understand that code after reading this: GFX Forever: The Complete Guide to GFX for IoT[^] then one of us - probably me - has a communication issue
Real programmers use butterflies
modified 30-May-21 22:32pm.
|
|
|
|
|
honey the codewitch wrote: I tried writing an article (actually two, really) on it but I fear it wasn't well understood by people.
I have a similar issue with my latest article. The method I'm trying is separating the article into a conceptual section and a technical section. The conceptual section will talk about the topic at a high level. The idea is to get an initial, logical understanding of the problem being solved and the topics used to solve it without the confusing (but fun) details. Like when you learn about Model-View-Controller and you've got the pictures that show what the logical elements of that pattern do to give a practical understanding of what's going on. Then go over the technical details in a separate section to show how the various parts of the implementation solve the high-level, logical problems while diving into those gritty details that make it possible.
Can't confirm this approach works but it sounds good in my head
|
|
|
|
|
That tends to be how I do it. I usually divide it into "Conceptualizing this Mess" "Using this Mess" and sometimes "Coding this Mess" if I'm deep diving into how I built it.
Real programmers use butterflies
|
|
|
|
|
I assume this is the for your ongoing pixel drawing program. Any reason you dont wanna use shaders?
|
|
|
|
|
Show me an IoT graphics device that can support shaders and I'd consider it.
There is no hardware acceleration on this thing. Drawing is all point by point or square by square.
Real programmers use butterflies
|
|
|
|
|
Silverlight! hahahaha
|
|
|
|
|
I can make a "driver" to bind GFX to some sort of PC drawing surface, like a silverlight canvas (or whatever they have, I've never used silverlight in my life) but it seems pointless.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: This for example, sets the alpha channel to make a red color half transparent. It does so in a pixel binary format that is completely arbitrary and user defined, and does so entirely at compile time, yielding a color value with the appropriate binary footprint. Could've been straight out of a sci-fi movie!
|
|
|
|
|
It's not *that* complicated.
How many channels does an RGB pixel have? The answer is right in the question.
Real programmers use butterflies
|
|
|
|
|
honey the codewitch wrote: It's not *that* complicated. Said the person who wrote it
honey the codewitch wrote: sets the alpha channel
honey the codewitch wrote: How many channels does an RGB pixel have? Four, I guess, counting the alpha
honey the codewitch wrote: The answer is right in the question. Unless alpha isn't a channel and the answer really is three, it clearly doesn't
And by the way, your original post didn't mention RGB, just "setting the alpha channel"
"I am the Alpha and the Omega, the First and the Last, the Beginning and the End." (Revelation 22:13, and also your code)
|
|
|
|
|
It was 3 channels, because i didn't name an alpha in the question, but from your response you clearly understand the relationship between channels and pixels, and correctly deduced that an alpha channel would be the fourth channel if it had one.
Now, I didn't expect anyone to understand that much about my initial code without any context. I didn't provide the context because I didn't think understanding the code was exactly relevant, until more than one person decided it was. So here we are.
Real programmers use butterflies
|
|
|
|
|
|
Didn't he also do, "Hooked on a Feelin'"?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Yes, and several other hits.
Get me coffee and no one gets hurt!
|
|
|
|
|
|
Is this one of those scams like "Bill Gates is giving $50 to any person who forwards this e-mail"?
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
No, I think the scam is making you use Bing ...
"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!
|
|
|
|
|
One thing I hate about Edge is the way it forces Microsoft onto you every time you open a new tab. There is no way to turn off the "Bing experience" when opening a new tab. I set the default search engine to Google, but the new tab page still uses Bing.
And it shows those "news" headlines at the bottom to bait some clicks. Can't stand it.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I think it works properly now just try to remove from add and remove.
Caveat Emptor.
"Progress doesn't come from early risers – progress is made by lazy men looking for easier ways to do things." Lazarus Long
|
|
|
|
|
Sounds like a scam to me.
|
|
|
|
|
obermd wrote: Sounds like a scam to me. Nope, it's legitimate. MS has been offering premiums to use Bing as a search engine -- earn points and redeem for various things. I get a $5 Amazon gift card every 3 weeks or so.
MS has been advertising the cashback deal for a while, but I haven't looked at it.
|
|
|
|
|
|
It must have come as a shock to the good burghers of Amsterdam to discover that not every tourist came to their fair city to see the artwork in the museums...
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|