Skip to content

Instantly share code, notes, and snippets.

@OswaldHurlem
OswaldHurlem / pun_x11_colors.h
Created May 5, 2017 09:23
Metaprogramming a named color palette for Punity
/*<<<
x11Colors = [
("X11_BLACK", "0x00, 0x00, 0x00"),
("X11_WHITE", "0XFF, 0XFF, 0XFF"),
("X11_ALICE_BLUE", "0xF0, 0xF8, 0xFF"),
("X11_ANTIQUE_WHITE", "0xFA, 0xEB, 0xD7"),
("X11_AQUA", "0x00, 0xFF, 0xFF"),
("X11_AQUAMARINE", "0x7F, 0xFF, 0xD4"),
("X11_AZURE", "0xF0, 0xFF, 0xFF"),
("X11_BEIGE", "0xF5, 0xF5, 0xDC"),
using UnityEngine;
namespace OH.Vectors
{
public static class Swizzles
{
public static Vector2 XX(this Vector2 V){ return MkVector2(V.x, V.x); }
public static Vector2 XY(this Vector2 V){ return MkVector2(V.x, V.y); }
public static Vector2 X_(this Vector2 V){ return MkVector2(V.x, 0); }
public static Vector2 YX(this Vector2 V){ return MkVector2(V.y, V.x); }
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
// Ill-advised experiment making a SoA container in C# using Reflection
namespace SoaExperiment
using UnityEngine;
namespace OH.Ext
{
public static class OHVectorToUnityIntVector
{
public static Vector2Int ToVector2Int(this VectorI2 v)
{
return new Vector2Int(v.x, v.y);
}
#include <stdlib.h>
#include <stdint.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
struct lbp_serializer
{
int32_t DataVersion;
FILE* FilePtr;
// This doesn't seem to work properly
//#define USE_UNITY_PIN_FUNCTION
using System;
using System.Runtime.InteropServices;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine.Assertions;
// Trick for creating a temporary NativeArray which points to the contents of a managed array.
namespace OHDelegate
{
/*<<<
for valCnt in range(0, 6):
for refCnt in range(1, 9 - valCnt):
suffix = "WithRef" if refCnt == 1 else "With#{refCnt}Refs"
typeParams = ["in TVal#{i}" for i in xrange(0, valCnt)] + ["TRef#{i}" for i in xrange(0, refCnt)]
angleBracketContents = ", ".join(typeParams)
params = ", ".join(["TVal#{i} v#{i}" for i in xrange(0, valCnt)] + ["ref TRef#{i} r#{i}" for i in xrange(0, refCnt)])
OUT("public delegate void Action#{suffix}<#{angleBracketContents}>(")
This file has been truncated, but you can view the full file.
/* GIMP header image file format (INDEXED): C:\Users\co.nl.on\Desktop\desktop dump 2018\gimp_img_idxd.h */
static unsigned int width = 500;
static unsigned int height = 482;
/* Call this macro repeatedly. After each use, the pixel data can be extracted */
#define HEADER_PIXEL(data,pixel) {\
pixel[0] = header_data_cmap[(unsigned char)data[0]][0]; \
pixel[1] = header_data_cmap[(unsigned char)data[0]][1]; \
// This doesn't seem to work properly
//#define USE_UNITY_PIN_FUNCTION
using System;
using System.Runtime.InteropServices;
using System.Threading;
using Unity.Collections;
using Unity.Collections.LowLevel.Unsafe;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Assertions;
#define IMPL_DIV_INT(_intT) \
inline _intT Div(_intT A, _intT B) { \
_intT q = A/B, r = A%B; \
if ((r > 0 && B < 0) || (r < 0 && B > 0)) { return q-1; } \
return q; \
}
#define IMPL_CEIL_DIV_INT(_intT) \
inline _intT CeilDiv(_intT A, _intT B) { \
_intT q = A/B, r = A%B; \