GithubHelp home page GithubHelp logo

Comments (6)

pssguy avatar pssguy commented on June 11, 2024

Actually, the new magick package may be better approach

from rchess.

jbkunst avatar jbkunst commented on June 11, 2024

Hi @pssguy

Tell me if this looks good to you.

library("magick")
get_gif <- function(pgn, scale = "400x400", fps = 1) {

  fens <- get_fens(pgn)
  # fens <- head(fens)

  fens %>% 
    map(ggchessboard) %>% 
    map_chr(function(p){ # p <- sample(plots, size = 1)[[1]]
    fl <- tempfile(fileext = ".jpg")
    ggplot2::ggsave(p, file = fl)
    fl
  }) %>% 
    image_read() %>% 
    image_scale(geometry = scale) %>% 
    image_animate(fps = fps)


}

gif <- get_gif(pgn)

image_write(gif, "anim.gif")

anim

I need to change the font to have a nicer look but is a start.

I you're ok I will proceed to add this utilities into the package! :B

from rchess.

pssguy avatar pssguy commented on June 11, 2024

This is amazing work
Any reason you chose jpg over png?

Currently it is set to fps=1. I found 0.2 gave me time to take in moves better (same file size)

Ideally, somehow for users there would be controls to pause, set speed etc. but I have no idea if this is even feasible

from rchess.

jbkunst avatar jbkunst commented on June 11, 2024

No reason, just copy paste code from somewhere.

Not sure yet too how to implement parameters for have control in the image_animate. I'll take some time to see if this is feasible in a simple way.

from rchess.

sjorsvanheuveln avatar sjorsvanheuveln commented on June 11, 2024

What about plotting this animation in R-Studio? So not saving as a file but real time plot a game. I cannot do it, as the plot won't refresh in a for loop. How to solve this?

from rchess.

jbkunst avatar jbkunst commented on June 11, 2024

I guess it's possible wrap the image in a html div using htmltools package and then use the browseable function to send it to the viewer.

Let me if you can try this idea.

from rchess.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.