Skip to content

Instantly share code, notes, and snippets.

View x5lcfd's full-sized avatar
:octocat:
coding.

x5lcfd x5lcfd

:octocat:
coding.
View GitHub Profile
@x5lcfd
x5lcfd / DrawPolygon.cs
Created January 17, 2016 12:21
Draw a polygon in Unity
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Sprites;
using System;
using System.Collections.Generic;
public class DrawPolygon : Graphic
{
[SerializeField]
Shader "UI/Effect/Blur" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_BumpAmt ("Distortion", Range (0,128)) = 10
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
_Size ("Size", Range(0, 20)) = 1
}
Category {
Shader "UI/X5LCFD/Glint"
{
Properties
{
[PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
_Color("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
_ShineLocation("ShineLocation", Range(0,1)) = 0
_ShineWidth("ShineWidth", Range(0,1)) = 0
}
@x5lcfd
x5lcfd / delete_node.c
Last active February 28, 2016 14:57
linked list operations
void delete_node ( struct node** head, elem_type x )
{
for ( struct node** curr = head; *curr; )
{
struct node* entry = *curr;
if ( entry->elem == x ) {
*curr = entry->next;
free ( entry );
} else {
curr = &entry->next;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Xml;
using System;
public class BitmapFontExporter : ScriptableWizard
{
[MenuItem ( "BitmapFontExporter/Create" )]
private static void CreateFont ()
using UnityEngine;
using System.Collections;
namespace UnityEngine.UI
{
public class Empty4Raycast : MaskableGraphic
{
protected Empty4Raycast()
{
useLegacyMeshGeneration = false;
@x5lcfd
x5lcfd / ExpressionParser.cs
Last active October 17, 2016 02:01
MathExpressionParser
/* * * * * * * * * * * * * *
* A simple expression parser
* --------------------------
*
* The parser can parse a mathematical expression into a simple custom
* expression tree. It can recognise methods and fields/contants which
* are user extensible. It can also contain expression parameters which
* are registrated automatically. An expression tree can be "converted"
* into a delegate.
*
@x5lcfd
x5lcfd / freetype_test.cpp
Created April 21, 2016 14:01
FreeType Render UTF8 string
/* Compile & Run:
clang++ -std=c++11 -fsanitize=address `freetype-config --cflags` `icu-config --cflags | sed -e 's/-std=c99//g' | sed -e 's/-O2//g'` -o freetype_test freetype_test.cpp `freetype-config --libs` `icu-config --ldflags` -lopencv_core -lopencv_highgui && ASAN_OPTIONS="detect_leaks=1" ./freetype_test
*/
// Change the following to suit your need.
static const char *FONT_FILE = "/usr/share/fonts/truetype/wqy/wqy-microhei.ttc";
static const char *STR = u8"哈哈abcdefghijklmnopqrstuvwxyz1234567890";
static const int PIXEL_SIZE = 32, COLOR_BLUE = 255, COLOR_GREEN = 255, COLOR_RED = 0;
#include <cstdio>
@x5lcfd
x5lcfd / SpriteShadows.shader
Last active October 17, 2016 02:01
SpriteShadows
Shader "Sprites/SpriteShadows"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.5
_Intensity("Shadow Intensity", Range(0,1)) = 0.5
}
@x5lcfd
x5lcfd / SkeletonGraphic.cs
Created May 24, 2016 06:04 — forked from pharan/SkeletonGraphic.cs
SkeletonGraphic is a self-contained UnityEngine.UI.Graphic version of Spine's SkeletonAnimation component.
/******************************************************************************
* Spine Runtimes Software License
* Version 2.3
*
* Copyright (c) 2013-2015, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to use, install, execute and perform the Spine
* Runtimes Software (the "Software") and derivative works solely for personal