I am trying to modify the look of the graph displayed to have a white background with black axes.
However, simply modifying the RGB values of
m_OScopeCtrl.SetBackgroundColor(RGB(0, 64, 0)) ;
m_OScopeCtrl.SetGridColor(RGB(192, 255, 192)) ;
m_OScopeCtrl.SetPlotColor(RGB(255, 255, 255)) ;
in “TestOScopeDlg.cpp” doesn’t seem to do the trick, the entire graph just turns white and the plots disappear (presumably being hidden by the white background).
Link to source code on codeproject.
http://www.codeproject.com/Articles/241/Oscilloscope-StripChart-Control
How can I make the graph appear with a white background and black axes?
Found the answer. Changing SRCPAINT to SRCAND works.
It seems SRCPAINT works when trying to overlay a light color on top of a dark color and SRCAND works when trying to overlay a dark color on top of a light color.
Related
I have followed this gtkmm tutorial on how to draw shapes and fill them with colors (e.g. A red disc on a transparent background). I was also able, from this example, to derive another example with a red disc on a blue background.
However, what I would really need is a transparent disc with a blue background that fills everything minus the disc area, which should stay transparent.
So with cairo, the usual workflow is:
Create a surface
Draw a shape (e.g. draw a circle)
Fill the circle, so that it becomes a disc.
I would need some workflow that achieves something like this instead:
Create a surface
Draw a shape (e.g. draw a circle)
Fill the area outside the circle, so that I have a colored background with a transparent "hole" in the middle.
I have done some research on this on the web but all examples seem to assume that we want to fill the inner region of a shape (which I must admit is more typical).
How could I do this?
P.S. I have added the C tag because I don't mind if you prefer to use C (or even Python).
Draw your circle and draw a rectangle containing all the visible area. Set the cairo fill rule to even/odd. Fill. Done.
cairo_save(cr); // Save the state
cairo_arc(cr, 42, 42, 21, 0, 2*M_PI); // Draw circle
cairo_rectangle(cr, 0, 0, width, height); // Rectangle containing everything
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_fill(cr);
cairo_restore(cr); // Restore default fill rule (optional; pairs with save above)
IMHO, The function of 'Draw outside the circle' is complex to the graphic framework. It may also be ambiguous if you draw more than one circle filled outside.
As graphic shapes drawn later are placed 'on' the ones drawn former. What is needed is that draw a rectangle to fill the entire graphic context before drawing other shapes. This is defined as clear with the background color in some frameworks.
the workflow would seem like:
1. Create the surface.
2. Draw the background colored with what outside the circle.
3. Draw the circle filled with a specific color, e.g. white.
As a result, the circle would cover the background.
If insist on draw the circle first, please search Flood Fill Algorithm, which is used to draw on images. However, it is needless and costly to achieve the screen pixels and play such algorithms when drawing on screen.
I find
Example Application: Creating a Clock with Cairo in the later section of the book you provide.
That seems help.
I've implemented FreeType in my program, I can draw text with colors and style (Bold, Italic, Underline).
Now I would like to make an outline effect on my text. How can I do it?
(source: googlecode.com)
I've tried to draw the text two times, one larger in black in background and the second in white on foreground, result was wrong.
I've tried to draw the text two time, one in bold and the second in one on foreground, here again the result was wrong.
I would like to make a test again : Draw the "background" text in "outline" mode and the foreground text in regular mode. What do you think about it?
(source: googlecode.com)
Rendering text with 2 passes is the key, but you have to position the text correctly.
First you should render whole outline and then on top of it render the text.
Rendering the outline:
// initialize stroker, so you can create outline font
FT_Stroker stroker;
FT_Stroker_New(library, &stroker);
// 2 * 64 result in 2px outline
FT_Stroker_Set(stroker, 2 * 64, FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
...
// generation of an outline for single glyph:
FT_UInt glyphIndex = FT_Get_Char_Index(face, glyphId);
FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
FT_Glyph glyph;
FT_Get_Glyph(face->glyph, &glyph);
FT_Glyph_StrokeBorder(&glyph, stroker, false, true);
FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, true);
FT_BitmapGlyph bitmapGlyph = reinterpret_cast<FT_BitmapGlyph>(glyph);
// blit the glyph here on your target surface.
// For positioning use bitmapGlyph->left, bitmapGlyph->top
// For iteration over the glyph data use bitmapGlyph->bitmap.buffer, bitmapGlyph->bitmap.width, bitmapGlyph->bitmap.rows, bitmapGlyph->bitmap.pitch.
Next you have to render the text itself on the same data you've blitted the outline. Use the code above, but remove the FT_Glyph_StrokeBorder(&glyph, stroker, false, true); line.
This way you will have the text on top of an outline.
To achieve this "Cartoon" text effect you will have to do 4 passes: 3 outlines + 1 text. Texturing or applying a gradient should be done during the blitting phase.
Draw the text, then do a second pass over every pixel that was not fully coloured in. For each of those pixels calculate how far away it is from the nearest coloured pixel. If it's less than X where X is the desired width of your outline, colour it in using your outline colour.
It can be slow to do this for large text but it can be optimised and the results cached to make it run acceptably fast. This method allows complete freedom for all kinds of outline and drop shadow effects.
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)
I am drawing a shadow on a CCLableTTF using CGContextSetShadowWithColor. I have set the colour to be white but i always get a grey/black line around the edge of the shadow.
Is there anyway to remove the outline, i have looked but i cannot see any stroke colour for the shadow.
Thanks
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.