Hello from Sweden!

Hello, thank you for this great lib. It has really made me hopeful that i will be able to do some really neat stuff that i have pondered upon for some time now!

Is it generally OK to post newbie questions somewhere? I don’t want to litter your forum somehow hehe

But I would really like to know how I could avoid gradle not finding my openrndr-dependencies, I downloaded the template some time ago and now all of a sudden I get this when opening my project:

Could not download openrndr-gl3-0.3.44.jar (org.openrndr:openrndr-gl3:0.3.44)
Could not get resource ‘https://dl.bintray.com/openrndr/openrndr/org/openrndr/openrndr-gl3/0.3.44/openrndr-gl3-0.3.44.jar’.
Could not GET ‘https://dl.bintray.com/openrndr/openrndr/org/openrndr/openrndr-gl3/0.3.44/openrndr-gl3-0.3.44.jar’. Received status code 403 from server: Forbidden

Is there anyway to avoid or fix this in the future so that I can be sure that my project will always work?

1 Like

Hi hi! Hello from Berlin and welcome to the forum :slight_smile:

Having lots of questions in the forum would be great! Feel free to ask and share your experiments no matter how simple!

About your question: it was always the plan (afaik) to have projects work forever, but unfortunately and unexpectedly the hosting platform decided to close! :frowning: See here:

Fortunately it should be easy to fix your project.
I guess everyone hopes this doesn’t happen again.

Thanks! Is there any project that i might take a look upon to get the idea of how someone might structure their projects code?
I am kinda new to kotlin.

Also, is there anyway for shapes to be aware of eachother (like putting two shapes on the same spot will make them nudge eachother away), havent seen any of it in the tutorial and just don’t want that feeling of reinventing a wheel ^^

Project structure

I normally collect many “sketches” under the same project in Idea. For example here I have 4 Compute Shader projects (boids, cca = cyclic cellular automata, eoc = edge of chaos, ma = moving agents)

.
There’s also a folder called sketches where I experiment with things. Each one has a main method to run.

Finally, I have a folder called aBeLibs where I throw in code I want to reuse in multiple projects. I do that by having these lines in build.gradle.kts

sourceSets {
    main {
        java.srcDirs("../aBeLibs/")
    }
}

But other people don’t like that approach and prefer to have various libraries, each under a separate repo, and publish them to maven local. I didn’t do that because my “libs” are just very small helper files which I don’t feel they deserve an own repo.

Do you have any specific questions about organizing your projects?

Do you mean like some kind of physics engine to separate objects? In this direction?

I haven’t heard of any examples in that direction. But I think this can be implemented with a few simple forces to maintain cohesion, separate, etc.

Really like if i could just see someones project code so that i could see how someone might use all the kotlin and openrndr syntax.

My goal is to make different shapes and then later join them. And it all gets messy fast when my current solution is to do several
fun main() = application {

Cool! It seems that it does not really exist, for now i just want to place squares next to eachother. So it will be fun to figure out how i will program so that they are aware of eachother and do not occupy the same space :slight_smile:

1 Like

Do you mean several fun main() in the same file? or in different files?

Here you have my little mess of programs:

:slight_smile:

Different files for different fun main(), thank you for “the mess of programs” !

1 Like

Could you describe in which way it becomes messy?

Well i first just want to say that i am a backend developer in Java so my initial approach and how i “feel” like i want it to be might not optimal, i am also quite junior at that (and maybe not that bright).

Like what i would want to do is delegate the " program { " part to different files or classes, so that i could control the rendering in different places, this is because i generally never do long methods where they do different things.

For example, say i want to render 10 circles and 10 squares.
I would like to write code inside

fun main() = application {   program {   extend {
renderSquares(10, size, color, etc)
renderCircles(10, size, color, etc)

Now if i would like to do that (atleast when i tried to do it), i would have to send renderCircles(this) “this” parameter to do that and later have to do something like this.application.program.extend. Which in my meaning, is “messy”.

So my conclusion is that i am not thinking in the way i should, so i would like to see how others have accomplished this, by looking at their code :slight_smile:

One thing that I’ve seen done is to pass drawer instead of this, like in this example.

But if the functions are defined inside program then there’s no need to pass drawer around:

import org.openrndr.application
import org.openrndr.color.ColorRGBa

fun main() = application {
    program {
        fun renderSquares(count: Int, size: Int, color: ColorRGBa, etc: Int) {
            repeat(count) {
                drawer.fill = color
                drawer.rectangle(it * 20.0, it * 20.0, size.toDouble(), size
                    .toDouble())
            }
        }
        fun renderCircles(count: Int, size: Int, color: ColorRGBa, etc: Int) {
            repeat(count) {
                drawer.fill = color
                drawer.circle(it * 20.0, it * 20.0, size.toDouble())
            }
        }
        extend {
            renderSquares(10, 80, ColorRGBa.PINK, 5)
            renderCircles(15, 30, ColorRGBa.WHITE, 7)
        }
    }
}

Another option might be to add extension functions to drawer, so you can have those functions in external files, with the risk of polluting the Drawer object:

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Drawer

fun Drawer.renderSquares(count: Int, size: Int, color: ColorRGBa, etc: Int) {
    repeat(count) {
        fill = color
        rectangle(it * 20.0, it * 20.0, size.toDouble(), size.toDouble())
    }
}

fun Drawer.renderCircles(count: Int, size: Int, color: ColorRGBa, etc: Int) {
    repeat(count) {
        fill = color
        circle(it * 20.0, it * 20.0, size.toDouble())
    }
}

fun main() = application {
    program {
        extend {
            drawer.renderSquares(10, 80, ColorRGBa.PINK, 5)
            drawer.renderCircles(15, 30, ColorRGBa.WHITE, 7)
        }
    }
}

I’m also not soo experienced with Kotlin. Probably others can propose smarter approaches :slight_smile:

ps. While editing posts for this forum one can click the </> button to mark it as code. It’s probably more readable like that :slight_smile: I changed one code block in your post as an example.

Or OOP style?

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.Drawer

class MyRenderer(val drawer: Drawer) {
    fun squares(count: Int, size: Int, color: ColorRGBa, etc: Int) {
        repeat(count) {
            drawer.fill = color
            drawer.rectangle(it * 20.0, it * 20.0, size.toDouble(), size
                .toDouble())
        }
    }

    fun circles(count: Int, size: Int, color: ColorRGBa, etc: Int) {
        repeat(count) {
            drawer.fill = color
            drawer.circle(it * 20.0, it * 20.0, size.toDouble())
        }
    }

}

fun main() = application {
    program {
        val renderer = MyRenderer(this.drawer)
        extend {
            renderer.squares(10, 80, ColorRGBa.PINK, 5)
            renderer.circles(15, 30, ColorRGBa.WHITE, 7)
        }
    }
}

Hi :slight_smile: Did you figure out how to organize your code so it feels better to you?