-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# gȧrt : Dots. Wave. Flash. | ||
|
||
![](circledots.png) | ||
![](circledots2.png) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
arts/circledots/src/main/kotlin/dev/oblac/gart/circledots/v2/Circle2Anim.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package dev.oblac.gart.circledots.v2 | ||
|
||
import dev.oblac.gart.circledots.Context | ||
import dev.oblac.gart.gfx.Colors | ||
import dev.oblac.gart.gfx.Palettes | ||
import dev.oblac.gart.gfx.fillOf | ||
import dev.oblac.gart.gfx.fillOfBlack | ||
|
||
data class Circle2Anim(private val ctx: Context, val x: Float, val y: Float, val r: Float, var deg: Float, var speed: Float = 3f, val from: Int) { | ||
var tick = 0 | ||
private val fill = fillOf(palette.getSafe(from)) | ||
fun draw() { | ||
tick++ | ||
//ctx.g.canvas.drawCircle(x, y, r, blackStroke) | ||
|
||
val x2 = x + ctx.mcos[deg] * r | ||
val y2 = y - ctx.msin[deg] * r | ||
|
||
ctx.g.canvas.drawCircle(x2, y2, 20f, fill) | ||
|
||
if (tick > from) { | ||
deg += speed | ||
} | ||
} | ||
|
||
companion object { | ||
private val blackFill = fillOfBlack() | ||
private val palette = Palettes.gradient(Colors.black, Colors.white, 110) + | ||
Palettes.gradient(Colors.white, Colors.black, 110) | ||
|
||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
arts/circledots/src/main/kotlin/dev/oblac/gart/circledots/v2/CircleSingle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package dev.oblac.gart.circledots.v2 | ||
|
||
import dev.oblac.gart.Gart | ||
import dev.oblac.gart.Media | ||
import dev.oblac.gart.circledots.Context | ||
import dev.oblac.gart.gfx.Colors | ||
import kotlin.math.PI | ||
import kotlin.math.cos | ||
import kotlin.math.sin | ||
|
||
private val gart = Gart.of( | ||
"CircleDots2", | ||
640, 640, | ||
50 | ||
) | ||
private val ctx = Context(gart.g) | ||
|
||
fun main() { | ||
with(gart) { | ||
|
||
println(name) | ||
|
||
var tick = 0 | ||
|
||
val ccs = createAnimation(320, 320, 220) | ||
|
||
w.show() | ||
a.draw { | ||
tick++ | ||
if (tick > 440) { | ||
a.record() | ||
} | ||
g.fill(Colors.black) | ||
for (cc in ccs) { | ||
cc.draw() | ||
} | ||
if (tick == 2000) { | ||
a.stop() | ||
return@draw | ||
} | ||
} | ||
Media.saveImage(this, "circledots2.png") | ||
Media.saveVideo(this, "circledots2.mp4") | ||
} | ||
|
||
} | ||
|
||
private fun createAnimation(x: Int, y: Int, count: Int): Array<Circle2Anim> { | ||
val delta = 2 * PI / count | ||
var offset = 0.0 | ||
return Array(count) { | ||
val angle = it * delta + offset | ||
offset += delta | ||
Circle2Anim( | ||
ctx = ctx, | ||
x = (x + 200 * cos(angle)).toFloat(), | ||
y = (y + 200 * sin(angle)).toFloat(), | ||
r = 80f, | ||
deg = it * PI.toFloat() * 2, | ||
speed = 4f, | ||
it * 2 | ||
) | ||
} | ||
} |