Skip to content

Commit

Permalink
feat: Add rectangle builder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayfri committed Aug 31, 2022
1 parent c74f7fc commit 639a370
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pixi/src/main/kotlin/pixi/utils/builders.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import pixi.typings.graphics.Graphics
import pixi.typings.math.Matrix
import pixi.typings.math.ObservablePoint
import pixi.typings.math.Point
import pixi.typings.math.Rectangle
import pixi.typings.sprite.Sprite
import pixi.typings.text.PartialTextStyle
import pixi.typings.text.Text
Expand All @@ -36,6 +37,8 @@ fun point(block: Point.() -> Unit) = Point().apply(block)
fun <T> observablePoint(x: Number, y: Number, scope: T = jso(), onChange: ((T) -> Any?) = {}) = ObservablePoint(onChange, scope, x.toDouble(), y.toDouble())
fun observablePoint(x: Number, y: Number, onChange: (() -> Any?) = {}) = ObservablePoint(onChange.unsafeCast<(Void) -> Any?>(), null, x.toDouble(), y.toDouble())

fun rectangle(block: Rectangle.() -> Unit) = Rectangle().apply(block)

fun sprite(texture: Texture<Resource>, block: Sprite.() -> Unit) = Sprite(texture).apply(block)
fun sprite(texture: BaseTexture<Resource, IAutoDetectOptions>, block: Sprite.() -> Unit) = Sprite.from(texture).apply(block)
fun sprite(texture: String, block: Sprite.() -> Unit) = Sprite.from(texture).apply(block)
Expand Down

0 comments on commit 639a370

Please sign in to comment.