How do I draw a dot or a point in visual c++ and write next to it? - visual-c++

I want to draw a thick point or a dot in the client area of an mfc alpplication. Is there a function to do so? Alternatively I could even draw an extremely small circle and fill it with a colour to make it appear as a dot- but again how do I fill an object? especially a curved one?
Then I also want to put some text next to it- so what function could i use to "write" in the client area?

GetDC()->SetPixel(x, y, RGB(1,2,3))
Where GetDC() will return the current CWnd's device context, (x,y) are the coordinates, and RGB() is the red/greed/blue color.
Look at GetDC()->Ellipse() for a circle, etc. and GetDC()->TextOut() for displaying text.
It would be good to become familiar with device contexts in general, see:
MFC CDC Members

Related

How do I vary stroke on a line to create an effect similar to "Ed, Edd, and Eddy"?

I'm trying to create the "Ed, Edd, and Eddy" art style. Here's an example image:
Specifically, I'm trying to capture the effect of having accent lines with varying stroke values within the same line.
I have access to the Adobe suite. Spent a couple hours trying to see if I could do something in Photoshop or Illustrator to no avail. Any help?
You'll need to use Illustrator, here's a quick tutorial on how it's done in Illustrator CC.
Draw your starting shape:
Choose the width tool from the toolbox
click anywhere on the path and drag it out to the desired width
Repeat this (you can widen and thin the stroke) until you have the desired result.
In Photoshop, simply create a brush that is pressure sensitive (= change brush diameter with pressure) with your tablet.
That should give you the desired effect.
#user3488148 you are looking for a free form drawing strokes and for that you can use a brush that provides accents while you draw and can respond to pressure (if a tablet stylus is used) as well. Check out for inbuilt brushes and modify their diameter, length, pressure, etc.

Java 8/JavaFX: Drawing text in a rectangle

Is there a way to bind text to a JavaFX shape (for my purposes, I want to use rectangles) the same way you could using Graphics2D's drawString in previous versions of Java?
You may be able to just use Graphics2D still; I just don't know how to implement it.
Note: What isn't helpful is a way to place a Text object at the same x and y position as the shape on canvas. Rather, is there a way to actually write onto the Rectangle?

How to drag a polygon in MFC?

I'm new to MFC. I know how to draw a line and how to scribble in MFC. I use CDC and some functions such as LineTo() and MoveTo() to do this. Moreover, I've got FillRect() and Rectangle().Now I want to drag my rectangle or any polygon in the view.It's like you drag a icon on your desktop.
I think the first step is to get the region.Then erase the old polygon and when the mouse move draw a same polygon which depends on the point where the mouse go.
So I search region in MSDN and I got Region class and CRgn class.But before I look into these two class I want to know whether I'm in the right direction.
I need more suggestions on how to learn MFC. Actually,all I need is to finish my homework which is mainly about draw polygons and drag them and link them by line. And I hope I can finish this homework all by myself and MSDN. Can MSDN help me do that?
The CDC::Polyline function will draw a polygon much faster than using LineTo and MoveTo.
You do not need region and do not need to erase the old polygon. Instead, you need to draw everything in the view OnDraw. Any change you want to make with the mouse should change the array of coordinates that represent the polygon and then call Invalidate. In other words, do not draw in the mouse message handlers. Calling Invalidate in the mouse message handlers will cause OnDraw to be called later and it should repaint the entire view.

How can I draw to an XY position in Emacs?

I wanted to allow the Emacs cursor to move around freely outside of actual text (similar to virtualedit=all in Vim).
"Oh," I thought, "I'll just keep track of a virtual cursor and draw it to the screen myself."
But it turns out the actual native C drawing routines (such as draw_glyphs) seem to refer back to the buffer contents to decide what to draw (I could be wrong though).
My next idea was to make a giant overlay of all spaces so I'd have complete freedom where to put stuff. But an overlay only goes over ranges of actual text, so again, this does not seem to give me what I'm looking for.
Is this a reasonable goal without hacking the C code?
I believe the writeable area of a window is intrinsically limited to the buffer with which it is associated, i.e. you have to draw in an area where buffer content exists.
(One example of this limitation is the impossibility of drawing a vertical guide line in the 80th column to help the user identify long lines; currently the best possible implementation of such a feature is to highlight the "overflow" of each too-long line.)
You can do the same as what artist-mode does without adding spaces to the buffer:
when trying to place the cursor after the end of the line, just use an overlay with an after-string property which adds the spaces in the display without modifying the buffer.
Have a look at "artist-mode" (M-xartist-modeRET) - it allows you to draw in Emacs.
From the function documentation: "Artist lets you draw lines, squares, rectangles and poly-lines, ellipses and circles with your mouse and/or keyboard."
You can look at popup.el from the auto-complete package, which can pop up tooltips and menus and such at any position, including positions outside the contents of the buffer. Maybe that will show you how you can do it.

What is the proper way of drawing label in OpenGL Viewport?

I have a multiviewport OpenGL modeler application. It has three different viewports : perspective, front and top. Now I want to paint a label for each viewport and not succeeding in doing it.
What is the best way to print a label for each different perspective?
EDITED : The result
Here is the result of my attempt:
I don't understand why the perspective viewport label got scrambled like that. And, Actually I want to draw it in the upper left corner. How do I accomplished this, because I think it want 3D coordinate... is that right? Here is my code of drawing the label
glColor3f(1,0,0);
glDisable(GL_DEPTH_TEST);
glDepthMask(GL_FALSE);
glRasterPos2f(0,0);
glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits
glListBase(base - 32); // Sets The Base Character to 32
glCallLists(strlen("Perspective"), GL_UNSIGNED_BYTE, "Perspective"); // Draws The Display List Textstrlen(label)
glPopAttrib();
I use the code from here http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=13
thanks
For each viewport switch into a projection that allows you to supply "viewport space" coordinates, disable depth testing (glDisable(GL_DEPTH_TEST)) and depth writes (glDepthMask(GL_FALSE)) and draw the text using one of the methods used to draw text in OpenGL (texture mapped fonts, rendering the full text into a texture drawing that one, draw glyphs as actual geometry).
Along with #datenwolf's excellent answer, I'd add just one bit of advice: rather than drawing the label in the viewport, it's usually easier (and often looks better) to draw the label just outside the viewport. This avoids the label covering anything in the viewport, and makes it easy to get nice, cleanly anti-aliased text (which you can normally do in OpenGL as well, but it's more difficult).
If you decide you need to draw the text inside the viewport anyway, I'll add just one minor detail to what #datenwolf said: since you generally do want your text anti-aliased (even if the rest of the picture isn't) you generally want to draw the label after all the other geometry of the picture itself. If you haven't turned on anti-aliasing otherwise, you generally will want to turn it on for drawing the text.

Resources