This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define MAX_SIZE (64*1024) | |
static struct my_data data[MAX_SIZE]; | |
static short free_idx[MAX_SIZE]; | |
static short first_free_idx = -1; | |
// init; populate free items | |
free_idx[MAX_SIZE-1] = -1; | |
for (int i = 0; i < MAX_SIZE-1; ++i) { | |
free_idx[i] = i+1; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Named color names (theme specific) | |
enum MIcolorNames { | |
MI_COLOR_NEUTRAL, | |
MI_COLOR_ACCENT_A, | |
}; | |
// Tones per name (theme specific) | |
enum MIcolorTone { | |
MI_COLORTONE_50, | |
MI_COLORTONE_75, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "milayout.h" | |
#include <stdlib.h> | |
#include <stdarg.h> | |
static float mi__minf(float a, float b) { return a < b ? a : b; } | |
static float mi__maxf(float a, float b) { return a > b ? a : b; } | |
static int mi__getGrow(MIbox* box, int main) | |
{ | |
return box->content.xy[main] > 0 ? box->grow : (box->grow | 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
#include <span> | |
#include <algorithm> | |
// Based on | |
// "An O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber and Gene Myers | |
// - https://publications.mpi-cbg.de/Wu_1990_6334.pdf | |
// - Good article visualizing Myer's older algorithm: https://epxx.co/artigos/diff_en.html | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
#include <span> | |
#include <algorithm> | |
// Based on | |
// "An O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber and Gene Myers | |
// - https://publications.mpi-cbg.de/Wu_1990_6334.pdf | |
// - Good article visualizing Myer's older algorithm: https://epxx.co/artigos/diff_en.html | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <vector> | |
#include <algorithm> | |
// Based on "An O(NP) Sequence Comparison Algorithm" by Sun Wu, Udi Manber and Gene Myers | |
struct Edit { | |
enum Type { Insert, Delete, Common }; | |
Edit() = default; | |
Edit(Type _type, int _a, int _b, int _n) : type(_type), a(_a), b(_b), n(_n) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float evalCurve(float x, float tx, float ty, float sa, float sb) | |
{ | |
const float EPS = 1e-6f; | |
if (x < tx) { | |
return (ty * x) / (x + sa * (tx - x) + EPS); | |
} else { | |
return ((1-ty) * (x-1)) / ((1-x) - sb * (tx - x) + EPS) + 1.0f; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright (c) 2013 Mikko Mononen [email protected] | |
// | |
// This software is provided 'as-is', without any express or implied | |
// warranty. In no event will the authors be held liable for any damages | |
// arising from the use of this software. | |
// Permission is granted to anyone to use this software for any purpose, | |
// including commercial applications, and to alter it and redistribute it | |
// freely, subject to the following restrictions: | |
// 1. The origin of this software must not be misrepresented; you must not |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
(0,0) | |
+.................. | |
: image : | |
: : | |
: +----+ : | |
: |rect| : | |
: +----+ : | |
: : | |
................... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void mmul(float* m, const float* a, const float* b) | |
{ | |
for (int r = 0; r < 4; r++) | |
for (int c = 0; c < 4; c++) | |
m[r*4+c] = a[r*4+0] * b[0*4+c] + a[r*4+1] * b[1*4+c] + a[r*4+2] * b[2*4+c] + a[r*4+3] * b[3*4+c]; | |
} | |
void midentity(float* m) | |
{ | |
for (int i = 0; i < 4; i++) |
NewerOlder