|
|
|
|
@ -22,6 +22,7 @@ import java.util.* |
|
|
|
|
class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
|
|
|
|
|
// Steps & Frames |
|
|
|
|
private var drawer = TableDrawer() |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* The number of frames per second |
|
|
|
|
@ -233,10 +234,17 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
var playerStrokeWidth = 8f |
|
|
|
|
var cardStrokeWidth = 8f |
|
|
|
|
|
|
|
|
|
fun configure(width: Float, height: Float, context: Context) { |
|
|
|
|
|
|
|
|
|
this.setDimension(width, height) |
|
|
|
|
this.drawer.configurePaints(context, this) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* Calculates the position of all elements to draw |
|
|
|
|
*/ |
|
|
|
|
fun setDimension(width: Float, height: Float) { |
|
|
|
|
private fun setDimension(width: Float, height: Float) { |
|
|
|
|
|
|
|
|
|
Timber.d("Setting dimensions...") |
|
|
|
|
this.width = width |
|
|
|
|
this.height = height |
|
|
|
|
@ -352,6 +360,9 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
fun drawTable(canvas: Canvas, context: Context) { |
|
|
|
|
this.drawer.drawTable(canvas, context) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun stackRectForPlayer(positionIndex: Int): RectF { |
|
|
|
|
return this.playerStackRects[positionIndex] |
|
|
|
|
@ -486,7 +497,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
* Generates images and image descriptor to build the video using ffmpeg |
|
|
|
|
* Command line: https://trac.ffmpeg.org/wiki/Slideshow |
|
|
|
|
*/ |
|
|
|
|
suspend fun generateVideoContent(tableDrawer: TableDrawer, context: Context): File { |
|
|
|
|
suspend fun generateVideoContent(context: Context): File { |
|
|
|
|
|
|
|
|
|
var ffmpegImageDescriptor = "" |
|
|
|
|
var count = 0 |
|
|
|
|
@ -507,7 +518,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
val canvas = Canvas(bitmap) |
|
|
|
|
val vo = this.visualOccurences / 90.0 // this is needed before the call to drawTable which pass to the next frame |
|
|
|
|
|
|
|
|
|
tableDrawer.drawTable(canvas, context) |
|
|
|
|
this.drawer.drawTable(canvas, context) |
|
|
|
|
|
|
|
|
|
imagePath = File(directory, "img_$count.png").path |
|
|
|
|
|
|
|
|
|
@ -545,7 +556,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
* As soon as a bitmap has been created, the [frameHandler] is called with the created |
|
|
|
|
* bitmap, and a appropriate occurrences of the bitmap to be added is passed along |
|
|
|
|
*/ |
|
|
|
|
fun frames(tableDrawer: TableDrawer, context: Context, frameHandler: (Bitmap, Int) -> Unit) { |
|
|
|
|
fun frames(context: Context, frameHandler: (Bitmap, Int) -> Unit) { |
|
|
|
|
|
|
|
|
|
Timber.d("Step count = ${this.steps.size}") |
|
|
|
|
|
|
|
|
|
@ -561,7 +572,7 @@ class ReplayerAnimator(var handHistory: HandHistory, var export: Boolean) { |
|
|
|
|
val canvas = Canvas(bitmap) |
|
|
|
|
val vo = this.visualOccurences // this is needed before the call to drawTable which pass to the next frame |
|
|
|
|
|
|
|
|
|
tableDrawer.drawTable(canvas, context) |
|
|
|
|
this.drawer.drawTable(canvas, context) |
|
|
|
|
|
|
|
|
|
frameHandler(bitmap, vo) |
|
|
|
|
|
|
|
|
|
|