Skip to content

Instantly share code, notes, and snippets.

View usagi's full-sized avatar
🍣
Sushi

USAGI/USAGI.NETWORK usagi

🍣
Sushi
View GitHub Profile
@usagi
usagi / RGB24_from_HSL24.hxx
Last active December 10, 2015 23:19
color conversion (RGB24 from HSL24)
template<class INTERNAL_TYPE = double>
RGB24 rgb_from_hsl(HSL24&& i) {
using internal_type = INTERNAL_TYPE;
constexpr internal_type
zero = 0., one = 1., two = 2., six = 6.,
senary_1 = 1. / six, senary_2 = 2. / six,
senary_3 = 3. / six, senary_4 = 4. / six,
senary_5 = 5. / six,
trinary_1 = 1. / 3.,
max_factor = numeric_limits<decltype(i.h)>::max(),
@usagi
usagi / Makefile
Last active December 10, 2015 23:19
CXX := g++
OPT := -std=c++11 -O3 -Wall
#CORES := `grep processor /proc/cpuinfo | tail -n1 | sed "s/[^0-9]//g" | xargs expr 1 +`
#OPT += -floop-parallelize-all -ftree-parallelize-loops=${CORES}
OPT += -fopenmp
OPT_387 := -mfpmath=387
OPT_SSE := -mfpmath=sse
OPT_SSE387 := -mfpmath=sse,387
OPT_BINARY32 := -DADOPT_BINARY32
OPT_BINARY64 := -DADOPT_BINARY64
#include <iostream>
#include <boost/units/detail/utility.hpp>
#include <vector>
#include <string>
template<class T, class ... TS>
struct X { };
int main(){
#include <iostream>
#include <stdexcept>
#include <limits>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <limits>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 3 in line 1.
<lost colors of RGB24 from HSL>
{hr == sr == lr} liner proportional
[8,8,8] 16776759 16776647
[16,16,16] 16773371 16772879
[32,32,32] 16747073 16744394
[64,64,64] 16562781 16540975
[128,128,128] 15322739 15131360
[256,256,256] 10352220 7867682
[512,512,512] 2041468 21638
[1024,1024,1024] 7504 765
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 3 in line 1.
<lost colors of RGB24 from HSL>
{hr == sr == lr} liner proportional
[512,512,512] 2041468 21638
[640,640,640] 569105 4599
[768,768,768] 111629 765
[896,896,896] 19958 765
[1024,1024,1024] 7504 765
[1152,1152,1152] 2958 765
[1280,1280,1280] 1193 765
[1408,1408,1408] 582 765
#include <iostream>
#include <iomanip>
#include <stdexcept>
#include <limits>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
184691 1846 135
167617 4836 621
167593 8370 1484
167779 11538 2721
167094 14946 4334
168304 18432 6321
167943 21330 8684
167580 24954 11421
167986 28122 14534
166008 31584 18021
@usagi
usagi / vertex.hpp
Last active December 14, 2015 04:19
the vertex (attribute) type sample for libWRP-GLEW.
#include <cstddef>
#include <cstdint>
#include <memory>
template<class T, class ... TS>
struct vertex final
{
static constexpr size_t elements = 1 + sizeof...(TS);
// fix1-1: remove this line
// static constexpr size_t size = sizeof(T) + vertex<TS...>::size;