I am using ncurses with c++ on a xterm-256 display and I would like to print my text in shades of red, but I'm having trouble finding a simple way to do this.
Using this chart I can see that 0x009 is red and that 0x255 - 0x232 will be various shades of black. How can I go about using this information to form a mast for my colors?
I would basically like to form a map such that 10 means white and 20 means red, such that 15 would be pink and so on. I would then create color pairs with
init_pair(10, ???, COLOR_BLACK);
init_pair(11, ???, COLOR_BLACK);
...
init_pair(20, ???, COLOR_BLACK);
so that I could use these colors later to shade from white to red.
It depends on what assumptions you want to make. The layout of the xterm 256color feature is a given, with three parts:
colors 0-15 are ANSI colors and bright versions of those.
colors 16-231 are a 6x6x6 color cube
colors 232-255 are a grayscale ramp, intentionally leaving out black and white
See for example 256color.pl (widely copied from xterm sources). The numbers make more sense than the chart when you see the picture:
You could simply refer to those color numbers in init_pair. Bright red as you have noticed is 9 (COLOR_RED + 8).
On the other hand, the color palette can be modified. You could use init_color (giving your own red/green/blue triple) to define a color by number, and use that in init_pair.
Related
How do I create a polygon in OpenGL 4.1 that has an inset border of n-pixels?
Presumably, since I have said the magic word "pixel", this means that I need to invoke a fragment shader of some form. (And, even though I said "pixel", this might need to be "pixel distance from edge" or some similar metric).
In addition, since I said the word "inset" (ie. I don't want any of the outline pixels to render outside the rendered polygon), I probably have invoked a stencil buffer. And may have invoked the idea of multiple passes.
However, I seem to be at a loss for how to put the pieces together to make the outline.
Here is what I mean in pictures (I chose rectangles simply because they are the easiest to define what an n-pixel outline is as well as decompose into the constituent triangles cleanly):
This is a blue rectangle with a 2 pixel wide blue border:
This is a blue rectangle with a 3 pixel wide red border:
I am looking to reproduce the glow effect from this tutorial, if I understand well, we convert the first image to an "alpha texture" (black and white), and we blur the (rgb * a) texture.
How is it possible to create this alpha texture, so that some colors go to the white, and the other go to the black? I found this : How to render a texture with alpha? but I don't really know how to use these answers.
Thanks
It appears you are misunderstanding what that diagram is showing you. It is actually all one texture, but (a) shows the RGB color and (b) shows the alpha channel. (c) shows what happens when you multiply RGB by A.
Alpha is not actually "black and white", it is an abstract concept and amounts to a range of values between 0.0 and 1.0. For the human brain to make sense out of it, it interprets that as black (0.0) and white (1.0). In reality, alpha is whatever you want it to be and unrelated to color (though it can be used to do something to color).
Typically the alpha channel would be generated by a post-process image filter, that looks for areas of the texture with significantly above average luminance. In modern graphics engines HDR is used and any part of the scene with a color too bright to be displayed on a monitor is a candidate for glowing. The intensity of this glow is derived from just how much brighter the lighting at that point is than the monitor can display.
In this case, however, it appears to be human created. Think of the alpha channel like a mask, some artist looked at the UFO and decided that the areas that appear non-black in figure (b) were supposed to glow so a non-zero alpha value was assigned (with alpha = 1.0 glowing the brightest).
Incidentally, you should not be blurring the alpha mask. You want to blur the result of RGB * A. If you just blurred the alpha mask, then this would not resemble glowing at all. The idea is to blur the lit parts of the UFO that are supposed to glow and then add that on top of the base UFO color.
I try to render an object, but I don't want its edge blend with the background.
I use only 2 colors: red for the object, and white for the background.
When I get the pixels of the frame with glReadPixel() I see that there are other colors except for
red and white, a blending colors. These colors are located on the edges of the object.
Eventually, I need to get a picture of 2 colors only.
Someone can help me to solve this?
(note: I used glDisable(GL_BLEND) to make sure it didn't work)
So I have no idea how I should be doing what I want do so I'll explain as best as I can.
http://i.stack.imgur.com/j65H8.jpg
So imagine that entire image is a 2d square 128x128 and each color I want to apply a texture to that part of the 2d square. Also I want it to stretch as well so Red, Aqua, Green and Purple never stretch in any direction but Pink stretches all directions and then Grey, Yellow, Black and Orange stretch in the longest direction (grey/orange = width expands, yellow/black = height expands). When stretched it should look like this:
http://i.stack.imgur.com/wJiKv.jpg
Also I am using C++.
I am attempting to use Textured fonts as so that I can display text in my openGL scene. However I am having trouble finding glBlendFunc values that will work.
The background that the text will be placed on is a grayscale image but will change throughout the execution. Because the background changes the text could possibly be on top of any color from black to white.
The best values I have found are glBlendFunc(Gl.GL_SRC_COLOR, Gl.GL_ONE_MINUS_SRC_ALPHA). This will make the black box surrounding the character disappear but the character itself will fade as the background goes towards white.
Please help!
Do you want the text to invert based on the background color? white text over black background, black text on white? I think you can achieve an invert via blendfunc.
Alternatively you can use a font texture which has a "border" built into it to help set the character apart from the background. Imagine a white font w/ a smooth alpha blended black "glow". The font will look good against almost all colors.