Skip to content

Instantly share code, notes, and snippets.

@CIOSAI
Created September 19, 2022 12:24
Show Gist options
  • Save CIOSAI/736cb151ff41caf80afec0f080b6234b to your computer and use it in GitHub Desktop.
Save CIOSAI/736cb151ff41caf80afec0f080b6234b to your computer and use it in GitHub Desktop.
sussy video rendered with cat lin
import kotlinx.coroutines.delay
import org.openrndr.animatable.Animatable
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 {
configure {
width = 1280
height = 720
}
program {
val font = loadFont("data/fonts/default.otf", 120.0)
val aniArc = object : Animatable(){
var a1 = -0.25
var a2 = -0.25
var waited = 0
var total = 1000
}
aniArc.apply{
delay(waited.toLong())
::a1.animate(0.75, 1000, Easing.QuartOut)
::a2.animate(0.75, 1000, Easing.None)
}
val upward = object : Animatable(){
var y = 1.0
var rad = 0.0
var waited = aniArc.waited + aniArc.total
var total = 2000
}
upward.apply {
delay(waited.toLong())
::y.animate(0.0, 1000, Easing.CubicInOut)
::y.complete()
::rad.animate(1.0, 1000, Easing.SineInOut)
}
val underline = object : Animatable(){
var x = -1.0
var waited = upward.waited + upward.total
var total = 500
}
underline.apply {
delay(waited.toLong())
::x.animate(1.0, 500, Easing.CubicInOut)
}
class aniText : Animatable () {
var y = 1.0
var waited = underline.waited + underline.total
var total = 100
}
val aniChar = List("AMOGUS".length){
aniText()
}
for(i in aniChar.indices){
aniChar[i].waited += i*aniChar[i].total
aniChar[i].apply {
delay(waited.toLong())
::y.animate(0.0, 150, Easing.CubicOut)
}
}
val shrinker = object : Animatable(){
var n = 1.0
var waited = aniChar[aniChar.lastIndex].waited + aniChar[aniChar.lastIndex].total + 1000
var total = 1000
}
shrinker.apply {
delay(waited.toLong())
::n.animate(0.0, 1000, Easing.QuadInOut)
}
val sr = ScreenRecorder()
extend(sr)
extend {
val w = width;val h = height
drawer.clear(ColorRGBa.DARK_BLUE)
drawer.translate(w/2.0, h/2.0)
drawer.stroke = ColorRGBa.PINK
drawer.lineCap = LineCap.ROUND
drawer.fill = ColorRGBa.PINK
shrinker.updateAnimation()
if(!aniChar[aniChar.lastIndex].hasAnimations()){
drawer.scale(shrinker.n)
}
aniArc.updateAnimation()
drawer.strokeWeight = h/8.0
val arc = Circle(0.0, 0.0, h/3.0).contour.sub(aniArc.a1, aniArc.a2)
drawer.contour(arc)
upward.updateAnimation()
if (!aniArc.hasAnimations()){
drawer.circle(0.0, upward.y*h/3.0, mix(h/16.0, h/3.0, upward.rad) )
}
underline.updateAnimation()
if(!upward.hasAnimations()){
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)
}
for(i in aniChar) i.updateAnimation()
val amogus = "AMOGUS"
drawer.fontMap = font
val span = Writer(drawer).textWidth("AMOGUS")
drawer.drawStyle.clip = Rectangle(0.0, 0.0, w.toDouble(), h/2.0+h/16.0)
if(!underline.hasAnimations()){
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)
)
}
}
drawer.drawStyle.clip = null
if(!shrinker.hasAnimations()){
sr.outputToVideo = false
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment