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 - Dajcok

Pages: [1]
1
Graphics / Re: Is there a way to load PDF document into image buffer ?
« on: February 01, 2021, 02:10:09 pm »
All the good stuff SFML provides is for that "some stuff" i need to make with that pdf. I need to position, rotate, scale other images and place them to this PDF file. After that i need to group these images and the pdf document into a single image and export it to a printer.

2
Graphics / Is there a way to load PDF document into image buffer ?
« on: February 01, 2021, 01:50:51 pm »
Hello,
I'm making a project for one company. What they want from me is load a PDF document, make some stuff with it and then export it to a printer. I thought that SFML will be good library for this project since it is easy to use and it provides many useful functions for project like this. But I have a problem with the first step. I cannot see a way to load PDF file into SFML. Maybe I should convert PDF into JPG and then load it but it is too difficult and I'm looking for an easier solution if it exists. Any tips or tricks ?

3
Graphics / Export whole scene(multiple images) to a one JPG(PNG) file
« on: January 24, 2021, 01:49:20 pm »
Hello,
let's suppose that we have multiple images in our scene. We loaded them using method which SFML provides. Is there a way to "group" these images and save them all to a one image file(JPG, PNG...) ?

4
Graphics / Re: Position of drawn pixels
« on: May 30, 2020, 10:43:58 am »
Thanks very much, I didn't think about this possibility at all.  ;D

5
Graphics / Position of drawn pixels
« on: May 29, 2020, 03:25:44 pm »
Hello,
I'm trying to create function which will check mousePosition in order to check if it collides with visible area of my object and if yes it will delete the object from an array. For example: If I go with cursor over some circle's outline(when I draw circle only outlines are enabled to be visible in my window) and then I click on the outline the circle will be deleted from my circle vector. It can be done trough sin and cos but it would be very uneficient since it would have to store position from every pixel in the perimeter of that circle for every circle I draw so I was wondering if there's is some kind of OpenGL or SFML function which can tell position of the pixels in circles outline so i can write som code like:

for(int i = 0; i < object.countOfDrawnPixels() /*<-- function that I am seeking for */; i++)
{
 if(object.getCoordinatesOfPixel.at(i) /*<-- also function that I am seeking for*/ == sf::Mouse::getPosition())
 {
   pixelTriggered = true;
 }
}
 

6
Graphics / sf::View - why is my minimap transparent
« on: April 28, 2020, 12:14:57 pm »
Hello,
I´m making a CAD program and I would like to include minimap which will show me where am I zoomed in etc.
One view shows my enviroment for drawing with current position where am I and the other is minimap which shows 100% of my enviroment. My problem comes when I am drawing stuff to the Views as it for some reason collide with each other as you can see on the screenshot. Even at Red rectangle with 0 transparency. It looks like that I am drawing my background grid to the minimap 2 times but when I try to take it somwhere else in the code so it won´t collide with my camera it doesn´t show up at all. Can you help me solve where I should place my draw for background grid so it won´t collide with my minimap ?

void targetWindow::worldCamera()
{
        if (!event)
        {
                if (setup)// this basically sets up my camera and it run just first time of loop
                {
                        this->camera.setCenter({ 0, 0 }); //camera is private object in targetWindow which
                        this->camera.setSize({1280, 720});//just creates view
                        setup = false;                              
                }
                this->camera.setView(window);
        }

       //here is other stuff which handle camera zooming and moving
}

void targetWindow::minimap()
{
        if (mSetup)
        {
                minimapView.setCenter({ 0, 0 }); //minimapView is private object in targetWindow which
                minimapView.setSize({ 3842, 2162 });//just creates another view
                minimapView.camera.setViewport(sf::FloatRect(0.75f, 0.f, 0.25f, 0.25f));

                mMapPosition.setSize({ 1280, 720 });//this is that red rectangle which will show position of main
                mMapPosition.setPosition({ 0,0 });     //camera
                mMapPosition.setFillColor(sf::Color::Red);

                mSetup = false;
        }

        minimapView.setView(window);
}

void targetWindow::update()
{
       
        minimap();
        window.clear(bgColor);//some color for background
        window.draw(mMapPosition);//red rectangle
        window.draw(backgroundObj);//grid

        worldCamera();
        window.draw(backgroundObj);//I think that this causes the problem as it should be somewhere else
        window.display();                   //but I don´t really know where as I´m not very familiar with
                                                     //sf::View behavior
        sf::sleep(sf::milliseconds(clockVar));
}
 

7
Graphics / Custom shape class error
« on: March 31, 2020, 01:28:55 pm »
Hello,
I created custom shape for my project and when I want to call object of this class i get an error: Object of abstract class "dcad::DimensioningLine" is not allowed pure virtual function "sf::Shape::getPoint()" has no overrider.
Here is the code:
#ifndef DCAD_DIMENSIONINGLINE_H
#define DCAD_DIMENSIONINGLINE_H


#include "SFML/Graphics.hpp"

namespace dcad
{
        class DimensioningLine : public sf::Shape
        {
        public:

                explicit DimensioningLine(const sf::Vector2f& size = sf::Vector2f(0, 0)) :
                        m_size(size)
                {
                        update();
                }

                void setSize(const sf::Vector2f& size)
                {
                        m_size = size;
                        update();
                }

                const sf::Vector2f& getSize() const
                {
                        return m_size;
                }

                virtual std::size_t getPointCount() const
                {
                        return 10;
                }

                virtual sf::Vector2f getPoint(unsigned int index) const
                {
                        float x, y;

                        switch (index)
                        {
                        default:
                        case 0: return sf::Vector2f(x, y);
                        case 1: return sf::Vector2f(x + 7, y + 7);
                        case 2: return sf::Vector2f(x + 14, y);
                        case 3: return sf::Vector2f(x + 7, y + 7);
                        case 4: return sf::Vector2f(x + 7, y - 7);
                        case 5: return sf::Vector2f(x + 7 + m_size.x, y);
                        case 6: return sf::Vector2f(x + 7 + m_size.x, y + 7);
                        case 7: return sf::Vector2f(x + m_size.x, y);
                        case 8: return sf::Vector2f(x + 7 + m_size.x, y + 7);
                        case 9: return sf::Vector2f(x + 14 + m_size.x, y);
                        }
                }

        private:

                sf::Vector2f m_size;
        };
}
#endif DCAD_DIMENSIONINGLINE_H
Anyone knows why am I getting this error ?

8
Graphics / Re: Custom ellipse shape pointCount
« on: March 16, 2020, 12:09:45 pm »
i got it thx very much ;D

9
Graphics / Custom ellipse shape pointCount
« on: March 16, 2020, 11:18:28 am »
Hello I've made custom ellipse shape according to this code:
#pragma once

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>

class EllipseShape : public sf::Shape
{
public:

        explicit EllipseShape(const sf::Vector2f& radius = sf::Vector2f(0.f, 0.f)) :
                m_radius(radius)
        {
                update();
        }

        void setRadius(const sf::Vector2f& radius)
        {
                m_radius = radius;
                update();
        }

        const sf::Vector2f& getRadius() const
        {
                return m_radius;
        }

        virtual std::size_t getPointCount() const
        {
                return 30;
        }

        virtual sf::Vector2f getPoint(std::size_t index) const
        {
                static const float pi = 3.141592654f;

                float angle = index * 2 * pi / getPointCount() - pi / 2;
                float x = std::cos(angle) * m_radius.x;
                float y = std::sin(angle) * m_radius.y;

                return sf::Vector2f(m_radius.x + x, m_radius.y + y);
        }

        //void setPointCount(std::size_t count);

private:
        std::size_t m_pointCount;
        sf::Vector2f m_radius;
};

I would like to set point count to this ellipse because it's too edgy when i resize it. I added there void setPointCount(std::size_t count) according to circleshape.hpp but i couldn't find definition of that function. Any ideas how can I define that function so it would add more points to that ellipse ?

10
Graphics / Re: Circles and ellipses are too edgy (liny)
« on: March 06, 2020, 09:50:15 am »
Default number of points is 30 (at least on CircleShape I tested). It is normal that when u scale it way bigger to be visible. Increase the number of points when making the obj or use .setPointCount()
It works  8). Thank you very much for help ;D ;D

11
Graphics / Circles and ellipses are too edgy (liny)
« on: March 05, 2020, 10:10:15 pm »
Hello,
I'm making program that can draw stuff. Problem comes when I draw circles and ellipses. As long as they're small in size it's ok but when I resize it the lines from which are circles made starts to be very visible. I've tried AA but haven't seen any difference. Is there any way to solve this problem or maybe add more lines to shape ?

12
General / Re: SFML behaves odd
« on: January 16, 2020, 01:24:11 pm »
I knew it will be something so primitive.. I'm so stupid... Thx for help  ;D

13
General / SFML behaves odd
« on: January 16, 2020, 12:24:15 pm »
Hello guys,

I'm making drawing program as my school project and i have little trouble with it. I have several shapes which you can draw like triangles, rectangles,... , and I want to include user's own shapes.

void Shapes::getShape(int mousePositionXShapes, int mousePositionYShapes //gets mouse position from another function)
{
        sf::VertexArray userShape(sf::TrianglesStrip, arrayLength);

        if (clickRelease)
        {
                if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
                {
                        userShape[n].position = sf::Vector2f(mousePositionXShapes, mousePositionYShapes);
                        userShape[n].color = sf::Color::Yellow;

                        if (n != 0)
                        {
                                int positionX = userShape[n - 1].position.x;
                                int currentPositionX = userShape[n].position.x;

                                cout << "previous position: " << positionX << endl;
                                cout << "current position: " << currentPositionX << endl;
                        }

                        clickRelease = false;
                }
        }

        else if (!sf::Mouse::isButtonPressed(sf::Mouse::Left))
        {
                if (!clickRelease)
                {
                        clickRelease = true;

                        arrayLength++;
                        n++;

               
                }
        }

        window.clear(sf::Color::White);
        window.draw(userShape);
        window.display();

        //drawShape(userShape);

}
 

This part of code should let user choose his own points by clicking. If he will click 3 points it will form into triangle and each next point will add next triangle. It's basically this: https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php -> Primitive Types -> sf::TriangleStrip.

Problem comes when I start the program. First click will define position for first vertex but if i click again for another vertex position, previous vertex will be removed.

Console output looks like this:
previous position: 0
current position: 683
previous position: 0
current position: 1021
previous position: 0
current position: 451
previous position: 0
current position: 527

Why is this happening ?

Pages: [1]