korlibs / korge

KorGE Game Engine. Multiplatform Kotlin Game Engine
https://korge.org/
Other
2.46k stars 123 forks source link

Allow setting stroke width on line() #2143

Open davjhan opened 6 months ago

davjhan commented 6 months ago

On the Line class, there is no way to specify a stroke width.

davjhan commented 6 months ago

I do now see that If I use the graphics builder directly, I can* build lines with strokes:

 graphics {
    stroke(myColor, lineWidth = 4) {
      moveTo(...)
      lineTo(...)
   }
}

But I still think it would be nice to support this in the line() syntactic sugar APIs

soywiz commented 6 months ago

It would make sense to have the stroke indeed.

But the internal implementation would need a major rework.

The idea of the Line and Outline view classes were to have a way to use the line batcher that uses the internal line primitives from OpenGL whose line width is not implemented on OpenGLES/WebGL. But I believe people using those clases might expect to behave like the rest ones.

So maybe we should rename those clases to something like SinglePixelOutline or DebugOutline and provide an implementation supporting more features here.

In any case, for now, keep using the graphics one, and I'll mark this as a feature request.

davjhan commented 6 months ago

Thanks! Agree with the path forward.

So if I understand this correctly, the OpenGL api does support stroke width, but the OpenGLES/WebGL implementation doesn't support this?

If so, then what is it that happens under the hood when drawing the line with graphics{ ... }? As I understand it, for web and mobile, it too would also use openGL to draw a line?