Skip to content

Instantly share code, notes, and snippets.

View pascalbros's full-sized avatar

Pascal Ambrosini pascalbros

View GitHub Profile
@pascalbros
pascalbros / spacesToTabs.sh
Created October 29, 2017 19:07
Replace whitespaces with tabs in a Xcode Project
#!/bin/bash
find . -name "*.swift" | while read line; do unexpand -t 4 "$line" > "$line.new"; mv "$line.new" "$line"; done
@pascalbros
pascalbros / PolylineUtils.cs
Last active April 18, 2024 21:20
Converts a polyline (EdgeCollider2D coordinates) to a PolygonCollider2D points using the given thickness.
class PolylineUtils {
/*
* Converts a polyline to a polygon with the given thickness.
*/
static Vector2[] GeneratePolygonFromPolyline(float thickness, Vector2[] points) {
if (points.Length < 2) { return points; }
Vector2[] result = new Vector2[points.Length * 2];
var normal = Vector2.zero;
for (int i = 0; i < points.Length - 1; i++) {
var direction = (points[i + 1] - points[i]).normalized;