flashcards

Stupid LaTeX flashcard viewer
git clone git://lumidify.org/flashcards.git
Log | Files | Refs | README

commit 1148dd020e6d7449567ed96b7e417c9bb8b3e36a
parent d5084133d69805bd727003de6d951ac2de1d8d8d
Author: lumidify <nobody@lumidify.org>
Date:   Wed,  8 Apr 2020 17:07:26 +0200

Small image scaling improvement

Diffstat:
MREADME | 9+++++----
Acache/bob_back.png | 0
Acache/bob_front1.png | 0
Acache/bob_front2.png | 0
Aconfig.json | 1+
Aflashcards_orig/bob | 3+++
Alatex/bob | 3+++
Mrender_card.sh | 2+-
Mviewer2.pl | 5++++-
9 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/README b/README @@ -5,10 +5,11 @@ works for me, that's why I use it. `viewer.pl` is the old version using Tk, `viewer2.pl` is the new version using Gtk2. -The flashcard files are dumped in `latex/`. You then run `./gen_cache.pl` -to generate the cache. This uses `pdflatex`, `pdfcrop`, and `pdftoppm` to -convert the LaTeX files to PNG, pasting `fm.tex` at the beginning of the -flashcard before rendering it. +The flashcard files are stored in `latex/`. You need to have a master +copy of them somewhere else, then run `./gen_cache.pl path/to/flashcards/` +to copy the new or changed flashcard files to `latex/` and render them. +This uses `pdflatex`, `pdfcrop`, and `pdftoppm` to convert the LaTeX files +to PNG, pasting `fm.tex` at the beginning of the flashcard before rendering it. The top line of each flashcard file has the theorem number or something similar, the second line has the front side of the card, and the rest diff --git a/cache/bob_back.png b/cache/bob_back.png Binary files differ. diff --git a/cache/bob_front1.png b/cache/bob_front1.png Binary files differ. diff --git a/cache/bob_front2.png b/cache/bob_front2.png Binary files differ. diff --git a/config.json b/config.json @@ -0,0 +1 @@ +{"cards":{"bob":3}} diff --git a/flashcards_orig/bob b/flashcards_orig/bob @@ -0,0 +1,3 @@ +Satz 1|bla +Tolle Karte +$\frac{x}{y}$ diff --git a/latex/bob b/latex/bob @@ -0,0 +1,3 @@ +Satz 1|bla +Tolle Karte +$\frac{x}{y}$ diff --git a/render_card.sh b/render_card.sh @@ -2,7 +2,7 @@ filename="`basename $1`" -meta1=`head -n 1 "$1" | tr -d '\n'` +meta1=`head -n 1 "$1" | tr -d '\n' | sed 's/|.*$//'` meta2=`sed '2!d' "$1" | tr -d '\n'` body=`tail -n +3 "$1"` diff --git a/viewer2.pl b/viewer2.pl @@ -113,7 +113,10 @@ sub gui { my $label = Gtk2::Label->new(""); $button = Gtk2::Button->new_with_mnemonic("_Reveal back"); $button->signal_connect(clicked => sub { - my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_size("cache/${card_id}_back.png", 1280, 500); + my ($fmt, $w, $h) = Gtk2::Gdk::Pixbuf->get_file_info("cache/${card_id}_back.png"); + my $w_final = $w < 1280 ? $w : 1280; + my $h_final = $h < 600 ? $h : 1280; + my $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_size("cache/${card_id}_back.png", $w_final, $h_final); my $image = Gtk2::Image->new_from_pixbuf($pixbuf); $img_vbox->pack_start($image, FALSE, FALSE, 0); $image->show;