Skip to content

Instantly share code, notes, and snippets.

HB HoraceBury

  • UK
View GitHub Profile
@HoraceBury
HoraceBury / posts
Created Mar 28, 2019
Links to useful posts in the Corona forums
View posts
Moving groups of physics objects
https://forums.coronalabs.com/topic/74929-moving-group-of-phyics-objects/
Setting a physics body's position
https://forums.coronalabs.com/topic/74900-how-to-permanently-set-bodys-x-position/
Collision events
https://forums.coronalabs.com/topic/74846-collision-events-order/
@HoraceBury
HoraceBury / dropboxapi.lua
Last active Sep 16, 2018
DropBox API v2 library.
View dropboxapi.lua
-- DropBox API v2 Library
require("utils") -- https://gist.github.com/HoraceBury/9321964
local iolib = require("iolib") -- https://gist.github.com/HoraceBury/d8d2fa3382f82a7c7faa
iolib.isdebug = false
local lib = {}
local function printer(str)
iolib.isdebug = lib.IsDebug
@HoraceBury
HoraceBury / catmull.lua
Created Aug 2, 2018
Takes a table of x,y points and returns a smooth catmull-rom spline table of x,y points.
View catmull.lua
-- catmull-rom-spline library
-- Resources:
-- https://gist.github.com/1383576
-- http://codeplea.com/simple-interpolation
-- http://codeplea.com/introduction-to-splines
require("tablelib") -- https://gist.github.com/HoraceBury/9307117
require("mathlib") -- https://gist.github.com/HoraceBury/9431861
@HoraceBury
HoraceBury / Program.cs
Created Apr 4, 2018
Executing an equation in C# proven with nUnit.
View Program.cs
using System;
using NUnit.Framework;
using System.Data;
namespace RandomTests
{
[TestFixture]
public class NumberTests
{
public static void Main(string[] args)
@HoraceBury
HoraceBury / displaylib.lua
Created Mar 21, 2018
Display library, adding to and modifying the existing Corona display library.
View displaylib.lua
-- display lib
local newShapeList = {
"newCircle",
"newContainer",
"newEmbossedText",
"newEmitter",
"newGroup",
"newImage",
"newImageRect",
@HoraceBury
HoraceBury / cyclingants.lua
Last active Mar 11, 2018
Cycling ants. Takes a pattern to be used for a mask outline and generates a collection of display groups which can be used to animate the cyclic pattern around a path shape. https://youtu.be/4cwjTrpvnFU
View cyclingants.lua
require("mathlib")
require("graphicslib")
require("tablelib")
local function asPoint( x, y )
return { x=x, y=y }
end
local function getPoint( path, index )
return { x=path[index], y=path[index+1] }
@HoraceBury
HoraceBury / graphicslib.lua
Last active Mar 21, 2018
Graphics extension library.
View graphicslib.lua
-- graphics extension library
require("mathlib") -- https://gist.github.com/HoraceBury/9431861
require("displaylib") -- https://gist.github.com/HoraceBury/1e2ce033e3441823038eb88b551ad981
-- https://math.stackexchange.com/questions/2269589/calculate-angle-of-the-next-point-on-a-circle
--[[
Generates a table of points containing the outline of a circle with each point 'step' pixels from the previous.
Parameters:
@HoraceBury
HoraceBury / _shadowlib.lua
Last active May 8, 2018
Shadow library. Given a display group, this will ensure that non-physics-based shadows will be updated to track their parent, whether the parent is physics-based or not. The test sample demonstrates using physics to provide a shadow, as well.
View _shadowlib.lua
local lib = {}
function lib.newShadowLayer( shadowgroup )
local function refresh()
if (shadowgroup and shadowgroup.numChildren) then
for i=1, shadowgroup.numChildren do
local shadow = shadowgroup[i]
local object = shadowgroup[i].shadowparent
if (not shadow.isBodyActive) then
@HoraceBury
HoraceBury / Cache.cs
Created Aug 21, 2017
Generic caching mechanism which makes sliding expiration easy.
View Cache.cs
using System;
using System.Collections.Generic;
using System.Runtime.Caching;
namespace CacheServices
{
public class Cache
{
protected MemoryCache _cache = new MemoryCache("general");
@HoraceBury
HoraceBury / dragitemscrollview.lua
Created Dec 30, 2016
Provides a scrollview widget which can have items dragged off it.
View dragitemscrollview.lua
local widget = require("widget")
local function angleOf( ax, ay, bx, by, adjust, positive )
local angle = math.atan2( by-ay, bx-ax ) * 180/math.pi
if (adjust) then
if (type(adjust) ~= "number") then adjust = -90 end
angle = angle - adjust
if (angle < -180) then angle=angle+360 end
if (angle > 180) then angle=angle-360 end
You can’t perform that action at this time.