Created
December 9, 2013 17:03
-
-
Save darrenmothersele/7875928 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "testApp.h" | |
#include <ofGraphics.h> | |
void testApp::setup(){ | |
ofSetFrameRate(60); | |
ofSetBackgroundAuto(false); | |
ofEnableAlphaBlending(); | |
ofEnableSmoothing(); | |
ofBackground(255); | |
ofSetColor(0); | |
} | |
void testApp::update(){ | |
} | |
float monteCarlo() { | |
while (true) { | |
float r1 = ofRandom(1); | |
float probability = r1; | |
float r2 = ofRandom(1); | |
if (r2 < probability) { | |
return r1; | |
} | |
} | |
} | |
void testApp::draw(){ | |
float num = monteCarlo(); | |
float sd = 120; | |
float mean = ofGetWidth() / 2; | |
float x = (sd * num) + mean; | |
ofSetColor(255, 10); | |
ofRect(0, 0, ofGetWidth(), ofGetHeight()); | |
ofSetColor(0); | |
ofEllipse(x, ofGetHeight() / 2, 16, 16); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment