int main() { sf::RenderWindow App(sf::VideoMode(imageWidth, imageHeight), "SFML Graphics",sf::Style::Fullscreen); // This is the SFML application initialization with the app's parameters cx[0] = 255; cx[1] = 0; cx[2] = 0; // The initial colors for the shifting kradius = 0.1; imagen.create(imageWidth,imageHeight); mandtex.create(imageWidth,imageHeight); // The scaling factor, defined by the ranges in Real and Imaginary axis, // divided by the respective axis real length. mandelb.setOrigin(imageWidth/2,imageHeight/2); mandelb.setPosition(640,400); mandelb.scale(1.5,1.5); // Set the image positioning, centering and scaling. k.real = 0; k.imag = 0; // Original K seed values. dir = false; // Direction of scan over the complex plane mandel = false; // false if painting Julia Set, true if Mandelbrot Set. draw = true; // To tell the application to pause or continue drawing, its switched by // pressing the right click. while (App.isOpen()) { sf::Event Event; while (App.pollEvent(Event)) { // SFML works with an event loop if (Event.type == sf::Event::Closed){ // If the window is closed, close the application App.close(); } if( Event.type == Event.MouseButtonReleased && Event.mouseButton.button == sf::Mouse::Left){ // If the left mouse is pressed and released, close the application App.close(); } if( Event.type == Event.MouseButtonReleased && Event.mouseButton.button == sf::Mouse::Right){ // If the right mouse is pressed and released, toggle randomness. draw = !draw; } } App.clear(); if(!draw) continue; // If false, then stop animating and freeze in the last generated frame. resolve(); //radialScan(); horizontalScan(); mandelb.setColor(sf::Color(cx[0], cx[1], cx[2])); // Shift the image hue. App.draw(mandelb); App.display(); } return EXIT_SUCCESS; }
void Texture::fillTexture(sf::Texture& texture, int width, int height, sf::Color color) { texture.create(width, height); int length = width * height * 4; sf::Uint8* buffer = new sf::Uint8[length]; for(int i = 0; i < length; i += 4) { buffer[i] = color.r; buffer[i + 1] = color.g; buffer[i + 2] = color.b; buffer[i + 3] = color.a; } texture.update(buffer); delete buffer; }
int main() { //check if top and bottom flipped sf::RenderWindow window = sf::RenderWindow(sf::VideoMode(640, 640, 32), "Perlin Noise", sf::Style::Titlebar | sf::Style::Close); sf::RenderTexture renderTexture; glewExperimental = GL_TRUE; glewInit(); srand(time(NULL)); texture.create(640,640); const float PERSISTENCE = .5; float i = 0; int count = 0; for( i = 2; i < 129; i /= PERSISTENCE){ std::cout << i; sf::Vector2f** gradients; gradients = new sf::Vector2f* [1 + (int)i]; for(int j = 0; j < (int)i + 1; j++){ gradients[j] = new sf::Vector2f[(int)i + 1]; } genRandom(gradients, i, 1 / i); drawNoise(window, gradients, i, 1 / i); for(int j = 0; j < (int)i + 1; j++){ delete[] gradients[j]; } delete[] gradients; //std::cin.get(); } display(window); std::cout << "draw"; window.display(); std::cin.get(); return 0; }
Tile() : map_x(0), map_y(0) { image.create(Tile::WIDTH, Tile::HEIGHT); texture.create(Tile::WIDTH, Tile::HEIGHT); sprite.setTexture(texture); }