Here is my take on the famous
logo done by the Mit Media Lab.
You can find the source code
here (it requires the
geomerative library).
I tried to keep it as simple as possible (in order to use it as an exercise for an introductory course about Processing and generative design in general) but in the end I came to use to geomerative library to get the spotlight outline intersections done.
I'm pretty happy with the gradient result even though I recognize that the result is still different from the original one.
I've written a simple sketch for drawing up and down (black and white) triangles up on a grid, mutating some one by changing its color (black ones may become white, white ones may become black or coloured). I draw each triangle using the triangle/6 primitive and the problem is visible on the default renderer as on the pdf one (after exporting).
As you can see from the
image, with a black background beneath, when four white triangles are near one another (the middle one was a black triangle) you can spot the margin between them even tough I used noStroke() and just a fill.
I suspect that it is due to some numerical imprecision even tough the coordinates I'm giving in the grid are float representing integer numbers.
While I try to export my sketch to a .app file (using Processing 2.0.1 under Mac OS X Lion) I get the following exception stack trace:
java.lang.NullPointerException
at processing.app.Base.copyDir(Base.java:2530)
at processing.mode.java.JavaBuild.exportApplication(JavaBuild.java:1162)
at processing.mode.java.JavaBuild.exportApplication(JavaBuild.java:1104)
at processing.mode.java.JavaMode.handleExportApplication(JavaMode.java:160)
at processing.mode.java.JavaEditor.exportApplicationPrompt(JavaEditor.java:422)
at processing.mode.java.JavaEditor.handleExportApplication(JavaEditor.java:231)
at processing.mode.java.JavaEditor$1.actionPerformed(JavaEditor.java:55)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:389)
at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:95)
at java.awt.MenuItem.processActionEvent(MenuItem.java:650)
at java.awt.MenuItem.processEvent(MenuItem.java:609)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:343)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:331)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:720)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:690)
at java.awt.EventQueue$3.run(EventQueue.java:688)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:86)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:687)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Some additional info (if it can be of any help): I'm writing a sketch that uses controlP5, the pdf library and a couple classes written by me (some .pde files and a .java file).
I'm using Geomerative to load some RShapes from a font and to divide a single shape (in this case representing a single char) into several 'slices' vertically.
I'm using the intersection method from the RG class, thus intersecting different rectangles with the shape to be cut. Here is an example of what I am doing:
From this image you could tell it is fine at this point, but I am finding many inaccuracies in the ending result (those are more visible when exported to pdf). I'm uploading a second image with a coloured background to show them: there is a less than one pixel space between slices and some extremities in the final shapes are badly 'cut'.
I recognize that much can be traced to numerical inaccuracies (we are talking about floats and their precision...) but I guess there is more.
Here are my questions:
1) is there a way to get a more precise intersection result with geomerative (or even an equivalent on processing)?
2) is the pdf render more subject to inaccuracies (and if so any alternatives to export to vector graphics)?
3) am I approaching the problem in a wrong way or expecting too much?
EDIT: sorry for the big post and merry xmas to everyone : D
HI I am using a Basic Stroke to draw a dotted line along a bezierPath. I cannot export the stroke with a PDF render btw. Which alternatives do I have? How can I get the same result with the PDF render? Or is there a way I can export from java to a pdf file?
I'm attaching a screenshot of what I'm doing (do not mind the cicles).
Hi, I'm using the fisica (
http://www.ricardmarxer.com/fisica/) library in my sketch and I'm using some FDistanceJoints and some FCircles. I'd like to have the world draw the joints under the bodies in order not to make th e anchors appears. I'm doing some drawing on the circle and it is 'disturbed' by the joint anchors and lines moving.
I tried to use the method setNoFill() not to draw the anchors, but since I need to display the joint lines I have to set some stroke on the joints.
HI,
I downloaded the Eclipse plugin from the Processing wiki and installed it under Indigo. When I have a single pde file it runs smoothly but when I add different .pde files and right click on the main one to do a Run as Processing Applet an exception is thrown: it expects a .class file that there is not.
In my accessory .pde files I create public java classes if this matters
Hi,
I'm trying to use the
postToWeb library to upload to a server an image I'm creating in my program. When I specify the selected file type through a
setType()
I see that only with the JPEG and TIFF format the file gets saved on the software, not with the PNG one. The error it reports on the console is an exception:
java.lang.IllegalArgumentException: im == null!
at javax.imageio.ImageIO.write(ImageIO.java:1457)
at javax.imageio.ImageIO.write(ImageIO.java:1571)
at org.seltar.Bytes2Web.ImageToWeb.getBytes(ImageToWeb.java:142)
at hackatar.keyPressed(hackatar.java:304)
at processing.core.PApplet.handleKeyEvent(PApplet.java:1996)
at processing.core.PApplet.dequeueKeyEvents(PApplet.java:1979)
at processing.core.PApplet.handleDraw(PApplet.java:1643)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
<p><b>Error:</b> File is empty!</p>
am I missing something?
This is when I save it:
PImage img = get(0, controlOffset, width, wHeight); // I get a portion of the screen
img.save(path +".png"); // I save it locally
PGraphics pg = createGraphics(width, wHeight, P2D); // I create a PGraphics from it
pg.loadPixels();
img.loadPixels();
for (int i = 0; i < img.pixels.length; i++)
{
pg.pixels[i] = img.pixels[i];
}
ImageToWeb imgTW = new ImageToWeb(this); //Creating imageToWeb
imgTW.setType(ImageToWeb.PNG); //Setting Type
imgTW.post("test", url, "hacktion", true, imgTW.getBytes(pg)); //posting to wesite
Looking at the code of the library it seems that PNG and GIF are treated the same and maybe the solution can lie in how I built the PGraphics (am I doing it right?)
Hi all,
I realized this applet
http://www.mediafire.com/?tto03htbrtoho6a that is a simplified painting editor.
When I run it in Safari it works smooth and nice, but when I load it in firefox, it is a bit slower and sometimes I'm not able to activate a command by pressing a key on the keyboard (A/B/E/+/-).
And finally, in chrome, the screen flashes sometimes.
What can I do to understand what is the problem?
How do you see it work in your browser?
I'm drawing some colored lines on a simple sketch script and I'd like to muply blend them, but I guess the blend() function only works with images, how can I blend them?
Hi all,
I exported my processing program into an applet and signed it following the guide found here:
http://wiki.processing.org/w/Sign_an_Applet in the wiki.
Now, when the applet starts, it asks if I want to run it but when I say ok I'm not able to see the loaded image.
What am I missing?
UPDATE:
Well, it seems like the image appears for just one second and then disappears.
I'm linking the zip file cointaining the applet
http://www.mediafire.com/?2lnl7lg0eahg97r