ai-twerk-generator
A fun and experimental Elixir library for generating AI-assisted twerk animations. This package provides utilities for creating and manipulating animation data suitable for driving visual representations.
Installation
Add ai_twerk_generator to your list of dependencies in mix.exs:
elixir
def deps do
[
{:ai_twerk_generator, "~> 0.1.0"}] end
Then run: bash mix deps.get mix compile
Usage
This library provides several functions to assist in creating and manipulating twerk animation data. Here are a few examples:
1. Generating a Basic Twerk Sequence:
This example demonstrates generating a simple sequence of animation frames. elixir alias AiTwerkGenerator.Sequence
sequence = Sequence.new() |> Sequence.add_frame(%{waist: 0.2, hips: 0.5}) |> Sequence.add_frame(%{waist: 0.8, hips: 0.1}) |> Sequence.add_frame(%{waist: 0.5, hips: 0.9}) |> Sequence.to_list()
IO.inspect(sequence)
Expected Output (example):
[%{hips: 0.5, waist: 0.2}, %{hips: 0.1, waist: 0.8}, %{hips: 0.9, waist: 0.5}]
2. Applying a Smoothing Function:
You can smooth animation data to create more fluid movements. elixir alias AiTwerkGenerator.Effect
initial_data = [%{waist: 0.1, hips: 0.9}, %{waist: 0.9, hips: 0.1}, %{waist: 0.3, hips: 0.7}]
smoothed_data = initial_data |> Effect.smooth(0.5)
IO.inspect(smoothed_data)
Output will be a smoothed version of the initial data.
3. Scaling Animation Intensity:
Adjust the intensity of the twerk by scaling the animation data. elixir alias AiTwerkGenerator.Transform
animation_data = [%{waist: 0.3, hips: 0.7}, %{waist: 0.6, hips: 0.4}]
scaled_data = animation_data |> Transform.scale(1.5) # Increase intensity by 50%
IO.inspect(scaled_data)
Output will be the animation data scaled by 1.5.
4. Using Pattern Matching to Extract Keyframes:
This example demonstrates extracting keyframes based on certain criteria. elixir alias AiTwerkGenerator.Sequence
keyframes = [%{waist: 0.1, hips: 0.9}, %{waist: 0.5, hips: 0.5}, %{waist: 0.9, hips: 0.1}]
extract_high_hip_frames = fn frame -> case frame do
%{hips: hip} when hip > 0.7 -> {:ok, frame}
_ -> :errorend end
high_hip_frames = keyframes |> Enum.filter(fn frame -> extract_high_hip_frames.(frame) == {:ok, frame} end)
IO.inspect(high_hip_frames)
Expected Output: [%{hips: 0.9, waist: 0.1}]
5. Composing Transformations with Pipes:
Combine multiple transformations using the pipe operator for complex effects. elixir alias AiTwerkGenerator.Transform alias AiTwerkGenerator.Effect
animation_data = [%{waist: 0.2, hips: 0.8}, %{waist: 0.7, hips: 0.3}]
transformed_data = animation_data |> Transform.scale(1.2) |> Effect.smooth(0.3)
IO.inspect(transformed_data)
Output will be scaled and smoothed animation data.
Features
- Sequence Generation: Tools for creating animation sequences.
- Data Transformation: Functions to scale, smooth, and otherwise manipulate animation data.
- Keyframe Extraction: Utilities for identifying and extracting important frames.
- Composable Transformations: Easily combine transformations using Elixir's pipe operator.
License
MIT
This package is part of the ai-twerk-generator ecosystem. For advanced features and enterprise-grade tools, visit: https://supermaker.ai/blog/how-to-make-ai-twerk-video-with-supermaker-ai-free-online/