Elementary graphics in java/scala - scala

I'd like to add a real-time graphical representation of what's going on behind some scala code. Just a black window of a given size where I can put colored pixels at random (x, y) points will do. That's exactly want I'll be doing, actually.
What library should I use? I want to stay as simple as possible, so as to avoid mixing in (say) a full-fledged game-writing library just for a quick and dirty way to place pixels on a canvas.

I'd just use the Java 2D Graphics API.
Scala has support for Java's Swing GUI API, see the scala.swing package in the Scala API documentation.

Related

The relationship between libraries: Clutter, Cogl, Clutter, GTK+, etc

I'm a little confused about the relationship of the libraries listed above, here are what I think:
Cairo is a 2D graphic library, and GTK+ uses it to render widgets. Cario is low-level.
Cogl is a 3D graphic library based on OpenGL(or a fork? I don’t know), and Clutter is a 3D GUI toolkit based on Cogl.
If this is correct, will Clutter replace GTK+ someday?
And...
If you think there is a better place to ask this question or some books I should read first, please tell me! I'm self-learning programming for interest.
yes, Cairo is a high quality 2D drawing API, and GTK+ uses Cairo to draw itself.
Cogl is a GPU programming library that internally can use GL or GLES to access the graphics pipeline (though in theory it could as easily use DirectX on supported platforms).
Clutter uses Cogl for rendering, but it can also use Cairo for 2D elements.
Clutter will not replace GTK+: GTK+ is a very complex library that provides system integration, complex widgets, and other utility API that Clutter has no interest in providing.
the future is going to be a bit more gray than a black-and-white replacement.
Cairo can use Cogl to draw; Cogl will program the GPU pipeline, but Cairo will generate the geometry to be submitted, so you can have high quality 2D results. Cairo already can use GL directly, but Cogl has a better state tracking already.
Clutter can use GDK, the GTK+ windowing system API, to talk to the windowing system surfaces and get input events.
in the future, it's entirely possible that GTK+ will use Clutter internally as the base for its widgets - though that's still a work in progress.
in short, a diagram could be:
GPU <- [ [ Cogl + Cairo ] <- [ GDK + Clutter ] <- GTK+ ] <- application

Which is a more preferable Geometry in Objective C Programming?

It took me up to this point that I still do not understand what is the difference and which is better to use for geometrical programming in Objective C. I understand that NextStep has its own version of C Geometry (Quartz) but what is much more preferable to study and appropriate for iPhone dev?
There's CoreGraphics, if you just want to draw on a UIView. You could look at higher level options such as Core Plot: http://code.google.com/p/core-plot/
An alternative is to place a UIWebView in your app and use one of a myriad of JavaScript libraries and/or SVG.

OpenGL 2D editor?

I want to draw different 2D objects in OpenGL for example a path/Road ,is there any program i could draw them using a GUI then transfer them to points so i could use them in my program ?
I have personally used Inkscape to do this. If you save your data as SVG, then any standard XML parsing library should make it relatively easy to extract your data. Even better, you might even find an SVG parsing library that will make it even easier. I created one in Python, based on the work of Martin O'Leary of supereffective:
http://pypi.python.org/pypi/svgbatch
It's very fragile and incomplete (it barfs on svg elements it doesn't recognise) but if you stick to the SVG elements it recognises (closed polygon paths, no curves) then it works, and it might help you put together one of your own.
Somewhat heavy handed, but you could use Inkscape to create SVG files, and then just parse out the path vertexes.

OpenGL - to use or not to use ? why - iPhone application dev

I have to develop an application "Behavior like an Tetris game".
I have never used "OpenGL" for the iPhone application developement.
Application is something like this
Red / green / blue square boxes drop from top
Red + Red + Red = Points & boxes disappears
same way user has to make combination & get points
Different levels are there.
There are three buttons Left, Right for movement & bottom for speedy fall
For this kind of application should I use open GL or NOT?
i.e. Is it possible to develop entire application with view & it's animation?
If yes then, will it be more complex as compare to open gl?
What is the advantage of using open GL?
(I know that it gives good 2d, 3d look )
(But here my question means - easy coding?)
(Or open gl is more complicated as compare to objective-c?)
(I am just asking because I am not aware of it)
Basically your options are:
Using OpenGL
Using Quartz
Using UIKit
OpenGL is a fairly complicated beast, but is by far the best way to squeeze performance out of the iPhone. Do you need it for a Tetris game, though? Almost certainly not.
Quartz is the toolkit used in Mac OS X and the iPhone to draw images and do image effects. Because I come from an OpenGL background in other languages, I find Quartz strange and frustrating. However, it is probably easier for someone who is new to both.
You can do everything here using UIKit, and it will definitely be much much easier than other options. The main disadvantage is that it's rather slow in comparison, but once again doing a Tetris-like game shouldn't matter at all.
Before you go with UIKit, though, I recommend just checking out something like Cocos 2D, which will give you the advantages of OpenGL without the headache of dealing with all of its inner workings.
From the tone of your question it looks like you're confusing what OpenGL is and isn't with regard to Objective-C.
OpenGL is a library written in the C programming language (to put it simplistically) that excels at rendering shapes (especially 3D shapes) for display on a screen. It doesn't replace Objective-C inside your program, it merely assists you in drawing the shapes. If you don't use OpenGL, you'll need to write some sort of drawing/rendering code in your NSView (or subclass) to render the blocks. By using OpenGL, you will be provided a lot of helpful C methods for drawing shapes, which otherwise you'll have to implement yourself. On top of that OpenGL has thousands of man hours worth of drawing optimizations that you can take advantage of if you use it rather than trying to implement shape rendering yourself.
Having said that, OpenGL isn't all sunshine and roses. It works like a state machine and has its own assumptions about the way it will be used (like any API). Just because you know C and Objective-C doesn't mean that using OpenGL will be trivial. If you've never written any OpenGL code, I suggest you look into a reference like the venerable Red Book.
The thing to keep in mind is that OpenGL is not a language until itself (ignoring the OpenGL shading language). Its merely a set of C functions to aid you in rendering graphics.
You may well want to ask as well on http://iphonegamedev.stackexchange.com/, the new Stack Overflow variant just for iPhone gaming.
To learn & understand what you need.
Please go through following link.
it includes all necessary links for all kind of resources that you needed.
http://maniacdev.com/2009/04/8-great-resources-for-learning-iphone-opengl-es/
Edit :
After reading your question properly ( actually my question - By r & d I found solution).
I think - you need to develop a 2d application.
Go for the following link. Best option for 2d animation.
http://code.google.com/p/cocos2d-iphone/
Don't forget to visit following link, if you needed sample codes.
http://monoclestudios.com/cocos2d_whitepaper.html

Vector drawing tool for iPhone development

This isn't strictly a programming question, but I'm asking it here because it's certainly a software development question, if you take "software development" to include all aspects of creating a software system.
I am an independent iPhone developer. Except for translations, I handle all aspects of my apps myself—graphics included. I have to create icons, buttons, and UI elements of all sorts on a regular basis. I've learned a few tricks along these lines, and while they're certainly not works of art, I can effectively use gradients, shadows, border strokes, transparency, and textures to create minimalistic, attractive effects.
So far, I've used a vector drawing tool called VectorDesigner for all of my development, with occasional raster postprocessing by Pixelmator. It's worked mostly okay so far, but VectorDesigner has a host of issues:
It uses a package format for its files, which interferes with the use of Subversion.
It is very much a print tool, and I have to be very careful not to end up with objects on fractional pixel values which cause antialiasing.
While you can take the union or intersection of shapes, or add and subtract them, curves tend to deform with repeated boolean operations, sometimes quite dramatically.
And it offers very little control over strokes, to the point where I barely use them.
So I'm looking for a better tool for this specific purpose: shape-based drawing of simple icons, buttons, and UI elements on a Mac by someone without graphic design training. Good functions for exporting would be a plus—ideally it should be almost as easy to export a PNG to the place it goes in my project as it is to save (not save as) the file.
The perfect tool for me would be one that would allow you to define an object's shape by stacking up areas and masks defined by primitive shapes (which would remain separately editable), then define properties on those objects like transforms and strokes. I have no idea if something like this exists, though.
Adobe's tools generally strike me as very heavyweight, and are usually expensive, but I suppose they're a possibility. (Fireworks, with its emphasis on screen design, seems like it might be particularly suitable, but I don't know that much about it.) But what else is out there? If you're in a position like me, what do you use? What do you recommend?
Edited to add: Of course a graphic designer could get better results from an ancient copy of MacPaint than I could from Illustrator CS5. No tool can replace skill and taste, and many programmers have little of either. I'm aware of that. But I'm fortunate enough to have at least some taste—enough that my users compliment my apps' appearance in their reviews. I'm not hugely talented, but I do know my limitations, and I don't let myself produce anything ugly. Given my budget, that will have to do for now.
Try Opacity. A little rough on the edges, but one of the coolest and most unique features they have is export as source code (in Quartz, Cocoa, Cocoa Touch, or Canvas)
I'd suggest OmniGraffle
OmniGraffle is easy to use, can save as a PNG, can create binary non-package files (it's an option in the interface). You can also set the units to pixels to ensure exact alignment. (Canvas Size -> Ruler Units)
Finally, the Graffletopia website has some nice iPhone stencils for getting it right:
http://graffletopia.com/search/iphone
I think the only acceptable answer here should be "hire a designer".
But it sounds like Pixelmator/Inkscape are your best bets.
Though if you do find something better, that'd be really cool. Like a jQueryUI but for native.