<commit_before>package main

import (
    "github.com/ajhager/rog"
    "github.com/ajhager/rog/wde"
    "math/rand"
)

const (
    TOPLEFT = 0
    TOPRIGHT = 1
    BOTTOMLEFT = 2
    BOTTOMRIGHT = 3
    SAMPLEX = 0
    SAMPLEY = 1
    SAMPLEWIDTH = 40
    SAMPLEHEIGHT = 20
)

var (
    sampleConsole *rog.Console = rog.NewConsole(SAMPLEWIDTH, SAMPLEHEIGHT)
    colors []rog.RGB = []rog.RGB{
        rog.RGB{50, 40, 150},
        rog.RGB{240, 85, 5},
        rog.RGB{50, 35, 240},
        rog.RGB{10, 200, 130}}
    dirR []int = []int{1, -1, 1, 1}
    dirG []int = []int{1, -1, -1, 1}
    dirB []int = []int{1, 1, 1, -1}
    black rog.RGB = rog.RGB{0, 0, 0}
)

func render() {
    for c := 0; c < 4; c++ {
        switch rand.Int31n(2) {
        case 0:
            colors[c].R += uint8(5 * dirR[c])
            if colors[c].R == 255 {
                dirR[c] = -1
            } else if colors[c].R == 0 {
                dirR[c] = 1
            }
        case 1:
            colors[c].G += uint8(5 * dirG[c])
            if colors[c].G == 255 {
                dirG[c] = -1
            } else if colors[c].G == 0 {
                dirG[c] = 1
            }
        case 2:
            colors[c].B += uint8(5 * dirB[c])
            if colors[c].B == 255 {
                dirB[c] = -1
            } else if colors[c].B == 0 {
                dirB[c] = 1
            }
        }
    }

    for x := 0; x < SAMPLEWIDTH; x++ {
        xcoef := float64(x) / float64(SAMPLEWIDTH - 1)
        top := colors[TOPLEFT].Alpha(colors[TOPRIGHT], xcoef)
        bot := colors[BOTTOMLEFT].Alpha(colors[BOTTOMRIGHT], xcoef)
        for y := 0; y < SAMPLEHEIGHT; y++ {
            ycoef := float64(y) / float64(SAMPLEHEIGHT - 1)
            cur := top.Alpha(bot, ycoef)
            sampleConsole.Set(x, y, nil, cur, "")
        }
    }

    for x := 0; x < SAMPLEWIDTH; x++ {
        for y := 0; y < SAMPLEHEIGHT; y++ {
            _, col, _ := sampleConsole.Get(x, y)
            col = col.Alpha(black, 0.5)
            sampleConsole.Set(x, y, col, nil, string(rand.Int31n(26)+97))
        }
    }
}

func main() {
    rog.Open(SAMPLEWIDTH, SAMPLEHEIGHT+2, "tcod true color", wde.Backend())
    for rog.IsOpen() {
        render()
        rog.Blit(sampleConsole, SAMPLEX, SAMPLEY)
        rog.Set(0, SAMPLEHEIGHT+1, nil, nil, "%v", rog.Fps())
        if rog.Key() == rog.Escape {
            rog.Close()<commit_msg>Clean up and fix tcod true_color sample<commit_after>package main

import (
    "github.com/ajhager/rog"
    "github.com/ajhager/rog/wde"
    "math/rand"
)

const (
    topLeft = 0
    topRight = 1
    botLeft = 2
    botRight = 3
    width = 40
    height = 20
)

var (
    sampleConsole *rog.Console = rog.NewConsole(width, height)
    colors []rog.RGB = []rog.RGB{
        rog.RGB{50, 40, 150},
        rog.RGB{240, 85, 5},
        rog.RGB{50, 35, 240},
        rog.RGB{10, 200, 130}}
    dirR []int = []int{1, -1, 1, 1}
    dirG []int = []int{1, -1, -1, 1}
    dirB []int = []int{1, 1, 1, -1}
    black rog.RGB = rog.RGB{0, 0, 0}
)

func render() {
    for c := 0; c < 4; c++ {
        switch rand.Int31n(3) {
        case 0:
            colors[c].R += uint8(5 * dirR[c])
            if colors[c].R == 255 {
                dirR[c] = -1
            } else if colors[c].R == 0 {
                dirR[c] = 1
            }
        case 1:
            colors[c].G += uint8(5 * dirG[c])
            if colors[c].G == 255 {
                dirG[c] = -1
            } else if colors[c].G == 0 {
                dirG[c] = 1
            }
        case 2:
            colors[c].B += uint8(5 * dirB[c])
            if colors[c].B == 255 {
                dirB[c] = -1
            } else if colors[c].B == 0 {
                dirB[c] = 1
            }
        }
    }

    for x := 0; x < width; x++ {
        xcoef := float64(x) / float64(width - 1)
        top := colors[topLeft].Alpha(colors[topRight], xcoef)
        bot := colors[botLeft].Alpha(colors[botRight], xcoef)
        for y := 0; y < height; y++ {
            ycoef := float64(y) / float64(height - 1)
            cur := top.Alpha(bot, ycoef)
            sampleConsole.Set(x, y, nil, cur, "")
        }
    }

    for x := 0; x < width; x++ {
        for y := 0; y < height; y++ {
            _, col, _ := sampleConsole.Get(x, y)
            col = col.Alpha(black, 0.5)
            sampleConsole.Set(x, y, col, nil, string(rand.Int31n(26)+97))
        }
    }
}

func main() {
    rog.Open(width, height+2, "tcod true color", wde.Backend())
    for rog.IsOpen() {
        render()
        rog.Blit(sampleConsole, 0, 1)
        rog.Set(0, height+1, nil, nil, "%v", rog.Fps())
        if rog.Key() == rog.Escape {
            rog.Close()
{'fraction_non_alphanumeric': 0.1658141517476556, 'fraction_numerical': 0.04688832054560955, 'mean_word_length': 1.4976051091005853, 'pattern_counts': {'":': 0, '<': 13, '<?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': '4129692', 'n_tokens_mistral': 1944, 'n_tokens_neox': 1746, 'n_words': 409}