I am new to Gtk and want to do simple drawing of shapes like circles and rectangles. I was looking at the gnome tutorial and the hello word example. However the curves section is undocumented. I was wondering if someone could point me in the right direction as to what should I look at, and maybe if I need to include some other supplementary library to draw?
The preferred drawing API in GTK 2 and 3 is Cairo. But if you need to develop a diagram program, with nodes that can react to events, you will need also to use a canvas, like GooCanvas.
Check out http://developer.gnome.org/gtk3/3.2/GtkDrawingArea.html about the GtkDrawingArea, plus http://developer.gnome.org/gdk/stable/gdk-Drawing-Primitives.html about Gdk-Drawing-Primitives and you are on the go.
You might also go a bit further by using this link and check out Cairo directly http://www.cairographics.org
Related
How would one "lock" the mouse to a certain OpenGL window. Sort of like how it is done in Minecraft.
Is GameDev a better place to ask?
Like Robert said in the comment, OpenGL doesn't actually do user input.
However, there are libraries that can abstract the platform dependent part away, such as LibSDL. You can use it to grab the mouse to your window.
A similar question has been asked here, where a programmer used a class called robot to change the mouse position.
Code: Robot.moveMouse(x,y)
This code was written in java, however, There are several classes like robot that can do the trick!
One option is to constantly move the mouse to the center of the screen or wherever you want it.
I am not a real designer and I would like to know if anyone have an idea how can I build the following visual :
The idea is to get 2 rings where inside I will draw secific number of pie represented as "Interactive shape or button". Base on the number of shape, they should cover the whole circle.
In addition to that, I need to be able to interact with each pie shape, and inside and oustide edge of those shape should be a perfect arc based on the circle diameter.
As I am not a perfect designer, how can I represent this visual ?
I was thinking of using a custom panel but then how to draw each panel shape in order that they gets perfect inside and ouside arc and offer interactivity with each of them ?
Thanks for your help
I would appreciate samples as well
Theres actually a Silverlight tutorial on making something exactly like this.
If you didnt want to use that, you could always do it in javascript. Here's an example using Rapheal js
I would recommend looking into WPF Geometry and how you can create custom controls (such as the Circular Gauge Custom Control over on CodeProject) using said Geometry.
I've never created a control quite like what your suggesting, but I would image you would define some form of area that can contain children and style it so that it forms the circular shape you want. Then, adding interactive regions should be as simple as adding controls to standard containers.
Here's a link to a "generic radial panel that can be used to host any items" which subclasses Panel.
i need to make a program where i have to detect the edge of a subimage (like a face in a portrait) using canny detector. then i need to filter that portion out and paste it in another background. it is like mixing 2 layers. can anybody give me any algorithm for this? or any idea about the process?
You are probably aware that the task of selecting a subimage is most known Region of Interest (ROI).
Edge detection with canny shouldn't be a problem since OpenCV implements it as cvCanny().
For what I understand you want to overlap two images. I suppose you want to add one image on top of each other? Take a look at step 2 on the first link I suggest: Adding Two Images with Different Size
If you want to BLEND them, then check these instructions. I have used them before to draw over the webcam window.
I'd like to know a library to draw graphics in WPF..
I'd like to plot a line graph with a lot of points which increases at runtime..
I tried with DynamicDataDisplay, but it was very slow in my app...
So.. Can you suggest me a library / project to use to solve my problem?
Maaany thanks!
I'd suggest binding your data to a System.Windows.Shapes.Path using a converter, you just need to implement a notifying interface if points are added or removed to update the graph.
(Recently wrote a generic cartesian point array converter for this question)
Hey Guys, I am building a cards game which displays a stack of Cards( Some thing like Solitaire). I was wondering you give me some advise regarding it? Also if you could direct me to a tutorial for stuff like these( I am already going through the gtk doc).
You should check what have already be done in GnomeGames :
Aisleriot
Blackjack
Get the code and see how they have done it. It seems that they render each and every card :
For example, in Aisleriot source code, in game.h, you have the definition of an ArSlot struct which stores all the cards of one slot. In there, you can see that they define the 'expansion' union which is just defining the offset between the cards.
So if you wish to create a heap of cards, you can draw each one of them, or if you consider it's too slow, just draw a few cards with a random offset of one or two pixels, and then draw the last card on the top : with this algorithm, your heap of cards looks like a heap, and it's quick to render on screen.
Unfortunately, there's no widget included in GTK+ that displays stack of cards, so yu have to write one yourself. You should use GtkDrawingArea (preferably by subclassing it), and in handler for expose_event signal do your drawing stuff. To draw you can use either plain GDK which is more basic, or use Cairo, which is more flexible drawing library (nb. Cairo is used by GTK+ anyway, so it's not additional dependency. If you want more, you can even use OpenGL (then you have to use GtkGlExt library).
GTK Tutorial has a chapter dedicated for creating own widgets.