kaplay icon indicating copy to clipboard operation
kaplay copied to clipboard

bug: rects having weird corners when having an outlineComp

Open amyspark-ng opened this issue 1 year ago • 6 comments

I have a rect object which im adding an outline to, it looks like this image

The code is: `kaboom()

let square = add([ rect(100, 100, { radius: 10 }), pos(center()), outline(10, BLACK) ])`

amyspark-ng avatar May 22 '24 05:05 amyspark-ng

seems like this is a issue with getArcPts() being only percise to integer angles instead of float angles

niceEli avatar May 22 '24 14:05 niceEli

is not better outline() component being a shader?

lajbel avatar May 22 '24 15:05 lajbel

@mflerackers

lajbel avatar May 22 '24 15:05 lajbel

is not better outline() component being a shader?

MF has done a shader outline and it has some issues, for it to work properly you have to do some operation which is not too performant? plus the sprites also need padding in the spriteAtlas kaboom saves the sprites in so that might cause some issues

amyspark-ng avatar May 22 '24 15:05 amyspark-ng

The reason is quite simple. Line joins are not supported. So even if you calculate the points for the line correctly, they aren't nicely joined. Lines are just drawn as separate segments with a butt linecap. So where lines at an angle join, you are going to have gaps. The solution is to add line join support for at least bevel join. Then the problem of the round rectangle outline is automatically fixed as well.

mflerackers avatar May 23 '24 10:05 mflerackers

was fixed in: https://github.com/marklovers/kaplay/commit/40e5d8cfdd7f7831b439aca2b4088f9401afe137

amyspark-ng avatar May 28 '24 15:05 amyspark-ng