Skip to content

Commit

Permalink
Merge branch 'main' into add-dynamic-framerate
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMartinus authored Dec 10, 2023
2 parents ea4b1e2 + 3974e42 commit c01dd64
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 27 deletions.
3 changes: 1 addition & 2 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,5 @@ fun Shape.draw(drawScope: DrawScope, particle: Particle, imageResource: ImageBit
drawable.draw(it.nativeCanvas)
}
}
is Shape.Text -> {
drawScope.drawIntoCanvas {
it.nativeCanvas.drawText(text, particle.x, particle.y, particle.paint)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package nl.dionsegijn.konfetti.core

import android.graphics.Paint
import nl.dionsegijn.konfetti.core.models.Shape

/**
Expand All @@ -25,5 +24,4 @@ data class Particle(
val scaleX: Float,
val shape: Shape,
val alpha: Int,
val paint: Paint
)
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,5 @@ fun Confetti.toParticle(): Particle {
scaleX,
shape,
alpha,
paint
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ class Confetti(
val rotationSpeed2D: Float = 1f,
val pixelDensity: Float
) {
val paint: Paint = Paint()

init {
if (shape is Shape.Text) {
paint.textSize = shape.textSizeInPixels
}
}

var rotation = 0f
private var rotationWidth = width
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,4 @@ sealed interface Shape {
drawable.intrinsicHeight.toFloat() / drawable.intrinsicWidth
}
}

data class Text(
val text: String,
val textSizeInPixels: Float
) : Shape
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import nl.dionsegijn.konfetti.core.models.Shape.Text
* `size` and must vertically/horizontally center their asset if it does not have an equal width
* and height.
*/
fun Shape.draw(particle: Particle, canvas: Canvas, paint: Paint, size: Float) {
fun Shape.draw(canvas: Canvas, paint: Paint, size: Float) {

when (this) {
Square -> canvas.drawRect(0f, 0f, size, size, paint)
Expand Down Expand Up @@ -50,8 +50,5 @@ fun Shape.draw(particle: Particle, canvas: Canvas, paint: Paint, size: Float) {
drawable.setBounds(0, top, size.toInt(), top + height)
drawable.draw(canvas)
}
is Text -> {
canvas.drawText(text, particle.x, particle.y, particle.paint)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ open class KonfettiView : View {
canvas.rotate(rotation, centerX, width / 2)
canvas.scale(scaleX, 1f)

shape.draw(this, canvas, paint, width)
shape.draw(canvas, paint, width)
canvas.restoreToCount(saveCount)
}

Expand Down

0 comments on commit c01dd64

Please sign in to comment.