Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wiki with better documentation #28

Open
DanielMartinus opened this issue Sep 4, 2017 · 1 comment
Open

Create wiki with better documentation #28

DanielMartinus opened this issue Sep 4, 2017 · 1 comment

Comments

@DanielMartinus
Copy link
Owner

Lots of stuff is missing, for example that you're able to create your own emitter. Also things can be explained in a better way.

@soundlicious
Copy link

soundlicious commented Nov 6, 2018

Hi @DanielMartinus I did a quick canvas extension to draw a star, but the physic brokes when using it, I'm probably missing something there.

fun Canvas.drawStar(rectF: RectF, paint: Paint){
    onDraw(this, paint, rectF)
}

private fun onDraw(canvas: Canvas, paint: Paint, rectF: RectF) {
    val spikes = 5
    var rot = Math.PI / 2 * 3
    val step = Math.PI / spikes
    val path = Path()
    val midX = rectF.centerX()
    val midy = rectF.centerY()
    val outerRadius= if (midX > midy) midy else midX
    val innerRadius = outerRadius / 2

    paint.style = Paint.Style.FILL

    path.moveTo(midX, midy - outerRadius)
    (0..spikes).forEach{ _ ->
        var x: Float = (midX + Math.cos(rot) * outerRadius).toFloat()
        var y: Float = (midy + Math.sin(rot) * outerRadius).toFloat()
        path.lineTo(x, y)
        rot += step

        x = (midX + Math.cos(rot) * innerRadius).toFloat()
        y = (midy + Math.sin(rot) * innerRadius).toFloat()
        path.lineTo(x, y)
        rot += step
    }

    path.lineTo(midX, midy - outerRadius)
    path.close()
    canvas.drawPath(path, paint)
}

I think giving a documentation on how to properly make an extension without breaking the physic could help introduce new shape and let people do their own fork for the shapes they need.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants