text
stringlengths
0
2.2M
}
}
}
//2 - UPDATE OUR POSITION
pos += vel;
//3 - (optional) LIMIT THE PARTICLES TO STAY ON SCREEN
//we could also pass in bounds to check - or alternatively do this at the ofApp level
if( pos.x > ofGetWidth() ){
pos.x = ofGetWidth();
vel.x *= -1.0;
}else if( pos.x < 0 ){
pos.x = 0;
vel.x *= -1.0;
}
if( pos.y > ofGetHeight() ){
pos.y = ofGetHeight();
vel.y *= -1.0;
}
else if( pos.y < 0 ){
pos.y = 0;
vel.y *= -1.0;
}
}
//------------------------------------------------------------------
void demoParticle::draw(){
if( mode == PARTICLE_MODE_ATTRACT ){
ofSetColor(255, 63, 180);
}
else if( mode == PARTICLE_MODE_REPEL ){
ofSetColor(208, 255, 63);
}
else if( mode == PARTICLE_MODE_NOISE ){
ofSetColor(99, 63, 255);
}
else if( mode == PARTICLE_MODE_NEAREST_POINTS ){
ofSetColor(103, 160, 237);
}
ofDrawCircle(pos.x, pos.y, scale * 4.0);
}
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#include <thread>
#include <folly/experimental/LockFreeRingBuffer.h>
#include <folly/portability/GTest.h>
#include <folly/test/DeterministicSchedule.h>
namespace folly {
TEST(LockFreeRingBuffer, writeReadSequentially) {
const int capacity = 256;
const int turns = 4;
LockFreeRingBuffer<int> rb(capacity);
LockFreeRingBuffer<int>::Cursor cur = rb.currentHead();
for (unsigned int turn = 0; turn < turns; turn++) {
for (unsigned int write = 0; write < capacity; write++) {
int val = turn * capacity + write;
rb.write(val);
}
for (unsigned int write = 0; write < capacity; write++) {
int dest = 0;
ASSERT_TRUE(rb.tryRead(dest, cur));
ASSERT_EQ(turn * capacity + write, dest);
cur.moveForward();
}
}
}