Page 1 of 1

Graphical glitch with drawing textures

Posted: Sun Jul 14, 2019 1:57 am
by Merudo
When I use draw textures with the square tool (with snap to grid), I get weird graphical glitches around the edges of the texture.

For example, I used the following 100 by 100 pixels texture:

Image


You can see that each edge is a different color.

If I put this texture on a 100 by 100 cell (with snap to grid), I get the following image:

Image

You can see the yellow appearing at the very top. If you zoom you can also notice some tiny bit of green on the left side too.

This graphical glitch is no big deal in many settings but when trying to make walls and such by drawing, it really makes the result ugly by creating colored lines where they should be none.

For example, if I try to draw a corner, I get this:

Image

As you can see, there are some tiny strips of brown at the top and the left.

I've also noticed this glitch doesn't happen on cell (0,0), strangely enough.

Re: Graphical glitch with drawing textures

Posted: Sun Jul 14, 2019 9:26 am
by Phergus
Merudo wrote:
Sun Jul 14, 2019 1:57 am
I've also noticed this glitch doesn't happen on cell (0,0), strangely enough.
Nothing strange about it. 0,0 is where the texture drawing begins from no matter where a drawing is actually placed on the map. This way the texture in all filled areas will line up.

As soon as you get away from a 1:1 zoom, there are going to be artifacts from scaling the "texture" as you get farther from the origin. As your "texture" has single pixel lines on it this will make things even worse as the rounding pushes the single pixel line this way or that way. I'm sure it can be done better but I wouldn't count on it being addressed any time soon.

Drawing building/dungeon walls this way is doing it the hard way. If you want to draw a wall with a texture, just use the free hand or straight line drawing tools and select a texture for the pen color.

Or use your "texture" as a background stamp and just put it down wherever you need it.

Re: Graphical glitch with drawing textures

Posted: Tue Jul 23, 2019 3:39 am
by Merudo
Phergus wrote:
Sun Jul 14, 2019 9:26 am
Drawing building/dungeon walls this way is doing it the hard way. If you want to draw a wall with a texture, just use the free hand or straight line drawing tools and select a texture for the pen color.
Can't really do corners correctly with your approach, though.

Re: Graphical glitch with drawing textures

Posted: Tue Jul 23, 2019 8:41 am
by Phergus
You can if you select the square line end instead of round.

Re: Graphical glitch with drawing textures

Posted: Wed Mar 25, 2020 2:55 am
by Merudo
Phergus wrote:
Sun Jul 14, 2019 9:26 am
Merudo wrote:
Sun Jul 14, 2019 1:57 am
I've also noticed this glitch doesn't happen on cell (0,0), strangely enough.
Nothing strange about it. 0,0 is where the texture drawing begins from no matter where a drawing is actually placed on the map. This way the texture in all filled areas will line up.
I don't think this is correct.

The code in drawBackground() of ShapeDrawable has the part
g.fill(shape);
where shape holds among other things the x and y pixel coordinates of the shape to be filled with the texture.

I don't see how every texture is drawn at 0,0.

Re: Graphical glitch with drawing textures

Posted: Wed Mar 25, 2020 5:37 pm
by Phergus
This is very simple to test.

With the rectangle drawing tool active select a map image (like one of the default ones) for the Fill texture.

Start drawing rectangles on the map. Note that it is like you are revealing the map you chose as the texture as if it was placed on the background layer at 0,0.
Screenshot 2020-03-25 15.30.27.jpg
Screenshot 2020-03-25 15.30.27.jpg (741.03 KiB) Viewed 611 times