This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Tested on repl.it | |
local N = 8 -- or 16, etc. Could also adapt for fixed point | |
local lshift = math.ldexp | |
local HighBitMask = lshift(1, N - 1) | |
local function Div (a, b) | |
local acc, result = 0, 0 | |
local mask = HighBitMask -- one-hot mask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local lfs = require("lfs") | |
local N, NFiles, NSpaces = 0, 0, 0 | |
local doc_path = system.pathForFile( "", system.ResourceDirectory ) | |
local function About (name, file, indent) | |
print(indent, file) | |
local n, nspaces = 0, 0 | |
for line in io.lines(name) do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Utilities for layout handling. | |
-- | |
-- These are designed to allow layout decisions and queries, without worrying about the | |
-- anchor points of the objects in question. In many cases, positions may be substituted | |
-- for objects, as well. | |
-- | |
-- With respect to this module, a **Number** may be any of the following: | |
-- | |
-- * A number, or a string that @{tonumber} is able to convert. These values are used as is. | |
-- * A string of the form **"AMOUNT%"**, e.g. `"20%"` or `"-4.2%"`, which resolves to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- Implements a system for deterministic recycling of objects, via an underlying cache. | |
-- | |
-- When an object is created, or fetched from the cache, it may be registered with this | |
-- system. At a given point in execution, the system will then claim the object and add it to | |
-- the cache. The system is primarily intended for more intense parts of a program and must | |
-- be activated explicitly, being idle otherwise. When not running, registration is a no-op, | |
-- though the cache remains available for fetching. | |
-- | |
-- An instance of this system is created via the @{NewCacheStack} function. (Typical programs | |
-- will only need one instance, but this is not required, e.g. various subsystems could each |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if not defined DevEnvDir ( | |
call "%VS120COMNTOOLS%vsvars32.bat" | |
) | |
@if not defined INCLUDE goto :FAIL | |
@setlocal | |
@if "%1"=="debug-5.1" goto :DEBUG_5_1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local CX, CY = display.contentCenterX, display.contentCenterY | |
local N = 15 | |
local R = 50 | |
local cosa, sina = R, 0 -- can be R, 0 if you have a fixed radius; otherwise, you will scale these | |
-- intermediate steps | |
local cosda, sinda = math.cos(2 * math.pi / N), math.sin(2 * math.pi / N) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files (the | |
* "Software"), to deal in the Software without restriction, including | |
* without limitation the rights to use, copy, modify, merge, publish, | |
* distribute, sublicense, and/or sell copies of the Software, and to | |
* permit persons to whom the Software is furnished to do so, subject to | |
* the following conditions: | |
* | |
* The above copyright notice and this permission notice shall be |
NewerOlder