korge icon indicating copy to clipboard operation
korge copied to clipboard

Allow setting stroke width on line()

Open davjhan opened this issue 1 year ago • 3 comments

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

davjhan avatar Feb 01 '24 04:02 davjhan

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

davjhan avatar Feb 01 '24 20:02 davjhan

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.

soywiz avatar Feb 02 '24 08:02 soywiz

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?

davjhan avatar Feb 02 '24 22:02 davjhan