<commit_before>import { fourFourty } from './math_helper'
import * as io from './image-operation'
import * as m from 'mithril'
import * as mh from './mithril-helper'
import * as _ from 'lodash'

const verboseLogging = false

const word1 = "ShapeLogic";
const word2 = "TypeScript" // _.trim("  TypeScript   ");

const headerPart = m('header', [
    m('h1', [`ShapeLogic TypeScript`]),
    m('p', ["Computer vision in TypeScript and WebGL"])
])

const canvas = document.getElementById('canvas') as HTMLCanvasElement;

const colorSequenceArray = [
    'rgba',
    'rbga',
    'gbra',
    'bgra',
    'rrra',
    'ggga',
    'bbba'
]

let colorIndex = 0
let imageSources = [
    "Lenna.png",
    "embryos.jpg",
    "baby-ball.jpg",
    "shapelogicsmalltransparent.png"]

function showImage(): void {
    colorIndex = (colorIndex + 1) % colorSequenceArray.length;
    // const colorSequence = colorSequenceArray[colorIndex];
    const colorSequence = getValueFromSelect("#familyname") || colorSequenceArray[0]
    const imageSource = "img/" + (getValueFromSelect("#imageSources") || imageSources[0])
    // io.drawImageInContext(canvas, imageSource, colorSequence, 0.5, 0.8, 1)
    const fragmentSource = io.fragmentShaderColorSwapper(colorSequence)
    io.doImageOperationNoArg(canvas, imageSource, fragmentSource)
}
/**
 * 
 * @param selector 
 */
function getValueFromSelect(selector: string): string | null {
    // const domFamily = document.getElementById('familyname')
    const domFamily = document.querySelector(selector) as HTMLSelectElement
    if (!domFamily) {
        console.warn('domFamily missing')
        return null
    }
    else {
        if (verboseLogging)
            console.log(domFamily)
        return domFamily.value
    }
}

function printFamilyname(): void {<commit_msg>Added inverse operation<commit_after>import { fourFourty } from './math_helper'
import * as io from './image-operation'
import * as m from 'mithril'
import * as mh from './mithril-helper'
import * as _ from 'lodash'

const verboseLogging = false

const headerPart = m('header', [
    m('h1', [`ShapeLogic TypeScript`]),
    m('p', ["Computer vision in TypeScript and WebGL"])
])

const canvas = document.getElementById('canvas') as HTMLCanvasElement;

const colorSequenceArray = [
    'inverse',
    'rgba',
    'rbga',
    'gbra',
    'bgra',
    'rrra',
    'ggga',
    'bbba'
]

let colorIndex = 0
let imageSources = [
    "Lenna.png",
    "embryos.jpg",
    "baby-ball.jpg",
    "shapelogicsmalltransparent.png"]

export const fragmentShaderColorInverse: string = `
    precision mediump float;
    
    // our texture
    uniform sampler2D u_image;
    
    // the texCoords passed in from the vertex shader.
    varying vec2 v_texCoord;
    
    void main() {
        gl_FragColor = vec4(1, 1, 1, 2) - texture2D(u_image, v_texCoord).rgba;
    }
    `

function showImage(): void {
    const colorSequence = getValueFromSelect("#familyname") || colorSequenceArray[0]
    const imageSource = "img/" + (getValueFromSelect("#imageSources") || imageSources[0])
    const fragmentSource = (colorSequence == 'inverse') ? fragmentShaderColorInverse : io.fragmentShaderColorSwapper(colorSequence)
    io.doImageOperationNoArg(canvas, imageSource, fragmentSource)
}
/**
 * 
 * @param selector 
 */
function getValueFromSelect(selector: string): string | null {
    const domFamily = document.querySelector(selector) as HTMLSelectElement
    if (!domFamily) {
        console.warn('domFamily missing')
        return null
    }
    else {
        if (verboseLogging)
            console.log(domFamily)
        return domFamily.value
    }
}

function printFamilyname(): void {
{'fraction_non_alphanumeric': 0.12513631406761178, 'fraction_numerical': 0.006543075245365322, 'mean_word_length': 3.518472906403941, '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': '1817972', 'n_tokens_mistral': 1145, 'n_tokens_neox': 1117, 'n_words': 276}