Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Kirill_Amber

Pages: [1]
1
General / Re: Scaling a window with objects(Shape)
« on: August 08, 2019, 03:35:42 pm »
The official view tutorial is recommended to understand how the view works: https://www.sfml-dev.org/tutorials/2.5/graphics-view.php#showing-more-when-the-window-is-resized

For letter boxing there's also some code on the GitHub SFML Wiki.
Thank, brah

2
General / Re: Scaling a window with objects(Shape)
« on: August 08, 2019, 03:14:26 pm »
Handle the resize event and adjust the view accordingly. See the tutorial for more details.
What tutorials can you, pls, recommend?

3
General / Scaling a window with objects(Shape)
« on: August 08, 2019, 04:12:51 am »
Hello,

I am writing a program(in Visual Studio) that creates a function graph. The function graph consists of RectangleShape and CircleShape. I needed to, when changing the window, by shifting the frames of window, the graph was scaled, without changing its ratio (not stretched). For example, let's say the graph and the window are 800x800. If I drag the left frame to the right, then the window becomes, supposably, 500x800, then the graph should become 500x500. I tried to resize objects, reduce points, but nothing came of it ...


Here is a piece of code:
RectangleShape shape3(Vector2f(2, 800)); // axis y
RectangleShape shape4(Vector2f(800, 2)); // axis x
RectangleShape point1(Vector2f(1, 6)); // point x
RectangleShape point2(Vector2f(6, 1)); // point y
shape3.setPosition(h / 2, 0); // axis movement y
shape4.setPosition(0, w / 2); // axis movement x

for (int i = 0; i <= w; i += 4) // x coordinate points
                        {

                                point1.setPosition(i, h / 2);
                                window.draw(point1);
                        }

                        for (int i = 0; i <= h; i += 4) // y coordinate points
                        {

                                point2.setPosition(w / 2, i);
                                window.draw(point2);
                        }

...
// here I tried to do something
if (w < h)
                        {
                               
                                //shape3.setScale(w/h, w/h);
                                //shape4.setScale(w / h, w / h);
                                shape3.move(0, 30);
                                h -= (h - w);
                                shape3.setSize(Vector2f(6.f, h));
                               
                                //window.setSize(sf::Vector2u(w, h));
                        }
                        if (h < w)
                        {
                                shape4.move(30, 0);
                                //shape3.setScale(h / w, h / w);
                                //shape4.setScale(h / w, h / w);
                                w -= (w - h);
                                shape4.setSize(Vector2f(w, 6.f));
                                //window.setSize(sf::Vector2u(w, h));
                        }

 

Pages: [1]