Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "Ruler" style croshair #163

Open
notevenaperson opened this issue Oct 23, 2022 · 5 comments
Open

Feature request: "Ruler" style croshair #163

notevenaperson opened this issue Oct 23, 2022 · 5 comments

Comments

@notevenaperson
Copy link

Aligning screen elements is easier with a crosshair that looks like this:
hacksaw

hacksaw2

@notevenaperson notevenaperson changed the title (Feature) "Ruler" style croshair Feature request: "Ruler" style croshair Oct 25, 2022
@allmeta
Copy link

allmeta commented Jan 10, 2023

Maybe it's possible to create a shader that does it?

@meganukebmp
Copy link

Maybe it's possible to create a shader that does it?

This will work

#version 120
uniform sampler2D texture;
uniform sampler2D desktop;
uniform vec2 screenSize;
uniform vec2 mouse;

varying vec2 uvCoord;

void main() {

    vec2 pixel = vec2(1,1)/screenSize;

    vec2 mpos = vec2(mouse.x, -mouse.y)/screenSize + vec2(0,1);
    
    vec4 color = vec4(0,0,0,0);
    if (distance(mpos.x, uvCoord.x) < pixel.x || distance(mpos.y, uvCoord.y) < pixel.y) {
        color = vec4(1,1,1,1);
    }

    gl_FragColor = color;
}

@notevenaperson
Copy link
Author

$ slop
Failed to detect a compositor, OpenGL hardware-acceleration disabled...

I don't use a compositor so a shader isn't the solution for me

This will work

#version 120
uniform sampler2D texture;
uniform sampler2D desktop;
uniform vec2 screenSize;
uniform vec2 mouse;

varying vec2 uvCoord;

void main() {

    vec2 pixel = vec2(1,1)/screenSize;

    vec2 mpos = vec2(mouse.x, -mouse.y)/screenSize + vec2(0,1);
    
    vec4 color = vec4(0,0,0,0);
    if (distance(mpos.x, uvCoord.x) < pixel.x || distance(mpos.y, uvCoord.y) < pixel.y) {
        color = vec4(1,1,1,1);
    }

    gl_FragColor = color;
}

Nice. You could add your shader to https://github.com/naelstrof/slop/tree/master/shaderexamples in a pull request.

@meganukebmp
Copy link

I don't use a compositor so a shader isn't the solution for me

Do you even see the generic outline when making a selection? If so, you might be able to just use that drawing code to also add your crosshair https://github.com/naelstrof/slop/blob/master/src/xshaperectangle.cpp

@notevenaperson
Copy link
Author

Do you even see the generic outline when making a selection?

I do.

If so, you might be able to just use that drawing code to also add your crosshair https://github.com/naelstrof/slop/blob/master/src/xshaperectangle.cpp

Thanks for the pointer, I could do it someday.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants