Hey, beginner to KorGE here. I can't find out how ...
# korge
r
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:
Copy code
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
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
Copy code
val strokeInfo = Context2d.StrokeInfo(thickness = 4.0, pixelHinting = false)
stroke(paint, strokeInfo) {
    circle(x, y, radius)
}
for example
(that would draw just one)
n
I used this code a while ago: ``````
Copy code
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
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
com/soywiz/korma/geom/vector/VectorBuilder.kt:118
the one you need is that one
r
Ah, thnx!
n
circle//
p
VectorBuilder one
r
That works, thnx!
👍 1
p
great! np man, glad to help
👍 1
r
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
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
Do you know if it's possible to have dashed or dotten stroke?
p
uhmmm, let me check...
r
I played around with
StrokeInfo
, but that didn't help
p
@Nico have you used com/soywiz/korim/vector/Context2d.strokeDot ? not sure if that's the right direction
n
nope
r
No, but I also don't know how to use it. Looks like that isn't it by looking at the code...