<commit_before>#!/usr/bin/env python

import sys

import pyglet
from pyglet.gl import *

class OscillatingImage(object):
    def __init__(self, filename):
        self.filename = filename
        self.window = pyglet.window.Window(visible=False, resizable=True)
        self.window.event(self.on_draw)
        pyglet.clock.schedule_interval(self.update, 5)
        self.image_drawn = True
        self.setup_target()
    def setup_target(self):
        img = pyglet.image.load(self.filename).get_texture(rectangle=True)
        img.anchor_x = img.width // 2
        img.anchor_y = img.height // 2
        checks = pyglet.image.create(32, 32, pyglet.image.CheckerImagePattern())
        self.background = pyglet.image.TileableTexture.create_for_image(checks)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)    
        self.window.width = img.width
        self.window.height = img.height
        self.window.set_visible()
        self.img = img
    def start(self):
        pyglet.app.run()
    def on_draw(self):
        self.background.blit_tiled(0, 0, 0, self.window.width, self.window.height)
        if self.image_drawn:
            self.draw_image()
            
    def draw_image(self):
        self.img.blit(self.window.width // 2, self.window.height // 2, 0)

    def update(self, dt):
        if self.image_drawn:
            self.image_drawn = False
            self.img.delete()
            self.setup_target()
        else:
            self.image_drawn = True
            self.setup_target()


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print __doc__
        sys.exit(1)
    image = OscillatingImage(sys.argv[1])
    target.start()
<commit_msg>Minor tweaks<commit_after>#!/usr/bin/env python

import sys

import pyglet
from pyglet.gl import *

class OscillatingImage(object):
    def __init__(self, filename):
        self.filename = filename
        self.window = pyglet.window.Window(visible=False, resizable=True)
        self.window.event(self.on_draw)
        pyglet.clock.schedule_interval(self.update, 5)
        self.image_drawn = True
        self.setup_target()
    def setup_target(self):
        img = pyglet.image.load(self.filename).get_texture(rectangle=True)
        img.anchor_x = img.width // 2
        img.anchor_y = img.height // 2
        checks = pyglet.image.create(32, 32, pyglet.image.CheckerImagePattern())
        self.background = pyglet.image.TileableTexture.create_for_image(checks)
        glEnable(GL_BLEND)
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)    
        self.window.width = img.width
        self.window.height = img.height
        self.window.set_visible()
        self.img = img
    def start(self):
        pyglet.app.run()
    def on_draw(self):
        self.background.blit_tiled(0, 0, 0, self.window.width, self.window.height)
        if self.image_drawn:
            self.draw_image()
            
    def draw_image(self):
        self.img.blit(self.window.width // 2, self.window.height // 2, 0)

    def update(self, dt):
        if self.image_drawn:
            self.image_drawn = False
            self.setup_target()
        else:
            self.image_drawn = True
            self.setup_target()


if __name__ == '__main__':
    if len(sys.argv) != 2:
        print __doc__
        sys.exit(1)
    oimage = OscillatingImage(sys.argv[1])
    oimage.start()

{'fraction_non_alphanumeric': 0.11183048852266039, 'fraction_numerical': 0.009417304296645085, 'mean_word_length': 2.2840579710144926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5860171', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1109, 'n_words': 192}