Created
September 20, 2022 02:39
-
-
Save CIOSAI/53cbcc8df530c32b75f8c71ad4a36d32 to your computer and use it in GitHub Desktop.
sussy video is now better organized
This file contains hidden or 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
import kotlinx.coroutines.delay | |
import org.openrndr.animatable.Animatable | |
import org.openrndr.animatable.AnimationEvent | |
import org.openrndr.animatable.PropertyAnimationKey | |
import org.openrndr.animatable.easing.Easing | |
import org.openrndr.application | |
import org.openrndr.color.ColorRGBa | |
import org.openrndr.draw.* | |
import org.openrndr.extra.color.presets.DARK_BLUE | |
import org.openrndr.ffmpeg.ScreenRecorder | |
import org.openrndr.math.mix | |
import org.openrndr.shape.Circle | |
import org.openrndr.shape.Rectangle | |
import org.openrndr.shape.TextNode | |
import kotlin.math.* | |
fun main() = application { | |
var w = 0;var h = 0 | |
configure { | |
width = 1280; w = width | |
height = 720; h = height | |
} | |
abstract class Chainable : Animatable(){ | |
var active = false | |
var follow:(()->Unit)? = null | |
fun chain(f:(()->Unit)?){ | |
follow = f | |
} | |
var onhold:Long = 0 | |
fun hold_for(delay:Long){ | |
onhold = delay | |
} | |
fun start(){ | |
delay(onhold) | |
assign() | |
active = true | |
} | |
fun <T> end(a:PropertyAnimationKey<T>){ | |
active = false | |
a.completed.listen{ | |
if(follow!=null) follow?.invoke() | |
} | |
} | |
abstract fun assign() | |
} | |
program { | |
val font = loadFont("data/fonts/default.otf", 120.0) | |
class AniText : Chainable(){ | |
var y = 1.0 | |
override fun assign(){ | |
end( | |
::y.animate(0.0, 150, Easing.CubicOut) | |
) | |
} | |
} | |
val aniArc = object : Chainable(){ | |
var a1 = -0.25 | |
var a2 = -0.25 | |
override fun assign(){ | |
::a1.animate(0.75, 1000, Easing.QuartOut) | |
end( | |
::a2.animate(0.75, 1000, Easing.None) | |
) | |
} | |
} | |
val upward = object : Chainable(){ | |
var y = 1.0 | |
var rad = 0.0 | |
override fun assign(){ | |
::y.animate(0.0, 1000, Easing.CubicInOut) | |
::y.complete() | |
end( | |
::rad.animate(1.0, 1000, Easing.SineInOut) | |
) | |
} | |
} | |
val underline = object : Chainable(){ | |
var x = -1.0 | |
override fun assign() { | |
end( | |
::x.animate(1.0, 500, Easing.CubicInOut) | |
) | |
} | |
} | |
val aniChar = List("AMOGUS".length){ | |
AniText() | |
} | |
val shrinker = object : Chainable(){ | |
var n = 1.0 | |
override fun assign() { | |
end( | |
::n.animate(0.0, 1000, Easing.QuadInOut) | |
) | |
} | |
} | |
class Composition(){ | |
fun update(){ | |
val toAnimate = mutableListOf(aniArc, upward, underline, shrinker) | |
for(i in aniChar) toAnimate.add(i) | |
for(i in toAnimate) i.updateAnimation() | |
} | |
fun start(){ | |
aniArc.chain(upward::start) | |
upward.chain(underline::start) | |
underline.chain(aniChar[0]::start) | |
for(i in 1 until aniChar.size){ | |
aniChar[i-1].chain(aniChar[i]::start) | |
} | |
shrinker.hold_for(1000) | |
aniChar[aniChar.lastIndex].chain(shrinker::start) | |
aniArc.start() | |
} | |
} | |
val sr = ScreenRecorder() | |
fun pause_vid(){sr.outputToVideo = false} | |
val myComposition = Composition() | |
shrinker.chain(::pause_vid) | |
myComposition.start() | |
extend(sr) | |
extend { | |
drawer.clear(ColorRGBa.DARK_BLUE) | |
drawer.translate(w/2.0, h/2.0) | |
drawer.lineCap = LineCap.ROUND | |
myComposition.update() | |
if(shrinker.active){ | |
drawer.scale(shrinker.n) | |
} | |
if(aniArc.active){ | |
drawer.stroke = ColorRGBa.PINK | |
drawer.fill = ColorRGBa.PINK | |
drawer.strokeWeight = h/8.0 | |
val arc = Circle(0.0, 0.0, h/3.0).contour.sub(aniArc.a1, aniArc.a2) | |
drawer.contour(arc) | |
} | |
if (upward.active){ | |
drawer.stroke = ColorRGBa.PINK | |
drawer.fill = ColorRGBa.PINK | |
drawer.strokeWeight = h/8.0 | |
drawer.circle( | |
0.0, upward.y*h/3.0, | |
mix(h/16.0, h/3.0, upward.rad) | |
) | |
} | |
if(underline.active){ | |
drawer.strokeWeight = h/64.0 | |
drawer.stroke = ColorRGBa.WHITE | |
drawer.lineSegment(-h/4.0, h/16.0, underline.x*h/4.0, h/16.0) | |
} | |
drawer.isolated { | |
drawer.drawStyle.clip = Rectangle(0.0, 0.0, w.toDouble(), h/2.0+h/16.0) | |
if(!underline.hasAnimations()){ | |
val amogus = "AMOGUS" | |
drawer.fontMap = font | |
val span = Writer(drawer).textWidth("AMOGUS") | |
drawer.stroke = null | |
drawer.fill = ColorRGBa.WHITE | |
for(i in amogus.indices){ | |
drawer.text( | |
" ".repeat(i)+amogus[i]+" ".repeat(amogus.length-1-i), | |
-span/2.0, | |
h/32.0+mix(0.0, h/6.0, aniChar[i].y) | |
) | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment