https://kotlinlang.org logo
Title
r

Rachid

07/02/2020, 7:21 PM
Hey, beginner to KorGE here. I can't find out how do do something simple as: drawing a circle with a border. So the border should have another color than the filling. I followed the tutorials on the website/youtube. And went through all the korge-samples. Only thing I found what looks related is
fillStroke
, but I have no idea how to apply this in a clean hello world where I only draw a circle...
I tried this:
graphics {
		fillStroke(ColorPaint(Colors.DARKGREEN), ColorPaint(Colors.RED), Context2d.StrokeInfo(thickness = 3.0)) {
			circle(20.0).xy(200, 100).interactive()
		}
	}
but this got me a white circle without border
p

Pablo Caviglia

07/02/2020, 7:25 PM
what about drawing two concentric circles, the outer one with a radius little bigger than the inner one ?
you can use korge's circle to draw a circle
val strokeInfo = Context2d.StrokeInfo(thickness = 4.0, pixelHinting = false)
stroke(paint, strokeInfo) {
    circle(x, y, radius)
}
for example
(that would draw just one)
n

Nico

07/02/2020, 7:32 PM
I used this code a while ago: ``````
val circleWithStroke = graphics {
   fillStroke(
      ColorPaint(Colors.GREEN),
      ColorPaint(Colors.RED),
      Context2d.StrokeInfo(thickness = 3.0)
   ) {
      circle(0.0, 0.0, 10.0)
   }
}.xy(100.0, 100.0)
r

Rachid

07/02/2020, 7:33 PM
Hm, but copy-pasting both examples doesn't compile for me. The
circle
function in my file refers to
inline fun Container.circle
That has a different signature. Any idea what causes this, I had this with other code samples as well
p

Pablo Caviglia

07/02/2020, 7:35 PM
com/soywiz/korma/geom/vector/VectorBuilder.kt:118
the one you need is that one
r

Rachid

07/02/2020, 7:35 PM
Ah, thnx!
n

Nico

07/02/2020, 7:35 PM
circle//
p

Pablo Caviglia

07/02/2020, 7:35 PM
VectorBuilder one
r

Rachid

07/02/2020, 7:36 PM
That works, thnx!
👍 1
p

Pablo Caviglia

07/02/2020, 7:36 PM
great! np man, glad to help
👍 1
r

Rachid

07/02/2020, 7:37 PM
So actually, what I want is a border bigger than the circle itself when I "select" it. I guess in that case I can do the trick @Pablo Caviglia mentioned about the "two concentric circles"
👍 1
p

Pablo Caviglia

07/02/2020, 7:38 PM
yeah, i dont know if that's the best approach... but it's easy to understand and it works
at the end of the day it's actually drawing the circles using canvas' primitives, will not make any difference in draw a transparent hole in one of the circles... in fact that's probably costful than drawing one in top of another
r

Rachid

07/02/2020, 7:46 PM
Do you know if it's possible to have dashed or dotten stroke?
p

Pablo Caviglia

07/02/2020, 7:46 PM
uhmmm, let me check...
r

Rachid

07/02/2020, 7:47 PM
I played around with
StrokeInfo
, but that didn't help
p

Pablo Caviglia

07/02/2020, 7:48 PM
@Nico have you used com/soywiz/korim/vector/Context2d.strokeDot ? not sure if that's the right direction
n

Nico

07/02/2020, 7:49 PM
nope
r

Rachid

07/02/2020, 7:52 PM
No, but I also don't know how to use it. Looks like that isn't it by looking at the code...