Skip to content

Instantly share code, notes, and snippets.

View dflemstr's full-sized avatar

David Flemström dflemstr

View GitHub Profile
object SomeRandomPass extends Pass {
val title = "Stuff"
val description = "Stuff"
//Magie: dieser Code fügt zwei Methoden zur Klasse BufferedImage hinzu
//Tu dies in dein Pass herein unter "val description = ..." um es zu aktivieren
case class Color(a: Int, r: Int, g: Int, b: Int)
implicit def addColorAccessTo(img: BufferedImage) = new {
def apply(x: Int, y: Int) = {
package se.dflemstr.imgproc.passes
import java.awt.image.BufferedImage
import se.dflemstr.imgproc.graphics.Texture
object NearestNeighbor extends Pass {
val title = "Nearest Neighbor interpolation detection"
val description = "A pass that highlights duplicate pixels in an image."
package se.dflemstr.imgproc.passes
import java.awt.image.BufferedImage
import se.dflemstr.imgproc.graphics.Texture
object NearestNeighbor extends Pass {
val title = "Nearest Neighbor interpolation detection"
val description = "A pass that highlights duplicate pixels in an image."
@dflemstr
dflemstr / example.cpp
Last active September 15, 2022 00:31
A C++ implementation of fixed point math
#include "fixedp.h"
#include <iostream>
int main(int, char **)
{
fixedp<true, 16, 16> x(0); //32-bit signed 16.16 fixed-point number
fixedp<false, 8, 8> y(10); //16-bit unsigned 8.8 fixed-point number
std::cout << (fixedp<false, 4, 4>(3.5) + fixedp<false, 4, 4>(4.5)).toFloat() << std::endl;
//prints "8"
#include "example.h"
Example::Example(int someInt, const std::string &someString)
: _someInt(someInt), //Assign _someInt
_someString(someString) //Copy the whole string to _someString
{
}
const std::string &Example::someString() const
{
//Linear interpolation of a 2D double array
private double[,] Interpolate(double[,] matrix, int dim)
{
double[,] result = new double[dim, dim];
double sf = (double)(matrix.GetLength(0) - 1) / (double)(dim - 1d);
for (int x = 0; x < dim; x++)
{
for (int y = 0; y < dim; y++)
{
public class Card {
private int number, colors;
private static String[] Colors = { "Hearts", "Spades", "Diamonds", "Clubs" };
private static String[] Number = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Knave", "Queen", "King" };
Card(int Cardcolors, int Cardnumber){
this.number=Cardnumber;
this.colors=Cardcolors;
}
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is an example PXML file for an application named "Exaile", to
demonstrate how a PXML file is supposed to be structured. Feel free to
replace all of the field contents with your own data, and to remove these
comments afterwards, in order to get a working and valid PXML file.
Note that this file is MINIMAL aka. this is the information you SHOULD
specify if you're well-behaved (all of it isn't NEEDED per-se, though)-->
<!--
Select
items1.id as items1_id,
localizations3.itemId as localizations3_itemId,
localizations3.languageName as localizations3_languageName,
items1.id as items1_id,
localizations2.string as localizations2_string,
localizations2.itemId as localizations2_itemId,
localizations2.languageName as localizations2_languageName,
localizations3.string as localizations3_string,
localizations3.itemId as localizations3_itemId,
//This doesn't actually work, since function application has the highest precedence in Scala.
def repeat(self: String, times: Int) = self * times
val x = "ABC"
x~repeat(5)