@slendro wrote:
Hi!
This is my first post ever on this forum. I have been working on translating some tutorial sketches from a book on Generative Art into OF (of_v0.10.0_osx) , and though I mostly have found the going easy as soon as I got some equivalences clear in my head, I have run into a couple of issues that I can’t seem to solve. So, I hope someone here can help me through this. Thanks a lot, in advance.
a) Processing will allow you to draw static images by calling drawing routines in its setup(). I realize that OF just does not do this, but I was wondering about how to be able to do these two things: 1) How to draw a static image that won’t be recalculated every draw() frame, that then could be captured on a .png file, and also that recalculation could be retriggered only when desired. 2) How to startup an OF program and have it call a class that will draw a 2d graphic onscreen on startup that will stay there until replaced or drawn over when desired.
b) What would be the right way of implementing the same functionality of these Processing routines in OF?
pixelDensity(displayDensity());
These instructions check for display resolution on Mac Retina displays and adjust the drawing resolution accordingly.
c) I have been working on converting a sketch from Processing called Solar Flare (you can see the original code here: https://gist.github.com/jacobjoaquin/615a11ed2e8d2ff704a368e692d74ce0 ). After hacking it for a while I got the basic drawing routine working on OF, but I have run into the issue that the sum of colors that produce the shading in the original sketch through a blend(ADD) in Processing do not come out at all the same when I use OF’s ofEnableBlendMode(OF_BLENDMODE_ADD) or ofEnableAlphaBlending();
I wonder what’s going on here. I think that maybe it is that I would need to draw everything first into an FBO and then onto screen? Here’s the relevant part of my code:
//-------------in ofApp.h
const float TAU = 6.283185307179586;
vectorglm::vec2 points;
//-------------in ofApp.cpp
//in ofApp:: setup()ofBackground(0); ofSetFrameRate(1); ofSetBackgroundAuto(false); ofNoFill(); ofSetColor(255, 64, 8, 128); float reservar= (nPoints * 1000); points.reserve(reservar); for (int j=0; j < 1000; j++ ){ for (int i = 0; i < nPoints; i++){ float ii = (float) i/nPoints; double ang = (ii*TAU); points[i +(j*nPoints)]= glm::vec2(cos(ang), sin(ang)); points[i+(j*nPoints)] *= glm::vec2(ofNoise(xOffset + (points[i+(j*nPoints)].x * inc)), ofNoise(yOffset + (points[i+(j*nPoints)].y * inc))); points[i+(j*nPoints)] *=s; } xOffset += offsetInc; yOffset += offsetInc; s *=m; }
}
//--------in ofApp.cpp
//-------in draw()ofEnableBlendMode(OF_BLENDMODE_ADD); ofSetColor(255, 64, 8, 128); ofSetLineWidth(0.5); ofTranslate(ofGetWidth() * 0.8, ofGetHeight() * 0.8); ofDrawCircle(0,0,10); ofBeginShape(); for (int j=0; j < 1000; j++ ){ for (int i = 0; i<nPoints; i++){ ofVertex(points[i+(j*nPoints)]); } } ofEndShape(); ofDisableBlendMode();
Posts: 1
Participants: 1