本文整理汇总了C++中sf::CircleShape::setFillColor方法的典型用法代码示例。如果您正苦于以下问题:C++ CircleShape::setFillColor方法的具体用法?C++ CircleShape::setFillColor怎么用?C++ CircleShape::setFillColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::CircleShape
的用法示例。
在下文中一共展示了CircleShape::setFillColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: print
// We define this function to print the current values that were updated by the on...() functions above.
void print()
{
// Clear the current line
std::cout << '\r';
// Print out the orientation. Orientation data is always available, even if no arm is currently recognized.
std::cout << '[' << std::string(roll_w, '*') << std::string(18 - roll_w, ' ') << ']'
<< '[' << std::string(pitch_w, '*') << std::string(18 - pitch_w, ' ') << ']'
<< '[' << std::string(yaw_w, '*') << std::string(18 - yaw_w, ' ') << ']'<< std::endl;
if(color_input == true)
{ shape.setFillColor(sf::Color((roll_w*10.75), ((270+pitch_w)*10.75), ((90 +yaw_w)*10.75)));
}
if (onArm) {
// Print out the currently recognized pose and which arm Myo is being worn on.
// Pose::toString() provides the human-readable name of a pose. We can also output a Pose directly to an
// output stream (e.g. std::cout << currentPose;). In this case we want to get the pose name's length so
// that we can fill the rest of the field with spaces below, so we obtain it as a string using toString().
std::string poseString = currentPose.toString();
std::cout << '[' << (whichArm == myo::armLeft ? "L" : "R") << ']'
<< '[' << poseString << std::string(14 - poseString.size(), ' ') << ']';
} else {
// Print out a placeholder for the arm and pose when Myo doesn't currently know which arm it's on.
std::cout << "[?]" << '[' << std::string(14, ' ') << ']';
}
std::cout << std::flush;
}
示例2: Ball
Ball(float mX, float mY)
{
shape.setPosition(mX, mY);
shape.setRadius(defRadius);
shape.setFillColor(defColor);
shape.setOrigin(defRadius, defRadius);
}
示例3: gameWindow
Pong() : gameWindow(sf::VideoMode(600, 480), "Pong")
{
ball.setFillColor(sf::Color::Cyan);
ball.setPosition(100.0, 100.0);
ball.setRadius(10.f);
p1Paddle.setFillColor(sf::Color::Green);
p1Paddle.setPosition(10.0, 100.0);
p1Paddle.setSize(sf::Vector2f(10.0, 100.0));
p2Paddle.setFillColor(sf::Color::Red);
p2Paddle.setPosition(580.0, 100.0);
p2Paddle.setSize(sf::Vector2f(10.0, 100.0));
p1MovingUp = false;
p1MovingDown = false;
p2MovingUp = false;
p2MovingDown = false;
ballMovement = sf::Vector2f(ballSpeed, ballSpeed);
font.loadFromFile("arial.ttf");
p1ScoreText.setPosition(150, 10);
p1ScoreText.setFont(font);
p1ScoreText.setString(std::to_string(p1Score));
p1ScoreText.setColor(sf::Color::Red);
p1ScoreText.setCharacterSize(24);
p2ScoreText.setPosition(450, 10);
p2ScoreText.setFont(font);
p2ScoreText.setString(std::to_string(p2Score));
p2ScoreText.setColor(sf::Color::Red);
p2ScoreText.setCharacterSize(24);
}
示例4: refresh
void ColorPalette::refresh(void) {
selected.setFillColor(color);
label.setColor(color);
label.setString(ColorPalette::interpret(color, str));
rgb_c.setOutlineColor(Utility::Color::getInverseColor(color));
bw_c.setOutlineColor(Utility::Color::getInverseColor(color));
}
示例5:
Stone (float x, float y, float a, float b)
{
velocity.x = x;
velocity.y = y;
s.setRadius(radius);
s.setOrigin(radius,radius);
s.setFillColor(sf::Color::Black);
s.setPosition(a,b);
}
示例6: init
static void init(sf::RenderWindow &window)
{
window.setMouseCursorVisible(false);
window.setVerticalSyncEnabled(true);
crosshair.setFillColor(sf::Color(0, 0, 0, 0));
crosshair.setOutlineColor(sf::Color(0, 0, 0));
crosshair.setOutlineThickness(2.0f);
srand(static_cast<unsigned>(time(0)));
}
示例7: createGeometry
void createGeometry() {
fill = type == Type::Follower ? sf::Color(198, 156, 109, 255) : sf::Color(0, 191, 243, 255);
outline = type == Type::Follower ? sf::Color(166, 124, 82, 255) : sf::Color(64, 140, 203, 255);
geometry.setRadius(radius);
geometry.setPointCount(6);
geometry.setFillColor(fill);
geometry.setOutlineColor(outline);
geometry.setOutlineThickness(2);
geometry.setOrigin(radius, radius);
}
示例8: Ball
// Costruttore: prende come parametri la posizione iniziale
// della pallina, sotto forma di due `float`.
Ball(float mX, float mY)
{
// SFML usa un sistema di coordinate avente l'origine
// posizionata nell'angolo in alto a sinistra della
// finestra.
// {Info: coordinate system}
shape.setPosition(mX, mY);
shape.setRadius(defRadius);
shape.setFillColor(defColor);
shape.setOrigin(defRadius, defRadius);
}
示例9: set_circle
void set_circle(sf::CircleShape& circle, const float value, const float norm_radius,
const sf::Vector2f& position, const sf::Color& color)
{
const float radius{sqrt_value_tot_radius(value, norm_radius)};
circle.setRadius(radius);
circle.setOrigin(radius, radius);
circle.setPosition(position);
circle.setFillColor(color);
}
示例10: Polygons
Polygons():
_polygons(),
__polygonsVect()
{
_polygons.setRadius(50);
_polygons.setFillColor(sf::Color::Red);
for(int i = 3; i < 9;i++)
{
_polygons.setPointCount(i);
_polygons.setPosition(100.0 + (i*99) , 200.0);
__polygonsVect.push_back(_polygons);
}
}
示例11: cerclesTransparents
cerclesTransparents():
_mesCercles(),
__vectCercles()
{
sf::Vector2u tailleWindow = _window.getSize();
unsigned int hauteur = tailleWindow.y;
unsigned int largeur = tailleWindow.x;
float rayon = 400;
for(int i = 0 ; i < 10; i++)
{
_mesCercles.setOrigin(rayon, rayon);
_mesCercles.setPosition(400,400);
_mesCercles.setRadius(rayon);
_mesCercles.setFillColor(sf::Color(0.0, 0.0 + (25*i) , 255 - (25*i), 127));
rayon -= 25;
__vectCercles.push_back(_mesCercles);
}
cout << "Taille du vect --> " << __vectCercles.size() << endl;
}
示例12: main
int main()
{
WSADATA wsaData;
SOCKET ConnectSocket = INVALID_SOCKET;
struct addrinfo *result = NULL,
*ptr = NULL,
hints;
char sendbuf[DEFAULT_BUFLEN];
int iResult;
int recvbuflen = DEFAULT_BUFLEN;
// Initialize Winsock
iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != 0)
{
printf("WSAStartup failed with error: %d\n", iResult);
return 1;
}
ZeroMemory(&hints, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;
// Resolve the server address and port
iResult = getaddrinfo("localhost", DEFAULT_PORT, &hints, &result);
if (iResult != 0)
{
printf("getaddrinfo failed with error: %d\n", iResult);
WSACleanup();
return 1;
}
// Attempt to connect to an address until one succeeds
for (ptr = result; ptr != NULL; ptr = ptr->ai_next)
{
// Create a SOCKET for connecting to server
ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol);
if (ConnectSocket == INVALID_SOCKET)
{
printf("socket failed with error: %ld\n", WSAGetLastError());
WSACleanup();
return 1;
}
// Connect to server.
iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen);
if (iResult == SOCKET_ERROR)
{
closesocket(ConnectSocket);
ConnectSocket = INVALID_SOCKET;
continue;
}
break;
}
freeaddrinfo(result);
if (ConnectSocket == INVALID_SOCKET)
{
printf("Unable to connect to server!\n");
WSACleanup();
return 1;
}
std::thread th(ReceiveThread, ConnectSocket);
th.detach();
std::thread th1(SendThread, ConnectSocket);
th1.detach();
sf::RenderWindow window(sf::VideoMode(800, 200), "SFML works!");
shape.setFillColor(sf::Color::Green);
sf::Event event;
while (window.isOpen())
{
while (window.pollEvent(event))
{
switch (event.type)// check the type of the event...
{
case sf::Event::Closed:
window.close();
break;
case sf::Event::KeyPressed:
movementMutex.lock();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
movement-=5;
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
movement+=5;
movementMutex.unlock();
break;
default:
break;
}
}
//.........这里部分代码省略.........
示例13: pose
TEST_F(EntityFixture, PlayerTest) {
GetInput().assignKey(sf::Keyboard::W, Input::Up);
GetInput().assignKey(sf::Keyboard::A, Input::Left);
GetInput().assignKey(sf::Keyboard::S, Input::Down);
GetInput().assignKey(sf::Keyboard::D, Input::Right);
GetInput().assignMouseButton(sf::Mouse::Left, Input::Shoot);
GetInput().setMouseLock(true);
GetWindow().setMouseCursorVisible(false);
dot.setFillColor(sf::Color::Red);
// Add behaviors
playerUpdater = da::BehaviorPtr(new PlayerUpdater(GetView(), GetInput()));
GetManager().addBehavior(playerUpdater);
GetManager().addBehavior(velocitiesUpdater);
GetManager().addBehavior(walker);
GetManager().addBehavior(poseUpdater);
GetManager().addBehavior(xformHistorian);
// Add spatial
GetRenderer().registerSpatial<SpriteSpatial>();
// Create entity
entity = GetManager().create();
entity->addAttribute(new da::Transform);
entity->addAttribute(new da::Depth);
da::TexturePtr texture = GetContent().load<sf::Texture>("mans.png");
entity->addAttribute(new Sprite(texture));
entity->addAttribute(new TransformHistory);
entity->addAttribute(new Collider);
entity->addAttribute(new Velocities);
Poses *poses = new Poses;
Pose pose(6);
for (unsigned int j = 0; j < DirectionCount; j++) {
for (unsigned int i = 0; i < pose.getFrameCount(); i++) {
Pose::Frame frame = {
sf::IntRect(i * 16, j * 24, 16, 24),
sf::Vector2f(8, 20)
};
pose.setFrame((CardinalDirection)j, i, frame);
}
}
poses->addPose("walk", pose);
poses->isLoop = true;
poses->timePerFrame = sf::seconds(0.25f);
poses->setPose("walk", 0);
entity->addAttribute(poses);
Player *player = new Player;
player->walkSpeed = 100.f;
player->viewDistance = 40.f;
entity->addAttribute(player);
GetManager().refresh(entity);
Run(update, emptyHandler, draw);
}
示例14: main
int main(int argc, char** argv)
{ sf::RenderWindow window(sf::VideoMode(400, 400), "Myo color picker");
shape.setPosition(sf::Vector2f(50, 50));
shape.setFillColor(sf::Color::Green);
color_input = true;
// We catch any exceptions that might occur below -- see the catch statement for more details.
try {
// First, we create a Hub with our application identifier. Be sure not to use the com.example namespace when
// publishing your application. The Hub provides access to one or more Myos.
myo::Hub hub("com.example.hello-myo");
std::cout << "Attempting to find a Myo..." << std::endl;
// Next, we attempt to find a Myo to use. If a Myo is already paired in Myo Connect, this will return that Myo
// immediately.
// waitForAnyMyo() takes a timeout value in milliseconds. In this case we will try to find a Myo for 10 seconds, and
// if that fails, the function will return a null pointer.
myo::Myo* myo = hub.waitForMyo(10000);
// If waitForAnyMyo() returned a null pointer, we failed to find a Myo, so exit with an error message.
if (!myo) {
throw std::runtime_error("Unable to find a Myo!");
}
// We've found a Myo.
std::cout << "Connected to a Myo armband!" << std::endl << std::endl;
// Next we construct an instance of our DeviceListener, so that we can register it with the Hub.
DataCollector collector;
// Hub::addListener() takes the address of any object whose class inherits from DeviceListener, and will cause
// Hub::run() to send events to all registered device listeners.
hub.addListener(&collector);
// Finally we enter our main loop.
while (1) {
// In each iteration of our main loop, we run the Myo event loop for a set number of milliseconds.
// In this case, we wish to update our display 20 times a second, so we run for 1000/20 milliseconds.
hub.run(1000/20);
// After processing events, we call the print() member function we defined above to print out the values we've
// obtained from any events that have occurred.
collector.print();
if(window.isOpen())
{ sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
{ window.close();
return 0;
}
}
window.clear();
window.draw(shape);
window.display();
}
}
// If a standard exception occurred, we print out its message and exit.
} catch (const std::exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
std::cerr << "Press enter to continue.";
std::cin.ignore();
return 1;
}
}
示例15:
Ball(float mX, float mY) {
shape.setPosition(mX, mY);
shape.setRadius(ballRadius);
shape.setFillColor(sf::Color::Red);
shape.setOrigin(ballRadius, ballRadius);
}