本文整理汇总了C++中ofPixels::getColor方法的典型用法代码示例。如果您正苦于以下问题:C++ ofPixels::getColor方法的具体用法?C++ ofPixels::getColor怎么用?C++ ofPixels::getColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofPixels
的用法示例。
在下文中一共展示了ofPixels::getColor方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void Sample::update(const ofRectangle& vidRect,
const ofVec2f& vidSize,
const ofPixels& pixels) {
_pos.set(vidRect.x + (vidRect.width * _vidPercent.x),
vidRect.y + (vidRect.height * _vidPercent.y));
// parse r, g, b, a values
ofColor c = pixels.getColor(vidSize.x * _vidPercent.x,
vidSize.y * _vidPercent.y);
_smoothedVals[0].addValue(c.r);
_smoothedVals[1].addValue(c.g);
_smoothedVals[2].addValue(c.b);
val[0] = int(_smoothedVals[0].getValue());
val[1] = int(_smoothedVals[1].getValue());
val[2] = int(_smoothedVals[2].getValue());
// http://stackoverflow.com/questions/596216/formula-to-determine-brightness-of-rgb-color
// https://en.wikipedia.org/wiki/Relative_luminance
val[3] = int((0.2126 * val[0] + 0.7152 * val[1] + 0.0722 * val[2])); // luminance
vals[_valsIndex] = val;
if (_valsIndex > BUFFER_SIZE - 1) {
_valsIndex = 0;
} else {
_valsIndex++;
}
}
示例2: desaturate
void desaturate(ofPixels &pix) {
// desaturate
for (int i = 0; i < 1024; ++i)
for (int j = 0; j < 768; ++j)
{
ofColor col = pix.getColor(i, j);
pix.setColor(i, j, ofColor(col.getBrightness()));
}
}
示例3: clearBlobs
void ofApp::clearBlobs(){
// turn all the blobs off
for(int i=0; i<totalSpeakers;i++){
if(pix.getColor(solenoidArray[i].pos.x, solenoidArray[i].pos.y).r>0){
solenoidArray[i].isActive=false;
ofxOscMessage n;
n.setAddress("/OF");
n.addFloatArg(i);
n.addIntArg(solenoidArray[i].isActive);
n.addIntArg(playMode);
sender.sendMessage(n);
}
}
blobArray.clear();
blobCount=0;
nodeID=blobCount;
}
示例4: draw
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(0, 0, 0);
fbo.begin();
ofClear(0.,0.,0., 0.);
if(playMode==0){drawWaves();}
else if (playMode==1){drawBlobs();}
fbo.end();
fbo.readToPixels(pix);
pix.getData();
for(int i=0; i<totalSpeakers;i++){
if(pix.getColor(solenoidArray[i].pos.x, solenoidArray[i].pos.y).r>0 && solenoidArray[i].isActive==false){
solenoidArray[i].isActive=true;
solenoidArray[i].timeStamp=ofGetElapsedTimeMillis();
}
if(solenoidArray[i].isActive != activeSolenoid[i]){
ofxOscMessage n;
n.setAddress("/OF");
n.addFloatArg(i);
n.addIntArg(playMode); // playMode
n.addIntArg(solenoidArray[i].isActive); //is active?
n.addIntArg(nodeID); //index
sender.sendMessage(n);
activeSolenoid[i] = solenoidArray[i].isActive;// update our reference node
cout << "OSC: Noid "<< i << " is " << solenoidArray[i].isActive << " -- nodeID: " << nodeID << endl;
}
}
// fbo.draw(0,0);
// ofDrawBitmapString(msg, ofGetWidth()/2, ofGetHeight()/2);
for (int i=0; i<totalSpeakers; i++) {
drawCircle(i);
}
}
示例5: addFrame
// by now we're copying everything (no pointers)
void ofxGifFile::addFrame(ofPixels _px, int _left, int _top, bool useTexture, GifFrameDisposal disposal, float _duration){
ofxGifFrame f;
if(getNumFrames() == 0){
accumPx = _px; // we assume 1st frame is fully drawn
if ( !useTexture ){
f.setUseTexture(false);
}
f.setFromPixels(_px , _left, _top, _duration);
gifDuration = _duration;
} else {
// add new pixels to accumPx
int cropOriginX = _left;
int cropOriginY = _top;
// [todo] make this loop only travel through _px, not accumPx
for (int i = 0; i < accumPx.getWidth() * accumPx.getHeight(); i++) {
int x = i % accumPx.getWidth();
int y = i / accumPx.getWidth();
if (x >= _left && x < _left + _px.getWidth() &&
y >= _top && y < _top + _px.getHeight()){
int cropX = x - cropOriginX; // (i - _left) % _px.getWidth();
int cropY = y - cropOriginY;
//int cropI = cropX + cropY * _px.getWidth();
if ( _px.getColor(cropX, cropY).a == 0 ){
switch ( disposal ) {
case GIF_DISPOSAL_BACKGROUND:
_px.setColor(x,y,bgColor);
break;
case GIF_DISPOSAL_LEAVE:
case GIF_DISPOSAL_UNSPECIFIED:
_px.setColor(x,y,accumPx.getColor(cropX, cropY));
// accumPx.setColor(x,y,_px.getColor(cropX, cropY));
break;
case GIF_DISPOSAL_PREVIOUS:
_px.setColor(x,y,accumPx.getColor(cropX, cropY));
break;
}
} else {
accumPx.setColor(x, y, _px.getColor(cropX, cropY) );
}
} else {
if ( _px.getColor(x, y) == bgColor ){
switch ( disposal ) {
case GIF_DISPOSAL_BACKGROUND:
accumPx.setColor(x,y,bgColor);
break;
case GIF_DISPOSAL_UNSPECIFIED:
case GIF_DISPOSAL_LEAVE:
accumPx.setColor(x,y,_px.getColor(x, y));
break;
case GIF_DISPOSAL_PREVIOUS:
_px.setColor(x,y,accumPx.getColor(x, y));
break;
}
} else {
accumPx.setColor(x, y, _px.getColor(x, y) );
}
}
}
if ( !useTexture ){
f.setUseTexture(false);
}
f.setFromPixels(_px,_left, _top, _duration);
}
accumPx = _px;
//
gifFrames.push_back(f);
}