displaying drawing on window/console Ruby+Cairo - ruby

I'm starting to work on a college project (for Computer Graphics) .... I wanted a library that could do 2d drawings and I came across Cairo. But the thing is, there arent many samples/tutorials/programs on ruby and cairo. Every program i came across, saved an image onto a file.
Can anyone please tell me a way to display these drawings on a window (or a console)??
... and since I'm at the beginning of my project, I wouldn't mind looking into any other alternative library if you can suggest any.
Thanks!!

There is a good tutorial at http://zetcode.com/tutorials/cairographicstutorial/ (and http://zetcode.com/tutorials/rubygtktutorial/cairo/ for Ruby) which shows how to draw basic shapes, line drawings and text on a Cairo surface within a GTK program.

Related

GraphViz: how to get UTF-8 AND external PostScript procedures?

Goal: draw a flowchart which contains non-Latin1 symbols.
Problem: GraphViz does not provide all node shapes necessary for drawing a flowchart (e.g. "Document", "Predefined Process" etc). Fortunately, a person named Jason Brazile created a nice library of missing shapes. However, it works only when using the PostScript driver (dot -Tps).
There are two basic PostScript drivers in GraphViz: built-in driver which does not support Unicode, and Cairo which does, but apparently does not support external PostScript procedures (the user-defined PS shapes are absent in the resulting layout).
Question: How do I use UTF-8 labels and flowchart shapes at the same time?
I asked the GraphViz developers about this and looks like the answer is that there is no way to do that:
We looked at this problem years ago. The native graphviz -Tps
Postscript driver does not have any custom font loading capabilites.
As mentioned here: http://tldp.org/HOWTO/Unicode-HOWTO-5.html
rendering utf-8 fonts in Postscript is a do-it-yourself job. It would
probably take weeks or months of work, but if you want to try to make
this modification to graphviz, it might be possible to appropriate
code from one of the other tools mentioned in that website. (Make
sure it is non-GPL code, otherwise it can't be distributed!)
Another option would be to modify the cairopango driver to render text
on top of a user shape after it is loaded. (Do we not already support
this? It seems obvious.) Then either find a way to render external
graphviz PS shapes after they are loaded and copy the rendered images
into the cairopango canvas (hey we already import ghostscript into
graphviz) or convert the custom PS shapes externally into images that
can be loaded by the cairopango driver. This might not take as much
time.
Either way, it will take an expert C programmer.
Probably none of us have much time to work on this (our time would be
better used trying to get funding to support the project in a more
general way, but we all have other jobs now) but you could offer a
bounty on bountysource and see what happens....

Placing images on top of other images in wxpython

I know this question is pretty basic, and I'm sorry for posting it, but I literally have spent the last hour googling and I still havent found an answer.
I coded a blackjack game using pygame, and want to convert it to wxpython mostly as a way to learn wxpython. In pygame the graphics are easy, I have a base image I display (basically just the table), and then I can just display other images on top of it as the action unfolds, for example the cards. Each time the player hits I just draw a new card in a different position. When The hand is over and I want to go to the next hand, I just display the base image again, and it covers everything up and viola! Its really simple all I have to use is blit() and pygame.display.update().
I cant seem to find anyway to do this in wxpython. All the examples I find are for drawing items in new widgets, or drawing vector graphics over an image, or opening new frames with images, etc.
any help is greatly appreciated, thank you very much.
--Daniel
The AlphaDrawing example in the wxPython demo shows how to overlap multiple drawings. This uses wx.GraphicContext / wx.GCDC. If you look at the documentation, you'll note that it has CreateBitmapFromImage and CreateBitmap methods that probably apply to what you want to do. See also the DragImage demo and the following links for related information:
wx python card game
http://rummy-py.sourceforge.net/ (look at the original that was done in wx)
I found this post, which reading the comments, does a good job of showing me want I was looking for.
Delete image in wxpython?

Using images in Matlab GUI

I'm working on a small image processing project in MATLAB. I have worked with MATLAB before, but never created a GUI. The GUI I want to create could be pretty advanced, so I need some hints on how to get started.
The purpose of the GUI would be to load an image and have it shown to the user. The user then has to click on two points in the image, of which the coordinates are stored (in pixels) in a variable. If possible, a colored dot is shown where the user has clicked. After the user finished with the current image, he can load a next one.
I have some experience with Java, and I think this wouldn't be too hard in Swing. But MATLAB seems like not having the purpose of creating such an advanced GUI. However, the whole project until now is in MATLAB, so it would be nice if I could manage to do it. Any help? Hints? Things I should look at?
Thanks a lot.
This is not a very complex task to be done in MATLAB.
For simple instructions about adding a picture to a GUI, take a look at this post:
http://blogs.mathworks.com/pick/2007/10/16/matlab-basics-setting-a-background-image-for-a-gui/
For instructions on various interactions between GUI axes and the mouse pointer, check this video (keep in mind that your picture in the GUI lies within normal MATLAB axes):
http://blogs.mathworks.com/pick/2008/05/27/advanced-matlab-capture-mouse-movement/
In general, Doug's tutorial videos are great for MATLAB beginners, and I'd advise you to take a look at more of them.

Qt, CEGUI or wxWidgets for a text game GUI?

I tried to sign up, but I was unable; perhaps a problem from my side. Hopefully I'll get an answer as anonymous.
I apologize for the grammar/syntax, but English isn't my native language.
Recently I lost my job, so I have enough spare time to try something fun. I decided to create a simple text RPG game for me and some friends. It will very close to the board games like Talisman, Dungeon Run, and HeroQuest, using dice and a simple attribute/skill system. So no 3d graphics. The only 2d element, if I decide to include it, will be a map
that will allow the hero to move between locations. Currently I'm using Windows XP SP3, for the game I use wxDev-C++, and although cross platform would be cool, I don't really care.
I have some experience in C++ (currently using wxDev-C++), but I'm far from being called an expert or even a great programmer. I was about to start writing parts of the code, but I decided to check if creating a GUI for the game is possible. In some forums, many suggested I use Qt, CEGUI or wxWidgets, but most examples I saw are grey boxes that are
indifferent at best, when I want something that fits better in a fantasy setting. I don't claim I would do better, but I want a GUI that is more fantasy related.
What I want from the GUI:
1. A "cool" Gui with decent graphics. I could even create an image to serve as a mask in Photoshop, but the GUI builder will have to support imported images.
2. A relatively large textbox in the middle (with a scrollbar) that will display die rolls, damage and options.
3. The ability to display dynamically values (like the change in the health after each action without requiring to refresh manually)
4. Display an icon or a small image of the character in the area where I display stats/abilities.
5. Open new windows created with tha same GUI builder to allocate points, buy/sell things and open a map.
About the map in the game: I decided to create a map in photoshop. When the hero decides to move to another location, a new window will open showing the map. I thought of 2 possible ways to move between locations: 1) Create hotspots on the image and select one by clicking on the name of the location.(I dare not think about the complexity of this so we
move to idea #2) and 2) Have the image as a backgroung to a grid with vertical and horizontal coordinates. When the hero selects a new area to visit, he clicks on the area, but what he really does is click on the grid, which returns the two values (x,y) of the location and informs the game about the area the hero wants to visit.
Yeah, yeah, I know it's too much, so what I'm most interested in are the 1-3. I know that even if they are possible, it will propably take forever, but as I said I have spare time, and I like learning new things. I apologize for the size of the post, but I decided to post as many info as possible so you know what I want.
If any of you has used Qt, CEGUI or wxWidgets could you tell which covers most of my criteria? I saw some great stuff build with CEGUI, but I don't know if it is too hard to learn?
Thank in advance.
I know my answer comes pretty late, I only recently started using stackoverflow fairly recently, but maybe this response will help anybody.
CEGUI fully supports skinning widgets using XML. Our CEED editor (WYSIWYG) fully supports layout editing, but the skinning editor (LNF editor) is not finished as of now (11.11.2014), the development version supports exchanging images however and changing sizes and proportions, but more advanced adjustments have to be done in XML.
CEGUI has an imageset editor, fully supported by the CEED editor. Creating imagesets (sets of named subimages, with position and dimension inside a big texture atlas) is supported there. Additionally there is a way to create imagesets from just a bunch of jpg/png/... files using a tool. You would have to ask for specifics in the forum though because it is not integrated into CEED yet.
So basically with CEGUI you are free to make whatever fantasy GUI you want. Skinning simple elements like buttons and progress bars isn't much work in XML anyways. Without the finished editor, some more advanced widgets are more work to skin, but many skins have already been created done this way and some of them are even publically available in the forum and in the CEGUI stock files.
StaticText widgets supports what you want, you can even use images in there or change fonts and colours in the text if you want. Scrollbars are supported too.
I am not sure what you mean by this. You have to specify this.
A simple "Generic/Image" widget is available in CEGUI for this purpose. You can use precreated images or even RTT textures.
You can create and destroy windows in CEGUI without issues.
Regarding the map: I m not sure what you mean, but getting the position of a click in respect to an image (representing the map) is possible in CEGUI.
CEGUI is not particularly hard to learn. There is always the forums and the chat if you got questions. For an Open Source project it is quite well documented so if you read all of the API docu, and look at the supplied samples in the sample browser, you should already get quite far. And for everything additional there is the forum (search), the IRC chat and a community wiki (mind the targeted versions of an article there though)
For a project like yours, CEGUI seems perfectly suited (this is what it was created for in the first place). Qt is not really optimal for games for numerous reasons. wxWidgets I have never used.

Trim bar like the GarageBand and iMovie ones

I'm creating a Mac app which needs a trim bar like the GarageBand and iMovie ones. I need a library to get the audio waves to draw them on a NSView. Anyone knows a good library for that?
I think he was referring to the track editor (cut/copy/paste/move).
There's a cool blog post on how to draw Waveforms by the author of the Capo audio editing software:
http://supermegaultragroovy.com/2009/10/06/drawing-waveforms/
I wrote Cocoa (Mac) code based on that, and it's not too hard. You can find that code here:
https://github.com/uliwitness/UKSoundWaveformView
Though it's far from a finished, shippable editor, it's under a permissive license (zlib) and could easily be used as a basis for a full editor.
Maibe this helps: Drawing waveform with AVAssetReader
and if the issue is to draw, then this may help: Parametric acceleration curves in Core Animation
This framework might help you out. From the examples it looks like its pretty easy to use and works well. It provides components to open an audio file, play it and draw the waveform. You might need to implement the cut/copy/paste features on your own.

Resources