repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
partition
stringclasses
1 value
webtorrent/create-torrent
index.js
getStreamStream
function getStreamStream (readable, file) { return () => { const counter = new stream.Transform() counter._transform = function (buf, enc, done) { file.length += buf.length this.push(buf) done() } readable.pipe(counter) return counter } }
javascript
function getStreamStream (readable, file) { return () => { const counter = new stream.Transform() counter._transform = function (buf, enc, done) { file.length += buf.length this.push(buf) done() } readable.pipe(counter) return counter } }
[ "function", "getStreamStream", "(", "readable", ",", "file", ")", "{", "return", "(", ")", "=>", "{", "const", "counter", "=", "new", "stream", ".", "Transform", "(", ")", "counter", ".", "_transform", "=", "function", "(", "buf", ",", "enc", ",", "don...
Convert a readable stream to a lazy readable stream. Adds instrumentation to track the number of bytes in the stream and set `file.length`. @param {Stream} stream @param {Object} file @return {function}
[ "Convert", "a", "readable", "stream", "to", "a", "lazy", "readable", "stream", ".", "Adds", "instrumentation", "to", "track", "the", "number", "of", "bytes", "in", "the", "stream", "and", "set", "file", ".", "length", "." ]
6e6fc18aac7d212a5a8d9c766b12a525618e9ceb
https://github.com/webtorrent/create-torrent/blob/6e6fc18aac7d212a5a8d9c766b12a525618e9ceb/index.js#L466-L477
train
foreverjs/nssocket
lib/nssocket.js
doReconnect
function doReconnect() { // // Cleanup and recreate the socket associated // with this instance. // self.retry.waiting = true; self.socket.removeAllListeners(); self.socket = common.createSocket(self._options); // // Cleanup reconnect logic once the socket connects // self.s...
javascript
function doReconnect() { // // Cleanup and recreate the socket associated // with this instance. // self.retry.waiting = true; self.socket.removeAllListeners(); self.socket = common.createSocket(self._options); // // Cleanup reconnect logic once the socket connects // self.s...
[ "function", "doReconnect", "(", ")", "{", "//", "// Cleanup and recreate the socket associated", "// with this instance.", "//", "self", ".", "retry", ".", "waiting", "=", "true", ";", "self", ".", "socket", ".", "removeAllListeners", "(", ")", ";", "self", ".", ...
Helper function containing the core reconnect logic
[ "Helper", "function", "containing", "the", "core", "reconnect", "logic" ]
ef5be453c895cdfca297a4e15cf5c783d1296515
https://github.com/foreverjs/nssocket/blob/ef5be453c895cdfca297a4e15cf5c783d1296515/lib/nssocket.js#L315-L337
train
foreverjs/nssocket
lib/nssocket.js
tryReconnect
function tryReconnect() { self.retry.retries++; if (self.retry.retries >= self.retry.max) { return self.emit('error', new Error('Did not reconnect after maximum retries: ' + self.retry.max)); } doReconnect(); }
javascript
function tryReconnect() { self.retry.retries++; if (self.retry.retries >= self.retry.max) { return self.emit('error', new Error('Did not reconnect after maximum retries: ' + self.retry.max)); } doReconnect(); }
[ "function", "tryReconnect", "(", ")", "{", "self", ".", "retry", ".", "retries", "++", ";", "if", "(", "self", ".", "retry", ".", "retries", ">=", "self", ".", "retry", ".", "max", ")", "{", "return", "self", ".", "emit", "(", "'error'", ",", "new"...
Helper function which attempts to retry if it is less than the maximum
[ "Helper", "function", "which", "attempts", "to", "retry", "if", "it", "is", "less", "than", "the", "maximum" ]
ef5be453c895cdfca297a4e15cf5c783d1296515
https://github.com/foreverjs/nssocket/blob/ef5be453c895cdfca297a4e15cf5c783d1296515/lib/nssocket.js#L343-L350
train
tj/better-assert
index.js
assert
function assert(expr) { if (expr) return; var stack = callsite(); var call = stack[1]; var file = call.getFileName(); var lineno = call.getLineNumber(); var src = fs.readFileSync(file, 'utf8'); var line = src.split('\n')[lineno-1]; var src = line.match(/assert\((.*)\)/)[1]; var err = new AssertionEr...
javascript
function assert(expr) { if (expr) return; var stack = callsite(); var call = stack[1]; var file = call.getFileName(); var lineno = call.getLineNumber(); var src = fs.readFileSync(file, 'utf8'); var line = src.split('\n')[lineno-1]; var src = line.match(/assert\((.*)\)/)[1]; var err = new AssertionEr...
[ "function", "assert", "(", "expr", ")", "{", "if", "(", "expr", ")", "return", ";", "var", "stack", "=", "callsite", "(", ")", ";", "var", "call", "=", "stack", "[", "1", "]", ";", "var", "file", "=", "call", ".", "getFileName", "(", ")", ";", ...
Assert the given `expr`.
[ "Assert", "the", "given", "expr", "." ]
dadbe26bc0fb86eeddd14f4651ee56a4a0f4126e
https://github.com/tj/better-assert/blob/dadbe26bc0fb86eeddd14f4651ee56a4a0f4126e/index.js#L21-L38
train
jDataView/jDataView
src/jdataview.js
add
function add(x, y) { var z = []; var n = Math.max(x.length, y.length); var carry = 0; var i = 0; while (i < n || carry) { var xi = i < x.length ? x[i] : 0; var yi = i < y.length ? y[i] : 0; var zi = carry + xi + yi; z.push(zi % 10); carry = Math.floor(zi / 10); i++; } return z; }
javascript
function add(x, y) { var z = []; var n = Math.max(x.length, y.length); var carry = 0; var i = 0; while (i < n || carry) { var xi = i < x.length ? x[i] : 0; var yi = i < y.length ? y[i] : 0; var zi = carry + xi + yi; z.push(zi % 10); carry = Math.floor(zi / 10); i++; } return z; }
[ "function", "add", "(", "x", ",", "y", ")", "{", "var", "z", "=", "[", "]", ";", "var", "n", "=", "Math", ".", "max", "(", "x", ".", "length", ",", "y", ".", "length", ")", ";", "var", "carry", "=", "0", ";", "var", "i", "=", "0", ";", ...
Adds two digit arrays, returning the result.
[ "Adds", "two", "digit", "arrays", "returning", "the", "result", "." ]
c9c29eac67c54de78ac48d16e5dffc5194a0c7bf
https://github.com/jDataView/jDataView/blob/c9c29eac67c54de78ac48d16e5dffc5194a0c7bf/src/jdataview.js#L254-L268
train
MarkBind/markbind
src/Site.js
getPluginPath
function getPluginPath(rootPath, plugin) { // Check in project folder const pluginPath = path.join(rootPath, PROJECT_PLUGIN_FOLDER_NAME, `${plugin}.js`); if (fs.existsSync(pluginPath)) { return pluginPath; } // Check in src folder const srcPath = path.join(__dirname, BUILT_IN_PLUGIN_FOLDER_NAME, `${plu...
javascript
function getPluginPath(rootPath, plugin) { // Check in project folder const pluginPath = path.join(rootPath, PROJECT_PLUGIN_FOLDER_NAME, `${plugin}.js`); if (fs.existsSync(pluginPath)) { return pluginPath; } // Check in src folder const srcPath = path.join(__dirname, BUILT_IN_PLUGIN_FOLDER_NAME, `${plu...
[ "function", "getPluginPath", "(", "rootPath", ",", "plugin", ")", "{", "// Check in project folder", "const", "pluginPath", "=", "path", ".", "join", "(", "rootPath", ",", "PROJECT_PLUGIN_FOLDER_NAME", ",", "`", "${", "plugin", "}", "`", ")", ";", "if", "(", ...
Retrieves the correct plugin path for a plugin name, if not in node_modules @param rootPath root of the project @param plugin name of the plugin
[ "Retrieves", "the", "correct", "plugin", "path", "for", "a", "plugin", "name", "if", "not", "in", "node_modules" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/Site.js#L871-L891
train
MarkBind/markbind
src/Site.js
findDefaultPlugins
function findDefaultPlugins() { const globPath = path.join(__dirname, BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME); if (!fs.existsSync(globPath)) { return []; } return walkSync(globPath, { directories: false, globs: [`${MARKBIND_PLUGIN_PREFIX}*.js`], }).map(file => path.parse(file).name); }
javascript
function findDefaultPlugins() { const globPath = path.join(__dirname, BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME); if (!fs.existsSync(globPath)) { return []; } return walkSync(globPath, { directories: false, globs: [`${MARKBIND_PLUGIN_PREFIX}*.js`], }).map(file => path.parse(file).name); }
[ "function", "findDefaultPlugins", "(", ")", "{", "const", "globPath", "=", "path", ".", "join", "(", "__dirname", ",", "BUILT_IN_DEFAULT_PLUGIN_FOLDER_NAME", ")", ";", "if", "(", "!", "fs", ".", "existsSync", "(", "globPath", ")", ")", "{", "return", "[", ...
Finds plugins in the site's default plugin folder
[ "Finds", "plugins", "in", "the", "site", "s", "default", "plugin", "folder" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/Site.js#L896-L905
train
MarkBind/markbind
src/plugins/filterTags.js
filterTags
function filterTags(tags, content) { if (!tags) { return content; } const $ = cheerio.load(content, { xmlMode: false }); const tagOperations = tags.map(tag => ({ // Trim leading + or -, replace * with .*, add ^ and $ tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`, ...
javascript
function filterTags(tags, content) { if (!tags) { return content; } const $ = cheerio.load(content, { xmlMode: false }); const tagOperations = tags.map(tag => ({ // Trim leading + or -, replace * with .*, add ^ and $ tagExp: `^${escapeRegExp(tag.replace(/^(\+|-)/g, '')).replace(/\\\*/, '.*')}$`, ...
[ "function", "filterTags", "(", "tags", ",", "content", ")", "{", "if", "(", "!", "tags", ")", "{", "return", "content", ";", "}", "const", "$", "=", "cheerio", ".", "load", "(", "content", ",", "{", "xmlMode", ":", "false", "}", ")", ";", "const", ...
Filters out elements on the page based on config tags @param tags to filter @param content of the page
[ "Filters", "out", "elements", "on", "the", "page", "based", "on", "config", "tags" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/plugins/filterTags.js#L9-L37
train
MarkBind/markbind
__mocks__/fs-extra-promise.js
rimraf
function rimraf(dirPath) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach((entry) => { const entryPath = path.join(dirPath, entry); if (fs.lstatSync(entryPath).isDirectory()) { rimraf(entryPath); } else { fs.unlinkSync(entryPath); } }); fs.rmdirSync(d...
javascript
function rimraf(dirPath) { if (fs.existsSync(dirPath)) { fs.readdirSync(dirPath).forEach((entry) => { const entryPath = path.join(dirPath, entry); if (fs.lstatSync(entryPath).isDirectory()) { rimraf(entryPath); } else { fs.unlinkSync(entryPath); } }); fs.rmdirSync(d...
[ "function", "rimraf", "(", "dirPath", ")", "{", "if", "(", "fs", ".", "existsSync", "(", "dirPath", ")", ")", "{", "fs", ".", "readdirSync", "(", "dirPath", ")", ".", "forEach", "(", "(", "entry", ")", "=>", "{", "const", "entryPath", "=", "path", ...
Utils Remove directory recursively @param {string} dirPath @see https://stackoverflow.com/a/42505874/3027390
[ "Utils", "Remove", "directory", "recursively" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/__mocks__/fs-extra-promise.js#L14-L26
train
MarkBind/markbind
__mocks__/fs-extra-promise.js
createDir
function createDir(pathArg) { const { dir, ext } = path.parse(pathArg); const dirNames = (ext === '') ? pathArg.split(path.sep) : dir.split(pathArg.sep); dirNames.reduce((accumDir, currentdir) => { const jointDir = path.join(accumDir, currentdir); if (!fs.existsSync(jointDir)) { fs.mkdirSyn...
javascript
function createDir(pathArg) { const { dir, ext } = path.parse(pathArg); const dirNames = (ext === '') ? pathArg.split(path.sep) : dir.split(pathArg.sep); dirNames.reduce((accumDir, currentdir) => { const jointDir = path.join(accumDir, currentdir); if (!fs.existsSync(jointDir)) { fs.mkdirSyn...
[ "function", "createDir", "(", "pathArg", ")", "{", "const", "{", "dir", ",", "ext", "}", "=", "path", ".", "parse", "(", "pathArg", ")", ";", "const", "dirNames", "=", "(", "ext", "===", "''", ")", "?", "pathArg", ".", "split", "(", "path", ".", ...
Iteratively creates directories to the file or directory @param pathArg
[ "Iteratively", "creates", "directories", "to", "the", "file", "or", "directory" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/__mocks__/fs-extra-promise.js#L32-L45
train
MarkBind/markbind
__mocks__/fs-extra-promise.js
copyDirSync
function copyDirSync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDest...
javascript
function copyDirSync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDest...
[ "function", "copyDirSync", "(", "src", ",", "dest", ")", "{", "if", "(", "fs", ".", "lstatSync", "(", "src", ")", ".", "isDirectory", "(", ")", ")", "{", "const", "files", "=", "fs", ".", "readdirSync", "(", "src", ")", ";", "files", ".", "forEach"...
Utility function to copy a directory to a destination recursively
[ "Utility", "function", "to", "copy", "a", "directory", "to", "a", "destination", "recursively" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/__mocks__/fs-extra-promise.js#L60-L76
train
MarkBind/markbind
__mocks__/fs-extra-promise.js
copyDirAsync
function copyDirAsync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDes...
javascript
function copyDirAsync(src, dest) { if (fs.lstatSync(src).isDirectory()) { const files = fs.readdirSync(src); files.forEach((file) => { const curSource = path.join(src, file); const curDest = path.join(dest, file); if (fs.lstatSync(curSource).isDirectory()) { if (!fs.existsSync(curDes...
[ "function", "copyDirAsync", "(", "src", ",", "dest", ")", "{", "if", "(", "fs", ".", "lstatSync", "(", "src", ")", ".", "isDirectory", "(", ")", ")", "{", "const", "files", "=", "fs", ".", "readdirSync", "(", "src", ")", ";", "files", ".", "forEach...
Utility function to copy a directory to a destination recursively for copyAsync
[ "Utility", "function", "to", "copy", "a", "directory", "to", "a", "destination", "recursively", "for", "copyAsync" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/__mocks__/fs-extra-promise.js#L81-L97
train
MarkBind/markbind
src/plugins/default/markbind-plugin-anchors.js
generateHeadingSelector
function generateHeadingSelector(headingIndexingLevel) { let headingsSelector = 'h1'; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelector += `, h${i}`; } return headingsSelector; }
javascript
function generateHeadingSelector(headingIndexingLevel) { let headingsSelector = 'h1'; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelector += `, h${i}`; } return headingsSelector; }
[ "function", "generateHeadingSelector", "(", "headingIndexingLevel", ")", "{", "let", "headingsSelector", "=", "'h1'", ";", "for", "(", "let", "i", "=", "2", ";", "i", "<=", "headingIndexingLevel", ";", "i", "+=", "1", ")", "{", "headingsSelector", "+=", "`",...
Generates a heading selector based on the indexing level @param headingIndexingLevel to generate
[ "Generates", "a", "heading", "selector", "based", "on", "the", "indexing", "level" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/plugins/default/markbind-plugin-anchors.js#L10-L16
train
MarkBind/markbind
src/Page.js
Page
function Page(pageConfig) { this.asset = pageConfig.asset; this.baseUrl = pageConfig.baseUrl; this.baseUrlMap = pageConfig.baseUrlMap; this.content = pageConfig.content || ''; this.faviconUrl = pageConfig.faviconUrl; this.frontmatterOverride = pageConfig.frontmatter || {}; this.layout = pageConfig.layout;...
javascript
function Page(pageConfig) { this.asset = pageConfig.asset; this.baseUrl = pageConfig.baseUrl; this.baseUrlMap = pageConfig.baseUrlMap; this.content = pageConfig.content || ''; this.faviconUrl = pageConfig.faviconUrl; this.frontmatterOverride = pageConfig.frontmatter || {}; this.layout = pageConfig.layout;...
[ "function", "Page", "(", "pageConfig", ")", "{", "this", ".", "asset", "=", "pageConfig", ".", "asset", ";", "this", ".", "baseUrl", "=", "pageConfig", ".", "baseUrl", ";", "this", ".", "baseUrlMap", "=", "pageConfig", ".", "baseUrlMap", ";", "this", "."...
Don't escape HTML entities
[ "Don", "t", "escape", "HTML", "entities" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/Page.js#L53-L93
train
MarkBind/markbind
src/Page.js
generateHeadingSelector
function generateHeadingSelector(headingIndexingLevel) { let headingsSelectors = ['.always-index:header', 'h1']; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelectors.push(`h${i}`); } headingsSelectors = headingsSelectors.map(selector => `${selector}:not(.no-index)`); return headingsSelec...
javascript
function generateHeadingSelector(headingIndexingLevel) { let headingsSelectors = ['.always-index:header', 'h1']; for (let i = 2; i <= headingIndexingLevel; i += 1) { headingsSelectors.push(`h${i}`); } headingsSelectors = headingsSelectors.map(selector => `${selector}:not(.no-index)`); return headingsSelec...
[ "function", "generateHeadingSelector", "(", "headingIndexingLevel", ")", "{", "let", "headingsSelectors", "=", "[", "'.always-index:header'", ",", "'h1'", "]", ";", "for", "(", "let", "i", "=", "2", ";", "i", "<=", "headingIndexingLevel", ";", "i", "+=", "1", ...
Generates a selector for headings with level inside the headingIndexLevel or with the index attribute, that do not also have the noindex attribute @param headingIndexingLevel to generate
[ "Generates", "a", "selector", "for", "headings", "with", "level", "inside", "the", "headingIndexLevel", "or", "with", "the", "index", "attribute", "that", "do", "not", "also", "have", "the", "noindex", "attribute" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/Page.js#L201-L208
train
MarkBind/markbind
src/Page.js
getClosestHeading
function getClosestHeading($, headingsSelector, element) { const prevElements = $(element).prevAll(); for (let i = 0; i < prevElements.length; i += 1) { const currentElement = $(prevElements[i]); if (currentElement.is(headingsSelector)) { return currentElement; } const childHeadings = currentE...
javascript
function getClosestHeading($, headingsSelector, element) { const prevElements = $(element).prevAll(); for (let i = 0; i < prevElements.length; i += 1) { const currentElement = $(prevElements[i]); if (currentElement.is(headingsSelector)) { return currentElement; } const childHeadings = currentE...
[ "function", "getClosestHeading", "(", "$", ",", "headingsSelector", ",", "element", ")", "{", "const", "prevElements", "=", "$", "(", "element", ")", ".", "prevAll", "(", ")", ";", "for", "(", "let", "i", "=", "0", ";", "i", "<", "prevElements", ".", ...
Gets the closest heading to an element @param $ a Cheerio object @param headingsSelector jQuery selector for selecting headings @param element to find closest heading
[ "Gets", "the", "closest", "heading", "to", "an", "element" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/Page.js#L250-L266
train
MarkBind/markbind
src/lib/markbind/src/parser.js
extractIncludeVariables
function extractIncludeVariables(includeElement, contextVariables) { const includedVariables = { ...contextVariables }; Object.keys(includeElement.attribs).forEach((attribute) => { if (!attribute.startsWith('var-')) { return; } const variableName = attribute.replace(/^var-/, ''); if (!included...
javascript
function extractIncludeVariables(includeElement, contextVariables) { const includedVariables = { ...contextVariables }; Object.keys(includeElement.attribs).forEach((attribute) => { if (!attribute.startsWith('var-')) { return; } const variableName = attribute.replace(/^var-/, ''); if (!included...
[ "function", "extractIncludeVariables", "(", "includeElement", ",", "contextVariables", ")", "{", "const", "includedVariables", "=", "{", "...", "contextVariables", "}", ";", "Object", ".", "keys", "(", "includeElement", ".", "attribs", ")", ".", "forEach", "(", ...
Extract variables from an include element @param includeElement include element to extract variables from @param contextVariables variables defined by parent pages
[ "Extract", "variables", "from", "an", "include", "element" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/lib/markbind/src/parser.js#L97-L126
train
MarkBind/markbind
src/lib/markbind/src/parser.js
extractPageVariables
function extractPageVariables(fileName, data, userDefinedVariables, includedVariables) { const $ = cheerio.load(data); const pageVariables = { }; $('variable').each(function () { const variableElement = $(this); const variableName = variableElement.attr('name'); if (!variableName) { // eslint-di...
javascript
function extractPageVariables(fileName, data, userDefinedVariables, includedVariables) { const $ = cheerio.load(data); const pageVariables = { }; $('variable').each(function () { const variableElement = $(this); const variableName = variableElement.attr('name'); if (!variableName) { // eslint-di...
[ "function", "extractPageVariables", "(", "fileName", ",", "data", ",", "userDefinedVariables", ",", "includedVariables", ")", "{", "const", "$", "=", "cheerio", ".", "load", "(", "data", ")", ";", "const", "pageVariables", "=", "{", "}", ";", "$", "(", "'v...
Extract page variables from a page @param filename for error printing @param data to extract variables from @param userDefinedVariables global variables @param includedVariables variables from parent include
[ "Extract", "page", "variables", "from", "a", "page" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/lib/markbind/src/parser.js#L135-L158
train
MarkBind/markbind
src/lib/markbind/src/parser.js
extractImportedVariables
function extractImportedVariables(context) { if (!context.importedVariables) { return {}; } const importedVariables = {}; Object.entries(context.importedVariables).forEach(([src, variables]) => { variables.forEach((variableName) => { const actualFilePath = utils.isUrl() ? src : pat...
javascript
function extractImportedVariables(context) { if (!context.importedVariables) { return {}; } const importedVariables = {}; Object.entries(context.importedVariables).forEach(([src, variables]) => { variables.forEach((variableName) => { const actualFilePath = utils.isUrl() ? src : pat...
[ "function", "extractImportedVariables", "(", "context", ")", "{", "if", "(", "!", "context", ".", "importedVariables", ")", "{", "return", "{", "}", ";", "}", "const", "importedVariables", "=", "{", "}", ";", "Object", ".", "entries", "(", "context", ".", ...
Extract imported page variables from a page @param context of the page
[ "Extract", "imported", "page", "variables", "from", "a", "page" ]
4d1101243781742448475993b43b6da2921836ab
https://github.com/MarkBind/markbind/blob/4d1101243781742448475993b43b6da2921836ab/src/lib/markbind/src/parser.js#L164-L186
train
riyadhalnur/node-base64-image
dist/node-base64-image.js
encode
function encode(url) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { string: false, local: false }; var callback = arguments[2]; // eslint-disable-line if (_lodash2.default.isUndefined(url) || _lodash2.default.isNull(url) || !_lodash2.default.isString(url)) { return cal...
javascript
function encode(url) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { string: false, local: false }; var callback = arguments[2]; // eslint-disable-line if (_lodash2.default.isUndefined(url) || _lodash2.default.isNull(url) || !_lodash2.default.isString(url)) { return cal...
[ "function", "encode", "(", "url", ")", "{", "var", "options", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "string", ":", "false", ",", "local", ":", "fa...
Encodes a remote or local image to Base64 encoded string or Buffer @name encode @param {string} url - URL of remote image or local path to image @param {Object} [options={}] - Options object for extra configuration @param {boolean} options.string - Returns a Base64 encoded string. Defaults to Buffer object @param {boo...
[ "Encodes", "a", "remote", "or", "local", "image", "to", "Base64", "encoded", "string", "or", "Buffer" ]
0fac0cdb9ff687e074f338e85a950899f00223b1
https://github.com/riyadhalnur/node-base64-image/blob/0fac0cdb9ff687e074f338e85a950899f00223b1/dist/node-base64-image.js#L42-L83
train
riyadhalnur/node-base64-image
dist/node-base64-image.js
decode
function decode(imageBuffer) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { filename: 'saved-image' }; var callback = arguments[2]; // eslint-disable-line if (!_lodash2.default.isBuffer(imageBuffer)) { return callback(new Error('The image is not a Buffer object type'))...
javascript
function decode(imageBuffer) { var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { filename: 'saved-image' }; var callback = arguments[2]; // eslint-disable-line if (!_lodash2.default.isBuffer(imageBuffer)) { return callback(new Error('The image is not a Buffer object type'))...
[ "function", "decode", "(", "imageBuffer", ")", "{", "var", "options", "=", "arguments", ".", "length", ">", "1", "&&", "arguments", "[", "1", "]", "!==", "undefined", "?", "arguments", "[", "1", "]", ":", "{", "filename", ":", "'saved-image'", "}", ";"...
Decodes an base64 encoded image buffer and saves it to disk @name decode @param {Buffer} imageBuffer - Image Buffer object @param {Object} [options={}] - Options object for extra configuration @param {string} options.filename - Filename for the final image file @param {fnCallback} callback - Callback function @return ...
[ "Decodes", "an", "base64", "encoded", "image", "buffer", "and", "saves", "it", "to", "disk" ]
0fac0cdb9ff687e074f338e85a950899f00223b1
https://github.com/riyadhalnur/node-base64-image/blob/0fac0cdb9ff687e074f338e85a950899f00223b1/dist/node-base64-image.js#L96-L111
train
silverwind/uppie
uppie.js
newDirectoryApi
function newDirectoryApi(input, opts, cb) { var fd = new FormData(), files = []; var iterate = function(entries, path, resolve) { var promises = []; entries.forEach(function(entry) { promises.push(new Promise(function(resolve) { if ("getFilesAndDirectories" in entry) { ...
javascript
function newDirectoryApi(input, opts, cb) { var fd = new FormData(), files = []; var iterate = function(entries, path, resolve) { var promises = []; entries.forEach(function(entry) { promises.push(new Promise(function(resolve) { if ("getFilesAndDirectories" in entry) { ...
[ "function", "newDirectoryApi", "(", "input", ",", "opts", ",", "cb", ")", "{", "var", "fd", "=", "new", "FormData", "(", ")", ",", "files", "=", "[", "]", ";", "var", "iterate", "=", "function", "(", "entries", ",", "path", ",", "resolve", ")", "{"...
API implemented in Firefox 42+ and Edge
[ "API", "implemented", "in", "Firefox", "42", "+", "and", "Edge" ]
be6d20fe135001c42605a0168fb2c1723874bd74
https://github.com/silverwind/uppie/blob/be6d20fe135001c42605a0168fb2c1723874bd74/uppie.js#L67-L94
train
silverwind/uppie
uppie.js
arrayApi
function arrayApi(input, opts, cb) { var fd = new FormData(), files = []; [].slice.call(input.files).forEach(function(file) { fd.append(opts.name, file, file.webkitRelativePath || file.name); files.push(file.webkitRelativePath || file.name); }); cb(fd, files); }
javascript
function arrayApi(input, opts, cb) { var fd = new FormData(), files = []; [].slice.call(input.files).forEach(function(file) { fd.append(opts.name, file, file.webkitRelativePath || file.name); files.push(file.webkitRelativePath || file.name); }); cb(fd, files); }
[ "function", "arrayApi", "(", "input", ",", "opts", ",", "cb", ")", "{", "var", "fd", "=", "new", "FormData", "(", ")", ",", "files", "=", "[", "]", ";", "[", "]", ".", "slice", ".", "call", "(", "input", ".", "files", ")", ".", "forEach", "(", ...
old prefixed API implemented in Chrome 11+ as well as array fallback
[ "old", "prefixed", "API", "implemented", "in", "Chrome", "11", "+", "as", "well", "as", "array", "fallback" ]
be6d20fe135001c42605a0168fb2c1723874bd74
https://github.com/silverwind/uppie/blob/be6d20fe135001c42605a0168fb2c1723874bd74/uppie.js#L97-L104
train
silverwind/uppie
uppie.js
entriesApi
function entriesApi(items, opts, cb) { var fd = new FormData(), files = [], rootPromises = []; function readEntries(entry, reader, oldEntries, cb) { var dirReader = reader || entry.createReader(); dirReader.readEntries(function(entries) { var newEntries = oldEntries ? oldEntries.concat(entr...
javascript
function entriesApi(items, opts, cb) { var fd = new FormData(), files = [], rootPromises = []; function readEntries(entry, reader, oldEntries, cb) { var dirReader = reader || entry.createReader(); dirReader.readEntries(function(entries) { var newEntries = oldEntries ? oldEntries.concat(entr...
[ "function", "entriesApi", "(", "items", ",", "opts", ",", "cb", ")", "{", "var", "fd", "=", "new", "FormData", "(", ")", ",", "files", "=", "[", "]", ",", "rootPromises", "=", "[", "]", ";", "function", "readEntries", "(", "entry", ",", "reader", "...
old drag and drop API implemented in Chrome 11+
[ "old", "drag", "and", "drop", "API", "implemented", "in", "Chrome", "11", "+" ]
be6d20fe135001c42605a0168fb2c1723874bd74
https://github.com/silverwind/uppie/blob/be6d20fe135001c42605a0168fb2c1723874bd74/uppie.js#L107-L159
train
hapticdata/toxiclibsjs
lib/toxi/geom/Matrix4x4.js
function(axis, theta) { var x, y, z, s, c, t, tx, ty; x = axis.x; y = axis.y; z = axis.z; s = Math.sin(theta); c = Math.cos(theta); t = 1 - c; tx = t * x; ty = t * y; _TEMP.set( tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z, ...
javascript
function(axis, theta) { var x, y, z, s, c, t, tx, ty; x = axis.x; y = axis.y; z = axis.z; s = Math.sin(theta); c = Math.cos(theta); t = 1 - c; tx = t * x; ty = t * y; _TEMP.set( tx * x + c, tx * y + s * z, tx * z - s * y, 0, tx * y - s * z, ...
[ "function", "(", "axis", ",", "theta", ")", "{", "var", "x", ",", "y", ",", "z", ",", "s", ",", "c", ",", "t", ",", "tx", ",", "ty", ";", "x", "=", "axis", ".", "x", ";", "y", "=", "axis", ".", "y", ";", "z", "=", "axis", ".", "z", ";...
Applies rotation about arbitrary axis to matrix @param axis @param theta @return rotation applied to this matrix
[ "Applies", "rotation", "about", "arbitrary", "axis", "to", "matrix" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Matrix4x4.js#L324-L340
train
hapticdata/toxiclibsjs
lib/toxi/geom/Matrix4x4.js
function(theta) { _TEMP.identity(); _TEMP.matrix[1][1] = _TEMP.matrix[2][2] = Math.cos(theta); _TEMP.matrix[2][1] = Math.sin(theta); _TEMP.matrix[1][2] = -_TEMP.matrix[2][1]; return this.multiplySelf(_TEMP); }
javascript
function(theta) { _TEMP.identity(); _TEMP.matrix[1][1] = _TEMP.matrix[2][2] = Math.cos(theta); _TEMP.matrix[2][1] = Math.sin(theta); _TEMP.matrix[1][2] = -_TEMP.matrix[2][1]; return this.multiplySelf(_TEMP); }
[ "function", "(", "theta", ")", "{", "_TEMP", ".", "identity", "(", ")", ";", "_TEMP", ".", "matrix", "[", "1", "]", "[", "1", "]", "=", "_TEMP", ".", "matrix", "[", "2", "]", "[", "2", "]", "=", "Math", ".", "cos", "(", "theta", ")", ";", "...
Applies rotation about X to this matrix. @param theta rotation angle in radians @return itself
[ "Applies", "rotation", "about", "X", "to", "this", "matrix", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Matrix4x4.js#L349-L355
train
hapticdata/toxiclibsjs
lib/toxi/geom/Line3D.js
function(p) { var v = this.b.sub(this.a); var t = p.sub(this.a).dot(v) / v.magSquared(); // Check to see if t is beyond the extents of the line segment if (t < 0.0) { return this.a.copy(); } else if (t > 1.0) { return this.b.copy(); } // Re...
javascript
function(p) { var v = this.b.sub(this.a); var t = p.sub(this.a).dot(v) / v.magSquared(); // Check to see if t is beyond the extents of the line segment if (t < 0.0) { return this.a.copy(); } else if (t > 1.0) { return this.b.copy(); } // Re...
[ "function", "(", "p", ")", "{", "var", "v", "=", "this", ".", "b", ".", "sub", "(", "this", ".", "a", ")", ";", "var", "t", "=", "p", ".", "sub", "(", "this", ".", "a", ")", ".", "dot", "(", "v", ")", "/", "v", ".", "magSquared", "(", "...
Computes the closest point on this line to the given one. @param p point to check against @return closest point on the line
[ "Computes", "the", "closest", "point", "on", "this", "line", "to", "the", "given", "one", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Line3D.js#L62-L73
train
hapticdata/toxiclibsjs
lib/toxi/THREE/ToxiclibsSupport.js
function(obj_or_mesh,threeMaterials){ var toxiTriangleMesh; if(arguments.length == 1){ //it needs to be an param object toxiTriangleMesh = obj_or_mesh.geometry; threeMaterials = obj_or_mesh.materials; } else { toxiTriangleMesh = obj_or_...
javascript
function(obj_or_mesh,threeMaterials){ var toxiTriangleMesh; if(arguments.length == 1){ //it needs to be an param object toxiTriangleMesh = obj_or_mesh.geometry; threeMaterials = obj_or_mesh.materials; } else { toxiTriangleMesh = obj_or_...
[ "function", "(", "obj_or_mesh", ",", "threeMaterials", ")", "{", "var", "toxiTriangleMesh", ";", "if", "(", "arguments", ".", "length", "==", "1", ")", "{", "//it needs to be an param object", "toxiTriangleMesh", "=", "obj_or_mesh", ".", "geometry", ";", "threeMat...
add a toxiclibs.js mesh to the three.js scene @param {Object|toxi.geom.mesh.TriangleMesh} obj_or_mesh either an options object or the toxiclibsjs mesh -- @param {toxi.geom.mesh.Trianglemesh} [obj_or_mesh.geometry] the mesh in the options object @param {THREE.Material} [obj_or_mesh.material] the three.js material for th...
[ "add", "a", "toxiclibs", ".", "js", "mesh", "to", "the", "three", ".", "js", "scene" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/THREE/ToxiclibsSupport.js#L104-L115
train
hapticdata/toxiclibsjs
lib/toxi/geom/Triangle2D.js
function(_p){ var v1 = _p.sub(this.a).normalize(), v2 = _p.sub(this.b).normalize(), v3 = _p.sub(this.c).normalize(), totalAngles = Math.acos(v1.dot(v2)); totalAngles += Math.acos(v2.dot(v3)); totalAngles += Math.acos(v3.dot(v1)); return (mathUtils.abs(totalAngles- mathUtils.TWO_PI) <= 0.01); }
javascript
function(_p){ var v1 = _p.sub(this.a).normalize(), v2 = _p.sub(this.b).normalize(), v3 = _p.sub(this.c).normalize(), totalAngles = Math.acos(v1.dot(v2)); totalAngles += Math.acos(v2.dot(v3)); totalAngles += Math.acos(v3.dot(v1)); return (mathUtils.abs(totalAngles- mathUtils.TWO_PI) <= 0.01); }
[ "function", "(", "_p", ")", "{", "var", "v1", "=", "_p", ".", "sub", "(", "this", ".", "a", ")", ".", "normalize", "(", ")", ",", "v2", "=", "_p", ".", "sub", "(", "this", ".", "b", ")", ".", "normalize", "(", ")", ",", "v3", "=", "_p", "...
Checks if point vector is inside the triangle created by the points a, b and c. These points will create a plane and the point checked will have to be on this plane in the region between a,b,c. Note: The triangle must be defined in clockwise order a,b,c @return true, if point is in triangle.
[ "Checks", "if", "point", "vector", "is", "inside", "the", "triangle", "created", "by", "the", "points", "a", "b", "and", "c", ".", "These", "points", "will", "create", "a", "plane", "and", "the", "point", "checked", "will", "have", "to", "be", "on", "t...
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Triangle2D.js#L70-L78
train
hapticdata/toxiclibsjs
lib/toxi/geom/ConvexPolygonClipper.js
function(list, q){ for(var i=0, l=list.length; i<l; i++){ if( list[i].equalsWitTolerance(q, 0.001) ){ return true; } } return false; }
javascript
function(list, q){ for(var i=0, l=list.length; i<l; i++){ if( list[i].equalsWitTolerance(q, 0.001) ){ return true; } } return false; }
[ "function", "(", "list", ",", "q", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "list", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "list", "[", "i", "]", ".", "equalsWitTolerance", "(", "q", ",", ...
unused but included to match, source
[ "unused", "but", "included", "to", "match", "source" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/ConvexPolygonClipper.js#L83-L90
train
hapticdata/toxiclibsjs
lib/toxi/processing/ToxiclibsSupport.js
function(iterator, shapeID, closed){ //if first param wasnt passed in as a pjs Iterator, make it one if(iterator.hasNext === undefined || iterator.next === undefined){ iterator = new this.app.ObjectIterator( iterator ); } this.gfx.beginShape(shapeID); for(var v = void(0); iterator.hasNext() && ((v = iter...
javascript
function(iterator, shapeID, closed){ //if first param wasnt passed in as a pjs Iterator, make it one if(iterator.hasNext === undefined || iterator.next === undefined){ iterator = new this.app.ObjectIterator( iterator ); } this.gfx.beginShape(shapeID); for(var v = void(0); iterator.hasNext() && ((v = iter...
[ "function", "(", "iterator", ",", "shapeID", ",", "closed", ")", "{", "//if first param wasnt passed in as a pjs Iterator, make it one", "if", "(", "iterator", ".", "hasNext", "===", "undefined", "||", "iterator", ".", "next", "===", "undefined", ")", "{", "iterator...
Processes the 2D vertices from a Processing.js Iterator object @params {Iterator} iterator @params {Number} shapeID @params {Boolean} closed
[ "Processes", "the", "2D", "vertices", "from", "a", "Processing", ".", "js", "Iterator", "object" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/processing/ToxiclibsSupport.js#L314-L334
train
hapticdata/toxiclibsjs
lib/toxi/processing/ToxiclibsSupport.js
function(tri,isFullShape){ var isTriangle = function(){ if(tri.a !== undefined && tri.b !== undefined && tri.c !== undefined){ return (tri.a.x !== undefined); } return false; }, isTriangle3D = function(){ if(isTriangle()){ return (tri.a.z !== undefined); } return false; }; if(isFul...
javascript
function(tri,isFullShape){ var isTriangle = function(){ if(tri.a !== undefined && tri.b !== undefined && tri.c !== undefined){ return (tri.a.x !== undefined); } return false; }, isTriangle3D = function(){ if(isTriangle()){ return (tri.a.z !== undefined); } return false; }; if(isFul...
[ "function", "(", "tri", ",", "isFullShape", ")", "{", "var", "isTriangle", "=", "function", "(", ")", "{", "if", "(", "tri", ".", "a", "!==", "undefined", "&&", "tri", ".", "b", "!==", "undefined", "&&", "tri", ".", "c", "!==", "undefined", ")", "{...
works for Triangle3D or Triangle2D
[ "works", "for", "Triangle3D", "or", "Triangle2D" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/processing/ToxiclibsSupport.js#L441-L473
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(a,b) { if( hasXY( a ) && hasXY( b ) ){ this.x = mathUtils.clip(this.x, a.x, b.x); this.y = mathUtils.clip(this.y, a.y, b.y); } else if( isRect( a ) ){ this.x = mathUtils.clip(this.x, a.x, a.x + a.width); this.y = mathUtils.clip(this.y, a.y, a.y + a.height); } return this; }
javascript
function(a,b) { if( hasXY( a ) && hasXY( b ) ){ this.x = mathUtils.clip(this.x, a.x, b.x); this.y = mathUtils.clip(this.y, a.y, b.y); } else if( isRect( a ) ){ this.x = mathUtils.clip(this.x, a.x, a.x + a.width); this.y = mathUtils.clip(this.y, a.y, a.y + a.height); } return this; }
[ "function", "(", "a", ",", "b", ")", "{", "if", "(", "hasXY", "(", "a", ")", "&&", "hasXY", "(", "b", ")", ")", "{", "this", ".", "x", "=", "mathUtils", ".", "clip", "(", "this", ".", "x", ",", "a", ".", "x", ",", "b", ".", "x", ")", ";...
Forcefully fits the vector in the given rectangle. @param a either a Rectangle by itself or the Vec2D min @param b Vec2D max @return itself
[ "Forcefully", "fits", "the", "vector", "in", "the", "given", "rectangle", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L133-L142
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function() { var mag = this.x * this.x + this.y * this.y; if (mag > 0) { mag = 1.0 / Math.sqrt(mag); this.x *= mag; this.y *= mag; } return this; }
javascript
function() { var mag = this.x * this.x + this.y * this.y; if (mag > 0) { mag = 1.0 / Math.sqrt(mag); this.x *= mag; this.y *= mag; } return this; }
[ "function", "(", ")", "{", "var", "mag", "=", "this", ".", "x", "*", "this", ".", "x", "+", "this", ".", "y", "*", "this", ".", "y", ";", "if", "(", "mag", ">", "0", ")", "{", "mag", "=", "1.0", "/", "Math", ".", "sqrt", "(", "mag", ")", ...
Normalizes the vector so that its magnitude = 1 @return itself
[ "Normalizes", "the", "vector", "so", "that", "its", "magnitude", "=", "1" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L419-L427
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(theta) { var co = Math.cos(theta); var si = Math.sin(theta); var xx = co * this.x - si * this.y; this.y = si * this.x + co * this.y; this.x = xx; return this; }
javascript
function(theta) { var co = Math.cos(theta); var si = Math.sin(theta); var xx = co * this.x - si * this.y; this.y = si * this.x + co * this.y; this.x = xx; return this; }
[ "function", "(", "theta", ")", "{", "var", "co", "=", "Math", ".", "cos", "(", "theta", ")", ";", "var", "si", "=", "Math", ".", "sin", "(", "theta", ")", ";", "var", "xx", "=", "co", "*", "this", ".", "x", "-", "si", "*", "this", ".", "y",...
Rotates the vector by the given angle around the Z axis. @param theta @return itself
[ "Rotates", "the", "vector", "by", "the", "given", "angle", "around", "the", "Z", "axis", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L477-L484
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(box_or_min, max){ var min; if( is.AABB( box_or_min ) ){ max = box_or_min.getMax(); min = box_or_min.getMin(); } else { min = box_or_min; } this.x = mathUtils.clip(this.x, min.x, max.x); this.y = mathUtils.clip(this.y, min.y, max.y); this.z = mathUtils.clip(this.z, min.z, max.z)...
javascript
function(box_or_min, max){ var min; if( is.AABB( box_or_min ) ){ max = box_or_min.getMax(); min = box_or_min.getMin(); } else { min = box_or_min; } this.x = mathUtils.clip(this.x, min.x, max.x); this.y = mathUtils.clip(this.y, min.y, max.y); this.z = mathUtils.clip(this.z, min.z, max.z)...
[ "function", "(", "box_or_min", ",", "max", ")", "{", "var", "min", ";", "if", "(", "is", ".", "AABB", "(", "box_or_min", ")", ")", "{", "max", "=", "box_or_min", ".", "getMax", "(", ")", ";", "min", "=", "box_or_min", ".", "getMin", "(", ")", ";"...
Forcefully fits the vector in the given AABB specified by the 2 given points. @param box_or_min either the AABB box by itself, or your min Vec3D with accompanying max @param max @return itself
[ "Forcefully", "fits", "the", "vector", "in", "the", "given", "AABB", "specified", "by", "the", "2", "given", "points", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L740-L752
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(vec){ var cx = this.y * vec.z - vec.y * this.z; var cy = this.z * vec.x - vec.z * this.x; this.z = this.x * vec.y - vec.x * this.y; this.y = cy; this.x = cx; return this; }
javascript
function(vec){ var cx = this.y * vec.z - vec.y * this.z; var cy = this.z * vec.x - vec.z * this.x; this.z = this.x * vec.y - vec.x * this.y; this.y = cy; this.x = cx; return this; }
[ "function", "(", "vec", ")", "{", "var", "cx", "=", "this", ".", "y", "*", "vec", ".", "z", "-", "vec", ".", "y", "*", "this", ".", "z", ";", "var", "cy", "=", "this", ".", "z", "*", "vec", ".", "x", "-", "vec", ".", "z", "*", "this", "...
Calculates cross-product with vector v. The resulting vector is perpendicular to both the current and supplied vector and overrides the current. @param v the v @return itself
[ "Calculates", "cross", "-", "product", "with", "vector", "v", ".", "The", "resulting", "vector", "is", "perpendicular", "to", "both", "the", "current", "and", "supplied", "vector", "and", "overrides", "the", "current", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L781-L788
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(vec_axis,theta){ var ax = vec_axis.x, ay = vec_axis.y, az = vec_axis.z, ux = ax * this.x, uy = ax * this.y, uz = ax * this.z, vx = ay * this.x, vy = ay * this.y, vz = ay * this.z, wx = az * this.x, wy = az * this.y, wz = az * this.z, si = Math.sin(theta), ...
javascript
function(vec_axis,theta){ var ax = vec_axis.x, ay = vec_axis.y, az = vec_axis.z, ux = ax * this.x, uy = ax * this.y, uz = ax * this.z, vx = ay * this.x, vy = ay * this.y, vz = ay * this.z, wx = az * this.x, wy = az * this.y, wz = az * this.z, si = Math.sin(theta), ...
[ "function", "(", "vec_axis", ",", "theta", ")", "{", "var", "ax", "=", "vec_axis", ".", "x", ",", "ay", "=", "vec_axis", ".", "y", ",", "az", "=", "vec_axis", ".", "z", ",", "ux", "=", "ax", "*", "this", ".", "x", ",", "uy", "=", "ax", "*", ...
Rotates the vector around the giving axis. @param axis rotation axis vector @param theta rotation angle (in radians) @return itself
[ "Rotates", "the", "vector", "around", "the", "giving", "axis", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L1133-L1155
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function(theta){ var co = Math.cos(theta); var si = Math.sin(theta); var zz = co *this.z - si * this.y; this.y = si * this.z + co * this.y; this.z = zz; return this; }
javascript
function(theta){ var co = Math.cos(theta); var si = Math.sin(theta); var zz = co *this.z - si * this.y; this.y = si * this.z + co * this.y; this.z = zz; return this; }
[ "function", "(", "theta", ")", "{", "var", "co", "=", "Math", ".", "cos", "(", "theta", ")", ";", "var", "si", "=", "Math", ".", "sin", "(", "theta", ")", ";", "var", "zz", "=", "co", "*", "this", ".", "z", "-", "si", "*", "this", ".", "y",...
Rotates the vector by the given angle around the X axis. @param theta the theta @return itself
[ "Rotates", "the", "vector", "by", "the", "given", "angle", "around", "the", "X", "axis", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L1164-L1171
train
hapticdata/toxiclibsjs
lib/toxi/geom/vectors.js
function() { if (Math.abs(this.x) < 0.5) { this.x = 0; } else { this.x = this.x < 0 ? -1 : 1; this.y = this.z = 0; } if (Math.abs(this.y) < 0.5) { this.y = 0; } else { this.y = this.y < 0 ? -1 : 1; this.x = this.z = 0; } if (Math.abs(this.z) < 0.5) { this.z = 0; } els...
javascript
function() { if (Math.abs(this.x) < 0.5) { this.x = 0; } else { this.x = this.x < 0 ? -1 : 1; this.y = this.z = 0; } if (Math.abs(this.y) < 0.5) { this.y = 0; } else { this.y = this.y < 0 ? -1 : 1; this.x = this.z = 0; } if (Math.abs(this.z) < 0.5) { this.z = 0; } els...
[ "function", "(", ")", "{", "if", "(", "Math", ".", "abs", "(", "this", ".", "x", ")", "<", "0.5", ")", "{", "this", ".", "x", "=", "0", ";", "}", "else", "{", "this", ".", "x", "=", "this", ".", "x", "<", "0", "?", "-", "1", ":", "1", ...
Rounds the vector to the closest major axis. Assumes the vector is normalized. @return itself
[ "Rounds", "the", "vector", "to", "the", "closest", "major", "axis", ".", "Assumes", "the", "vector", "is", "normalized", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/vectors.js#L1212-L1232
train
hapticdata/toxiclibsjs
lib/toxi/color/ToneMap.js
function( t ){ var idx; if( this.colors.size() > 2 ){ idx = Math.floor( this.map.getClippedValueFor(t) + 0.5 ); } else { idx = t >= this.map.getInputMedian() ? 1 : 0; } return this.colors.get(idx); }
javascript
function( t ){ var idx; if( this.colors.size() > 2 ){ idx = Math.floor( this.map.getClippedValueFor(t) + 0.5 ); } else { idx = t >= this.map.getInputMedian() ? 1 : 0; } return this.colors.get(idx); }
[ "function", "(", "t", ")", "{", "var", "idx", ";", "if", "(", "this", ".", "colors", ".", "size", "(", ")", ">", "2", ")", "{", "idx", "=", "Math", ".", "floor", "(", "this", ".", "map", ".", "getClippedValueFor", "(", "t", ")", "+", "0.5", "...
get a color from a tonal value @param {Number} t @return {toxi.color.TColor}
[ "get", "a", "color", "from", "a", "tonal", "value" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ToneMap.js#L63-L71
train
hapticdata/toxiclibsjs
lib/toxi/color/ToneMap.js
function( src, pixels, offset ){ if( typeof offset !== 'number'){ offset = 0; } else if ( offset < 0 ){ throw new Error("offset into target pixel array is negative"); } pixels = pixels || new Array(src.length); for(var i=0, l=sr...
javascript
function( src, pixels, offset ){ if( typeof offset !== 'number'){ offset = 0; } else if ( offset < 0 ){ throw new Error("offset into target pixel array is negative"); } pixels = pixels || new Array(src.length); for(var i=0, l=sr...
[ "function", "(", "src", ",", "pixels", ",", "offset", ")", "{", "if", "(", "typeof", "offset", "!==", "'number'", ")", "{", "offset", "=", "0", ";", "}", "else", "if", "(", "offset", "<", "0", ")", "{", "throw", "new", "Error", "(", "\"offset into ...
Applies the tonemap to all elements in the given source array of values and places the resulting ARGB color in the corresponding index of the target pixel buffer. If the target buffer is null, a new one will be created automatically. @param {Array<Number>}src source array of values to be tone mapped @param {Array<Numb...
[ "Applies", "the", "tonemap", "to", "all", "elements", "in", "the", "given", "source", "array", "of", "values", "and", "places", "the", "resulting", "ARGB", "color", "in", "the", "corresponding", "index", "of", "the", "target", "pixel", "buffer", ".", "If", ...
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ToneMap.js#L84-L95
train
hapticdata/toxiclibsjs
lib/toxi/geom/SutherlandHodgemanClipper.js
function( list, q ){ for( var i=0, l=list.length; i<l; i++){ if( list[i].equalsWithTolerance(q, 0.0001) ){ return true; } } return false; }
javascript
function( list, q ){ for( var i=0, l=list.length; i<l; i++){ if( list[i].equalsWithTolerance(q, 0.0001) ){ return true; } } return false; }
[ "function", "(", "list", ",", "q", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "list", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "list", "[", "i", "]", ".", "equalsWithTolerance", "(", "q", ",", ...
protected + unused in java
[ "protected", "+", "unused", "in", "java" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/SutherlandHodgemanClipper.js#L127-L134
train
hapticdata/toxiclibsjs
lib/toxi/math/waves/AbstractWave.js
function(freq){ if(freq === undefined)freq = 0; this.phase = (this.phase + freq) % AbstractWave.TWO_PI; if(this.phase < 0){ this.phase += AbstractWave.TWO_PI; } return this.phase; }
javascript
function(freq){ if(freq === undefined)freq = 0; this.phase = (this.phase + freq) % AbstractWave.TWO_PI; if(this.phase < 0){ this.phase += AbstractWave.TWO_PI; } return this.phase; }
[ "function", "(", "freq", ")", "{", "if", "(", "freq", "===", "undefined", ")", "freq", "=", "0", ";", "this", ".", "phase", "=", "(", "this", ".", "phase", "+", "freq", ")", "%", "AbstractWave", ".", "TWO_PI", ";", "if", "(", "this", ".", "phase"...
Ensures phase remains in the 0...TWO_PI interval. @param {Number} freq normalized progress frequency @return {Number} current phase
[ "Ensures", "phase", "remains", "in", "the", "0", "...", "TWO_PI", "interval", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/math/waves/AbstractWave.js#L39-L46
train
hapticdata/toxiclibsjs
examples/js/three.js
paramThreeToGL
function paramThreeToGL ( p ) { if ( p === THREE.RepeatWrapping ) return _gl.REPEAT; if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE; if ( p === THREE.MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT; if ( p === THREE.NearestFilter ) return _gl.NEAREST; if ( p === THREE.NearestMipMapNeare...
javascript
function paramThreeToGL ( p ) { if ( p === THREE.RepeatWrapping ) return _gl.REPEAT; if ( p === THREE.ClampToEdgeWrapping ) return _gl.CLAMP_TO_EDGE; if ( p === THREE.MirroredRepeatWrapping ) return _gl.MIRRORED_REPEAT; if ( p === THREE.NearestFilter ) return _gl.NEAREST; if ( p === THREE.NearestMipMapNeare...
[ "function", "paramThreeToGL", "(", "p", ")", "{", "if", "(", "p", "===", "THREE", ".", "RepeatWrapping", ")", "return", "_gl", ".", "REPEAT", ";", "if", "(", "p", "===", "THREE", ".", "ClampToEdgeWrapping", ")", "return", "_gl", ".", "CLAMP_TO_EDGE", ";"...
Map three.js constants to WebGL constants
[ "Map", "three", ".", "js", "constants", "to", "WebGL", "constants" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/examples/js/three.js#L21255-L21306
train
hapticdata/toxiclibsjs
examples/js/three.js
prepare
function prepare( vector ) { var vertex = vector.normalize().clone(); vertex.index = that.vertices.push( vertex ) - 1; // Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle. var u = azimuth( vector ) / 2 / Math.PI + 0.5; var v = inclination( vector ) / Math.PI ...
javascript
function prepare( vector ) { var vertex = vector.normalize().clone(); vertex.index = that.vertices.push( vertex ) - 1; // Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle. var u = azimuth( vector ) / 2 / Math.PI + 0.5; var v = inclination( vector ) / Math.PI ...
[ "function", "prepare", "(", "vector", ")", "{", "var", "vertex", "=", "vector", ".", "normalize", "(", ")", ".", "clone", "(", ")", ";", "vertex", ".", "index", "=", "that", ".", "vertices", ".", "push", "(", "vertex", ")", "-", "1", ";", "// Textu...
Project vector onto sphere's surface
[ "Project", "vector", "onto", "sphere", "s", "surface" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/examples/js/three.js#L31817-L31830
train
hapticdata/toxiclibsjs
examples/js/three.js
visible
function visible( face, vertex ) { var va = vertices[ face[ 0 ] ]; var vb = vertices[ face[ 1 ] ]; var vc = vertices[ face[ 2 ] ]; var n = normal( va, vb, vc ); // distance from face to origin var dist = n.dot( va ); return n.dot( vertex ) >= dist; }
javascript
function visible( face, vertex ) { var va = vertices[ face[ 0 ] ]; var vb = vertices[ face[ 1 ] ]; var vc = vertices[ face[ 2 ] ]; var n = normal( va, vb, vc ); // distance from face to origin var dist = n.dot( va ); return n.dot( vertex ) >= dist; }
[ "function", "visible", "(", "face", ",", "vertex", ")", "{", "var", "va", "=", "vertices", "[", "face", "[", "0", "]", "]", ";", "var", "vb", "=", "vertices", "[", "face", "[", "1", "]", "]", ";", "var", "vc", "=", "vertices", "[", "face", "[",...
Whether the face is visible from the vertex
[ "Whether", "the", "face", "is", "visible", "from", "the", "vertex" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/examples/js/three.js#L32177-L32190
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/VertexSelector.js
function() { var newSel = []; var vertices = this.mesh.getVertices(); var l = vertices.length; for (var i=0;i<l;i++) { var v = vertices[i]; if (this.selection.indexOf(v) < 0 ) { newSel.push(v); } } this.selection = newSel; ...
javascript
function() { var newSel = []; var vertices = this.mesh.getVertices(); var l = vertices.length; for (var i=0;i<l;i++) { var v = vertices[i]; if (this.selection.indexOf(v) < 0 ) { newSel.push(v); } } this.selection = newSel; ...
[ "function", "(", ")", "{", "var", "newSel", "=", "[", "]", ";", "var", "vertices", "=", "this", ".", "mesh", ".", "getVertices", "(", ")", ";", "var", "l", "=", "vertices", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", ...
Creates a new selection of all vertices NOT currently selected. @return itself
[ "Creates", "a", "new", "selection", "of", "all", "vertices", "NOT", "currently", "selected", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/VertexSelector.js#L50-L62
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/VertexSelector.js
function(points) { var l = points.length; for (var i=0;i<l;i++) { var v = points[i]; this.selection.push( this.mesh.getClosestVertexToPoint(v) ); } return this; }
javascript
function(points) { var l = points.length; for (var i=0;i<l;i++) { var v = points[i]; this.selection.push( this.mesh.getClosestVertexToPoint(v) ); } return this; }
[ "function", "(", "points", ")", "{", "var", "l", "=", "points", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "v", "=", "points", "[", "i", "]", ";", "this", ".", "selection", "."...
Selects vertices identical or closest to the ones given in the list of points. @param points @return itself
[ "Selects", "vertices", "identical", "or", "closest", "to", "the", "ones", "given", "in", "the", "list", "of", "points", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/VertexSelector.js#L70-L77
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/VertexSelector.js
function(sel2) { this.checkMeshIdentity(sel2.getMesh()); var removeThese = sel2.getSelection(); var i,l = removeThese.length; for ( i=0; i<l; i++ ) { this.selection.splice( this.selection.indexOf(removeThese[i]), 1 ); } return this; }
javascript
function(sel2) { this.checkMeshIdentity(sel2.getMesh()); var removeThese = sel2.getSelection(); var i,l = removeThese.length; for ( i=0; i<l; i++ ) { this.selection.splice( this.selection.indexOf(removeThese[i]), 1 ); } return this; }
[ "function", "(", "sel2", ")", "{", "this", ".", "checkMeshIdentity", "(", "sel2", ".", "getMesh", "(", ")", ")", ";", "var", "removeThese", "=", "sel2", ".", "getSelection", "(", ")", ";", "var", "i", ",", "l", "=", "removeThese", ".", "length", ";",...
Removes all vertices selected by the given selector from the current selection. The other selector needs to be assigned to the same mesh instance. @param sel2 other selector @return itself
[ "Removes", "all", "vertices", "selected", "by", "the", "given", "selector", "from", "the", "current", "selection", ".", "The", "other", "selector", "needs", "to", "be", "assigned", "to", "the", "same", "mesh", "instance", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/VertexSelector.js#L103-L111
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorRange.js
function( rc ){ if( is.ColorRange(rc) ){ addAll(this.hueConstraint, rc.hueConstraint); addAll(this.saturationConstraint, rc.saturationConstraint); addAll(this.brightnessConstraint, rc.brightnessConstraint); addAll(this.alphaConstraint, rc.alpha...
javascript
function( rc ){ if( is.ColorRange(rc) ){ addAll(this.hueConstraint, rc.hueConstraint); addAll(this.saturationConstraint, rc.saturationConstraint); addAll(this.brightnessConstraint, rc.brightnessConstraint); addAll(this.alphaConstraint, rc.alpha...
[ "function", "(", "rc", ")", "{", "if", "(", "is", ".", "ColorRange", "(", "rc", ")", ")", "{", "addAll", "(", "this", ".", "hueConstraint", ",", "rc", ".", "hueConstraint", ")", ";", "addAll", "(", "this", ".", "saturationConstraint", ",", "rc", ".",...
Adds the HSV color components as constraints @param {toxi.color.ColorRange | toxi.color.TColor} rc @return itself
[ "Adds", "the", "HSV", "color", "components", "as", "constraints" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorRange.js#L135-L152
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorRange.js
function( c ){ var isInRange = this.isValueInConstraint(c.hue(), this.hueConstraint); isInRange &= this.isValueInConstraint(c.saturation(), this.saturationConstraint); isInRange &= this.isValueInConstraint(c.brightness(), this.brightnessConstraint); isInRange &= this.isVa...
javascript
function( c ){ var isInRange = this.isValueInConstraint(c.hue(), this.hueConstraint); isInRange &= this.isValueInConstraint(c.saturation(), this.saturationConstraint); isInRange &= this.isValueInConstraint(c.brightness(), this.brightnessConstraint); isInRange &= this.isVa...
[ "function", "(", "c", ")", "{", "var", "isInRange", "=", "this", ".", "isValueInConstraint", "(", "c", ".", "hue", "(", ")", ",", "this", ".", "hueConstraint", ")", ";", "isInRange", "&=", "this", ".", "isValueInConstraint", "(", "c", ".", "saturation", ...
checks if all HSVA components of the given color are within the constraints define for this range @param {toxi.color.TColor} c @return true if is contained
[ "checks", "if", "all", "HSVA", "components", "of", "the", "given", "color", "are", "within", "the", "constraints", "define", "for", "this", "range" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorRange.js#L173-L179
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorRange.js
function( c, num, variance ){ if( arguments.length < 3 ){ variance = ColorRange.DEFAULT_VARIANCE; } if( arguments.length === 1 ){ num = c; c = undefined; } var list = new ColorList(); for( var i=0; i<...
javascript
function( c, num, variance ){ if( arguments.length < 3 ){ variance = ColorRange.DEFAULT_VARIANCE; } if( arguments.length === 1 ){ num = c; c = undefined; } var list = new ColorList(); for( var i=0; i<...
[ "function", "(", "c", ",", "num", ",", "variance", ")", "{", "if", "(", "arguments", ".", "length", "<", "3", ")", "{", "variance", "=", "ColorRange", ".", "DEFAULT_VARIANCE", ";", "}", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "...
creates a new `toxi.color.ColorList` of colors based on constraints of this range 1. @param {Number} num integer of how many colors to get 2. @param {toxi.color.TColor} c @param {Number} num @param {Number} variance @return {toxi.color.ColorList} list
[ "creates", "a", "new", "toxi", ".", "color", ".", "ColorList", "of", "colors", "based", "on", "constraints", "of", "this", "range", "1", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorRange.js#L261-L274
train
hapticdata/toxiclibsjs
lib/toxi/util/datatypes/FloatRange.js
function(min, max){ min = min || 0.0; max = typeof max === 'number' ? max : 1.0; // swap if necessary if(min > max){ var t= max; max = min; min = t; } this.min = min; this.max = max; this.currValue = min; }
javascript
function(min, max){ min = min || 0.0; max = typeof max === 'number' ? max : 1.0; // swap if necessary if(min > max){ var t= max; max = min; min = t; } this.min = min; this.max = max; this.currValue = min; }
[ "function", "(", "min", ",", "max", ")", "{", "min", "=", "min", "||", "0.0", ";", "max", "=", "typeof", "max", "===", "'number'", "?", "max", ":", "1.0", ";", "// swap if necessary", "if", "(", "min", ">", "max", ")", "{", "var", "t", "=", "max"...
construct a new `FloatRange` provides utilities for dealing with a range of Numbers. @param {Number} [min=0] the minimum in the range @param {Number} [max=1.0] the maximum in the range @constructor
[ "construct", "a", "new", "FloatRange", "provides", "utilities", "for", "dealing", "with", "a", "range", "of", "Numbers", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/util/datatypes/FloatRange.js#L12-L24
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(a,b,c,n,uvA,uvB,uvC){ //can be 3 args, 4 args, 6 args, or 7 args //if it was 6 swap vars around, if( arguments.length == 6 ){ uvC = uvB; uvB = uvA; uvA = n; n = undefined; } //7 param method var va = this.__checkVertex(a); var vb = this.__checkVertex(b); var ...
javascript
function(a,b,c,n,uvA,uvB,uvC){ //can be 3 args, 4 args, 6 args, or 7 args //if it was 6 swap vars around, if( arguments.length == 6 ){ uvC = uvB; uvB = uvA; uvA = n; n = undefined; } //7 param method var va = this.__checkVertex(a); var vb = this.__checkVertex(b); var ...
[ "function", "(", "a", ",", "b", ",", "c", ",", "n", ",", "uvA", ",", "uvB", ",", "uvC", ")", "{", "//can be 3 args, 4 args, 6 args, or 7 args", "//if it was 6 swap vars around,", "if", "(", "arguments", ".", "length", "==", "6", ")", "{", "uvC", "=", "uvB"...
add a Face to the mesh @param {Vec3D} a @param {Vec3D} b @param {Vec3D} c @param {Vec3D} [n] the normal @param {Vec2D} [uvA] @param {Vec2D} [uvB] @param {Vec2D} [uvC] @returns itself
[ "add", "a", "Face", "to", "the", "mesh" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L64-L93
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(m){ var l = m.getFaces().length; for(var i=0;i<l;i++){ var f = m.getFaces()[i]; this.addFace(f.a,f.b,f.c); } return this; }
javascript
function(m){ var l = m.getFaces().length; for(var i=0;i<l;i++){ var f = m.getFaces()[i]; this.addFace(f.a,f.b,f.c); } return this; }
[ "function", "(", "m", ")", "{", "var", "l", "=", "m", ".", "getFaces", "(", ")", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "f", "=", "m", ".", "getFaces", "(", ")", "[", "...
add the contents of a TriangleMesh to this TriangleMesh @param {TriangleMesh} m @returns itself
[ "add", "the", "contents", "of", "a", "TriangleMesh", "to", "this", "TriangleMesh" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L100-L107
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(array) { array = array || []; var i = 0; var l = this.vertices.length; for (var j=0;j<l;j++) { var v = this.vertices[j]; array[i++] = v.x; array[i++] = v.y; array[i++] = v.z; } return array; }
javascript
function(array) { array = array || []; var i = 0; var l = this.vertices.length; for (var j=0;j<l;j++) { var v = this.vertices[j]; array[i++] = v.x; array[i++] = v.y; array[i++] = v.z; } return array; }
[ "function", "(", "array", ")", "{", "array", "=", "array", "||", "[", "]", ";", "var", "i", "=", "0", ";", "var", "l", "=", "this", ".", "vertices", ".", "length", ";", "for", "(", "var", "j", "=", "0", ";", "j", "<", "l", ";", "j", "++", ...
flatten each vertex once into an array, useful for OpenGL attributes @param {Array|Float32Array} [array] optionally pass in an array or typed-array to reuse @return {Array|Float32Array}
[ "flatten", "each", "vertex", "once", "into", "an", "array", "useful", "for", "OpenGL", "attributes" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L472-L483
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(array){ array = array || []; var n = 0; for(i=0; i<this.vertices.length; i++){ var v = this.vertices[i]; array[n++] = v.normal.x; array[n++] = v.normal.y; array[n++] = v.normal.z; ...
javascript
function(array){ array = array || []; var n = 0; for(i=0; i<this.vertices.length; i++){ var v = this.vertices[i]; array[n++] = v.normal.x; array[n++] = v.normal.y; array[n++] = v.normal.z; ...
[ "function", "(", "array", ")", "{", "array", "=", "array", "||", "[", "]", ";", "var", "n", "=", "0", ";", "for", "(", "i", "=", "0", ";", "i", "<", "this", ".", "vertices", ".", "length", ";", "i", "++", ")", "{", "var", "v", "=", "this", ...
flatten each vertex normal once into an array, useful for OpenGL attributes @param {Array|Float32Array} [array] optionally pass in an array or typed-array to reuse @return {Array|Float32Array}
[ "flatten", "each", "vertex", "normal", "once", "into", "an", "array", "useful", "for", "OpenGL", "attributes" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L490-L501
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(array){ array = array || []; var i = 0; for(f=0; f<this.faces.length; f++){ var face = this.faces[f]; array[i++] = face.uvA ? face.uvA.x : 0; array[i++] = face.uvA ? face.uvA.y : 0; a...
javascript
function(array){ array = array || []; var i = 0; for(f=0; f<this.faces.length; f++){ var face = this.faces[f]; array[i++] = face.uvA ? face.uvA.x : 0; array[i++] = face.uvA ? face.uvA.y : 0; a...
[ "function", "(", "array", ")", "{", "array", "=", "array", "||", "[", "]", ";", "var", "i", "=", "0", ";", "for", "(", "f", "=", "0", ";", "f", "<", "this", ".", "faces", ".", "length", ";", "f", "++", ")", "{", "var", "face", "=", "this", ...
get the UVs of all faces in flattened array that is, usefl for OpenGL attributes any missing UV coordinates are returned as 0 @param {Array|Float32Array} [array] optionally pass in an array or typed-array to reuse @return {Array|Float32Array}
[ "get", "the", "UVs", "of", "all", "faces", "in", "flattened", "array", "that", "is", "usefl", "for", "OpenGL", "attributes", "any", "missing", "UV", "coordinates", "are", "returned", "as", "0" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L509-L523
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(vec) { var matchedVertex = -1; var l = this.vertices.length; for(var i=0;i<l;i++) { var vert = this.vertices[i]; if(vert.equals(vec)) { matchedVertex =i; } } return matchedVertex; }
javascript
function(vec) { var matchedVertex = -1; var l = this.vertices.length; for(var i=0;i<l;i++) { var vert = this.vertices[i]; if(vert.equals(vec)) { matchedVertex =i; } } return matchedVertex; }
[ "function", "(", "vec", ")", "{", "var", "matchedVertex", "=", "-", "1", ";", "var", "l", "=", "this", ".", "vertices", ".", "length", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "l", ";", "i", "++", ")", "{", "var", "vert", "=", ...
my own method to help
[ "my", "own", "method", "to", "help" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L535-L548
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(dir, forward) { forward = forward || Vec3D.Z_AXIS; return this.transform( Quaternion.getAlignmentQuat(dir, forward).toMatrix4x4(this.matrix), true); }
javascript
function(dir, forward) { forward = forward || Vec3D.Z_AXIS; return this.transform( Quaternion.getAlignmentQuat(dir, forward).toMatrix4x4(this.matrix), true); }
[ "function", "(", "dir", ",", "forward", ")", "{", "forward", "=", "forward", "||", "Vec3D", ".", "Z_AXIS", ";", "return", "this", ".", "transform", "(", "Quaternion", ".", "getAlignmentQuat", "(", "dir", ",", "forward", ")", ".", "toMatrix4x4", "(", "thi...
Rotates the mesh in such a way so that its "forward" axis is aligned with the given direction. This version uses the positive Z-axis as default forward direction. @param dir, new target direction to point in @param [forward], optional vector, defaults to Vec3D.Z_AXIS @return itself
[ "Rotates", "the", "mesh", "in", "such", "a", "way", "so", "that", "its", "forward", "axis", "is", "aligned", "with", "the", "given", "direction", ".", "This", "version", "uses", "the", "positive", "Z", "-", "axis", "as", "default", "forward", "direction", ...
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L680-L683
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(mat,updateNormals) { if(updateNormals === undefined){ updateNormals = true; } var l = this.vertices.length; for(var i=0;i<l;i++){ var v = this.vertices[i]; v.set(mat.applyTo(v)); } if(updateNormals){ this.computeFaceNormals(); } return this; }
javascript
function(mat,updateNormals) { if(updateNormals === undefined){ updateNormals = true; } var l = this.vertices.length; for(var i=0;i<l;i++){ var v = this.vertices[i]; v.set(mat.applyTo(v)); } if(updateNormals){ this.computeFaceNormals(); } return this; }
[ "function", "(", "mat", ",", "updateNormals", ")", "{", "if", "(", "updateNormals", "===", "undefined", ")", "{", "updateNormals", "=", "true", ";", "}", "var", "l", "=", "this", ".", "vertices", ".", "length", ";", "for", "(", "var", "i", "=", "0", ...
Applies the given matrix transform to all mesh vertices. If the updateNormals flag is true, all face normals are updated automatically, however vertex normals need a manual update. @param mat @param updateNormals @return itself
[ "Applies", "the", "given", "matrix", "transform", "to", "all", "mesh", "vertices", ".", "If", "the", "updateNormals", "flag", "is", "true", "all", "face", "normals", "are", "updated", "automatically", "however", "vertex", "normals", "need", "a", "manual", "upd...
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L778-L791
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(elevation){ if(this.__elevationLength == elevation.length){ for(var i = 0, len = elevation.length; i<len; i++){ this.vertices[i].y = this.elevation[i] = elevation[i]; } } else { throw new Error("the given elevation array size does not match terrain"); } return this; }
javascript
function(elevation){ if(this.__elevationLength == elevation.length){ for(var i = 0, len = elevation.length; i<len; i++){ this.vertices[i].y = this.elevation[i] = elevation[i]; } } else { throw new Error("the given elevation array size does not match terrain"); } return this; }
[ "function", "(", "elevation", ")", "{", "if", "(", "this", ".", "__elevationLength", "==", "elevation", ".", "length", ")", "{", "for", "(", "var", "i", "=", "0", ",", "len", "=", "elevation", ".", "length", ";", "i", "<", "len", ";", "i", "++", ...
Sets the elevation of all cells to those of the given array values. @param {Array} elevation array of height values @return itself
[ "Sets", "the", "elevation", "of", "all", "cells", "to", "those", "of", "the", "given", "array", "values", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L1315-L1324
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/meshCommon.js
function(x,z,h){ var index = this._getIndex(x,z); this.elevation[index] = h; this.vertices[index].y = h; return this; }
javascript
function(x,z,h){ var index = this._getIndex(x,z); this.elevation[index] = h; this.vertices[index].y = h; return this; }
[ "function", "(", "x", ",", "z", ",", "h", ")", "{", "var", "index", "=", "this", ".", "_getIndex", "(", "x", ",", "z", ")", ";", "this", ".", "elevation", "[", "index", "]", "=", "h", ";", "this", ".", "vertices", "[", "index", "]", ".", "y",...
Sets the elevation for a single given grid cell. @param {Number} x @param {Number} z @param {Number} h new elevation value @return itself
[ "Sets", "the", "elevation", "for", "a", "single", "given", "grid", "cell", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/meshCommon.js#L1332-L1337
train
hapticdata/toxiclibsjs
lib/toxi/color/theory/AnalagousStrategy.js
function( theta, contrast ){ this.contrast = typeof contrast === 'number' ? contrast : 0.25; this.theta = MathUtils.radians( typeof theta === 'number' ? theta : 10 ); }
javascript
function( theta, contrast ){ this.contrast = typeof contrast === 'number' ? contrast : 0.25; this.theta = MathUtils.radians( typeof theta === 'number' ? theta : 10 ); }
[ "function", "(", "theta", ",", "contrast", ")", "{", "this", ".", "contrast", "=", "typeof", "contrast", "===", "'number'", "?", "contrast", ":", "0.25", ";", "this", ".", "theta", "=", "MathUtils", ".", "radians", "(", "typeof", "theta", "===", "'number...
Creates a new instance @param {Number} [theta] optionally provide an angle in degrees, defaults to 10 @param {Number} [contrast] optionally provide a contrast, defaults to 0.25
[ "Creates", "a", "new", "instance" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/theory/AnalagousStrategy.js#L25-L28
train
hapticdata/toxiclibsjs
lib/toxi/geom/AxisAlignedCylinder.js
function(a,b,c) { var opts = { mesh: undefined, steps: 12, thetaOffset: 0 }; if(arguments.length == 1 && typeof arguments[0] == 'object'){ //options object for(var prop in arguments[0]){ opts[prop] = arguments[0][prop]; } } else if(arguments.length == 2){ opts.steps = arguments[0]; opts...
javascript
function(a,b,c) { var opts = { mesh: undefined, steps: 12, thetaOffset: 0 }; if(arguments.length == 1 && typeof arguments[0] == 'object'){ //options object for(var prop in arguments[0]){ opts[prop] = arguments[0][prop]; } } else if(arguments.length == 2){ opts.steps = arguments[0]; opts...
[ "function", "(", "a", ",", "b", ",", "c", ")", "{", "var", "opts", "=", "{", "mesh", ":", "undefined", ",", "steps", ":", "12", ",", "thetaOffset", ":", "0", "}", ";", "if", "(", "arguments", ".", "length", "==", "1", "&&", "typeof", "arguments",...
Builds a TriangleMesh representation of the cylinder at a default resolution 30 degrees. @return mesh instance
[ "Builds", "a", "TriangleMesh", "representation", "of", "the", "cylinder", "at", "a", "default", "resolution", "30", "degrees", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/AxisAlignedCylinder.js#L79-L95
train
hapticdata/toxiclibsjs
lib/toxi/math/SinCosLUT.js
function(theta) { while (theta < 0) { theta += mathUtils.TWO_PI; } return this.sinLUT[((theta * this.rad2deg) + this.quadrant) % this.period]; }
javascript
function(theta) { while (theta < 0) { theta += mathUtils.TWO_PI; } return this.sinLUT[((theta * this.rad2deg) + this.quadrant) % this.period]; }
[ "function", "(", "theta", ")", "{", "while", "(", "theta", "<", "0", ")", "{", "theta", "+=", "mathUtils", ".", "TWO_PI", ";", "}", "return", "this", ".", "sinLUT", "[", "(", "(", "theta", "*", "this", ".", "rad2deg", ")", "+", "this", ".", "quad...
Calculate cosine for the passed in angle in radians. @param theta @return cosine value for theta
[ "Calculate", "cosine", "for", "the", "passed", "in", "angle", "in", "radians", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/math/SinCosLUT.js#L37-L42
train
hapticdata/toxiclibsjs
lib/toxi/geom/LineStrip3D.js
function( x, y, z ){ if( hasXYZ( x ) ){ //it was 1 param, it was a vector or object this.vertices.push( new Vec3D(x) ); } else { this.vertices.push( new Vec3D(x,y,z) ); } return this; }
javascript
function( x, y, z ){ if( hasXYZ( x ) ){ //it was 1 param, it was a vector or object this.vertices.push( new Vec3D(x) ); } else { this.vertices.push( new Vec3D(x,y,z) ); } return this; }
[ "function", "(", "x", ",", "y", ",", "z", ")", "{", "if", "(", "hasXYZ", "(", "x", ")", ")", "{", "//it was 1 param, it was a vector or object", "this", ".", "vertices", ".", "push", "(", "new", "Vec3D", "(", "x", ")", ")", ";", "}", "else", "{", "...
add a vector to the line-strip, it will always be a copy @param {Vec3D | Number } x either a Vec3D or an x coordinate @param {Number} [y] @param {Number} [z] @return itself
[ "add", "a", "vector", "to", "the", "line", "-", "strip", "it", "will", "always", "be", "a", "copy" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/LineStrip3D.js#L34-L42
train
hapticdata/toxiclibsjs
lib/toxi/geom/LineStrip3D.js
function( step, doAddFinalVertex ){ if( doAddFinalVertex !== false ){ doAddFinalVertex = true; } var uniform = []; if( this.vertices.length < 3 ){ if( this.vertices.length === 2 ){ new Line3D( this.vertices[0], this.vertices[1]) .splitIntoSegments( uniform, step, true ); if( !doAddFi...
javascript
function( step, doAddFinalVertex ){ if( doAddFinalVertex !== false ){ doAddFinalVertex = true; } var uniform = []; if( this.vertices.length < 3 ){ if( this.vertices.length === 2 ){ new Line3D( this.vertices[0], this.vertices[1]) .splitIntoSegments( uniform, step, true ); if( !doAddFi...
[ "function", "(", "step", ",", "doAddFinalVertex", ")", "{", "if", "(", "doAddFinalVertex", "!==", "false", ")", "{", "doAddFinalVertex", "=", "true", ";", "}", "var", "uniform", "=", "[", "]", ";", "if", "(", "this", ".", "vertices", ".", "length", "<"...
Computes a list of points along the spline which are uniformly separated by the given step distance. @param {Number} step @param {Boolean} [doAddFinalVertex] true by default @return {Vec3D[]} point list
[ "Computes", "a", "list", "of", "points", "along", "the", "spline", "which", "are", "uniformly", "separated", "by", "the", "given", "step", "distance", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/LineStrip3D.js#L57-L98
train
hapticdata/toxiclibsjs
lib/toxi/geom/mesh/SphericalHarmonics.js
function(p,phi,theta) { var r = 0; r += Math.pow(mathUtils.sin(this.m[0] * theta), this.m[1]); r += Math.pow(mathUtils.cos(this.m[2] * theta), this.m[3]); r += Math.pow(mathUtils.sin(this.m[4] * phi), this.m[5]); r += Math.pow(mathUtils.cos(this.m[6] * phi), this.m[7]); ...
javascript
function(p,phi,theta) { var r = 0; r += Math.pow(mathUtils.sin(this.m[0] * theta), this.m[1]); r += Math.pow(mathUtils.cos(this.m[2] * theta), this.m[3]); r += Math.pow(mathUtils.sin(this.m[4] * phi), this.m[5]); r += Math.pow(mathUtils.cos(this.m[6] * phi), this.m[7]); ...
[ "function", "(", "p", ",", "phi", ",", "theta", ")", "{", "var", "r", "=", "0", ";", "r", "+=", "Math", ".", "pow", "(", "mathUtils", ".", "sin", "(", "this", ".", "m", "[", "0", "]", "*", "theta", ")", ",", "this", ".", "m", "[", "1", "]...
toxiclibs - FIXME check where flipped vertex order is coming from sometimes
[ "toxiclibs", "-", "FIXME", "check", "where", "flipped", "vertex", "order", "is", "coming", "from", "sometimes" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/mesh/SphericalHarmonics.js#L16-L28
train
hapticdata/toxiclibsjs
lib/toxi/color/TColor.js
function(h, s, v) { return this.setHSV([ this.hsv[0] + h, this.hsv[1] + s, this.hsv[2] + v ]); }
javascript
function(h, s, v) { return this.setHSV([ this.hsv[0] + h, this.hsv[1] + s, this.hsv[2] + v ]); }
[ "function", "(", "h", ",", "s", ",", "v", ")", "{", "return", "this", ".", "setHSV", "(", "[", "this", ".", "hsv", "[", "0", "]", "+", "h", ",", "this", ".", "hsv", "[", "1", "]", "+", "s", ",", "this", ".", "hsv", "[", "2", "]", "+", "...
Adds the given HSV values as offsets to the current color. Hue will automatically wrap. @param h @param s @param v @return itself
[ "Adds", "the", "given", "HSV", "values", "as", "offsets", "to", "the", "current", "color", ".", "Hue", "will", "automatically", "wrap", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/TColor.js#L83-L85
train
hapticdata/toxiclibsjs
lib/toxi/color/TColor.js
function(r, g,b) { return this.setRGB([this.rgb[0] + r, this.rgb[1] + g, this.rgb[2] + b]); }
javascript
function(r, g,b) { return this.setRGB([this.rgb[0] + r, this.rgb[1] + g, this.rgb[2] + b]); }
[ "function", "(", "r", ",", "g", ",", "b", ")", "{", "return", "this", ".", "setRGB", "(", "[", "this", ".", "rgb", "[", "0", "]", "+", "r", ",", "this", ".", "rgb", "[", "1", "]", "+", "g", ",", "this", ".", "rgb", "[", "2", "]", "+", "...
Adds the given RGB values as offsets to the current color. TColor will clip at black or white. @param r @param g @param b @return itself
[ "Adds", "the", "given", "RGB", "values", "as", "offsets", "to", "the", "current", "color", ".", "TColor", "will", "clip", "at", "black", "or", "white", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/TColor.js#L95-L97
train
hapticdata/toxiclibsjs
lib/toxi/color/TColor.js
function(c, t) { if(t === undefined) { t = 0.5; } var crgb = c.toRGBAArray(); this.rgb[0] += (crgb[0] - this.rgb[0]) * t; this.rgb[1] += (crgb[1] - this.rgb[1]) * t; this.rgb[2] += (crgb[2] - this.rgb[2]) * t; this._alpha += (c._alpha - this._alpha) * t; return this.setRGB(this.rgb); }
javascript
function(c, t) { if(t === undefined) { t = 0.5; } var crgb = c.toRGBAArray(); this.rgb[0] += (crgb[0] - this.rgb[0]) * t; this.rgb[1] += (crgb[1] - this.rgb[1]) * t; this.rgb[2] += (crgb[2] - this.rgb[2]) * t; this._alpha += (c._alpha - this._alpha) * t; return this.setRGB(this.rgb); }
[ "function", "(", "c", ",", "t", ")", "{", "if", "(", "t", "===", "undefined", ")", "{", "t", "=", "0.5", ";", "}", "var", "crgb", "=", "c", ".", "toRGBAArray", "(", ")", ";", "this", ".", "rgb", "[", "0", "]", "+=", "(", "crgb", "[", "0", ...
Blends the color with the given one by the stated amount @param c target color @param t interpolation factor @return itself
[ "Blends", "the", "color", "with", "the", "given", "one", "by", "the", "stated", "amount" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/TColor.js#L133-L141
train
hapticdata/toxiclibsjs
lib/toxi/color/TColor.js
function(rgba, offset) { rgba = rgba || []; offset = offset || 0; rgba[offset++] = this.rgb[0]; rgba[offset++] = this.rgb[1]; rgba[offset++] = this.rgb[2]; rgba[offset] = this._alpha; return rgba; }
javascript
function(rgba, offset) { rgba = rgba || []; offset = offset || 0; rgba[offset++] = this.rgb[0]; rgba[offset++] = this.rgb[1]; rgba[offset++] = this.rgb[2]; rgba[offset] = this._alpha; return rgba; }
[ "function", "(", "rgba", ",", "offset", ")", "{", "rgba", "=", "rgba", "||", "[", "]", ";", "offset", "=", "offset", "||", "0", ";", "rgba", "[", "offset", "++", "]", "=", "this", ".", "rgb", "[", "0", "]", ";", "rgba", "[", "offset", "++", "...
to an Array of RGBA values @param rgba @param offset (optional) @return rgba array
[ "to", "an", "Array", "of", "RGBA", "values" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/TColor.js#L584-L592
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorList.js
function(color){ for( var i=0, l= this.colors.length; i<l; i++){ if( this.colors[i].equals( color ) ){ return true; } } return false; }
javascript
function(color){ for( var i=0, l= this.colors.length; i<l; i++){ if( this.colors[i].equals( color ) ){ return true; } } return false; }
[ "function", "(", "color", ")", "{", "for", "(", "var", "i", "=", "0", ",", "l", "=", "this", ".", "colors", ".", "length", ";", "i", "<", "l", ";", "i", "++", ")", "{", "if", "(", "this", ".", "colors", "[", "i", "]", ".", "equals", "(", ...
Checks if the given color is part of the list. Check is done by value, not instance. @param color @return true, if the color is present.
[ "Checks", "if", "the", "given", "color", "is", "part", "of", "the", "list", ".", "Check", "is", "done", "by", "value", "not", "instance", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorList.js#L160-L167
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorList.js
function(){ var r = 0, g = 0, b = 0, a = 0; this.each(function(c){ r += c.rgb[0]; g += c.rgb[1]; b += c.rgb[2]; a += c.alpha(); }); var num = this.colors.length; if(num > 0){ return TColor.newRGBA(r / num, g / num, b / num, a / num); } return undefined; }
javascript
function(){ var r = 0, g = 0, b = 0, a = 0; this.each(function(c){ r += c.rgb[0]; g += c.rgb[1]; b += c.rgb[2]; a += c.alpha(); }); var num = this.colors.length; if(num > 0){ return TColor.newRGBA(r / num, g / num, b / num, a / num); } return undefined; }
[ "function", "(", ")", "{", "var", "r", "=", "0", ",", "g", "=", "0", ",", "b", "=", "0", ",", "a", "=", "0", ";", "this", ".", "each", "(", "function", "(", "c", ")", "{", "r", "+=", "c", ".", "rgb", "[", "0", "]", ";", "g", "+=", "c"...
Calculates and returns the average color of the list. @return average color or null, if there're no entries yet.
[ "Calculates", "and", "returns", "the", "average", "color", "of", "the", "list", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorList.js#L191-L209
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorList.js
function(){ var darkest, minBrightness = Number.MAX_VALUE; this.each(function(c){ var luma = c.luminance(); if(luma < minBrightness){ darkest = c; minBrightness = luma; } }); return darkest; }
javascript
function(){ var darkest, minBrightness = Number.MAX_VALUE; this.each(function(c){ var luma = c.luminance(); if(luma < minBrightness){ darkest = c; minBrightness = luma; } }); return darkest; }
[ "function", "(", ")", "{", "var", "darkest", ",", "minBrightness", "=", "Number", ".", "MAX_VALUE", ";", "this", ".", "each", "(", "function", "(", "c", ")", "{", "var", "luma", "=", "c", ".", "luminance", "(", ")", ";", "if", "(", "luma", "<", "...
Finds and returns the darkest color of the list. @return darkest color or null if there're no entries yet.
[ "Finds", "and", "returns", "the", "darkest", "color", "of", "the", "list", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorList.js#L231-L242
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorList.js
function(comp, isReversed){ //if a normal ( a, b ) sort function instead of an AccessCriteria, //wrap it so it can be invoked the same if( typeof comp === 'function' && typeof comp.compare === 'undefined' ){ comp = { compare: comp }; } this.colors.sort( comp.compare ); if...
javascript
function(comp, isReversed){ //if a normal ( a, b ) sort function instead of an AccessCriteria, //wrap it so it can be invoked the same if( typeof comp === 'function' && typeof comp.compare === 'undefined' ){ comp = { compare: comp }; } this.colors.sort( comp.compare ); if...
[ "function", "(", "comp", ",", "isReversed", ")", "{", "//if a normal ( a, b ) sort function instead of an AccessCriteria,", "//wrap it so it can be invoked the same", "if", "(", "typeof", "comp", "===", "'function'", "&&", "typeof", "comp", ".", "compare", "===", "'undefine...
Sorts the list using the given comparator. @param comp comparator @param isReversed true, if reversed sort @return itself
[ "Sorts", "the", "list", "using", "the", "given", "comparator", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorList.js#L313-L324
train
hapticdata/toxiclibsjs
lib/toxi/color/ColorList.js
function(proxy, isReversed){ if(arguments.length === 1){ isReversed = arguments[0]; proxy = new HSVDistanceProxy(); } if(this.colors.length === 0){ return this; } // Remove the darkest color from the stack, // put it in the sorted list as starting element. var root = this.getDarkest(), stack...
javascript
function(proxy, isReversed){ if(arguments.length === 1){ isReversed = arguments[0]; proxy = new HSVDistanceProxy(); } if(this.colors.length === 0){ return this; } // Remove the darkest color from the stack, // put it in the sorted list as starting element. var root = this.getDarkest(), stack...
[ "function", "(", "proxy", ",", "isReversed", ")", "{", "if", "(", "arguments", ".", "length", "===", "1", ")", "{", "isReversed", "=", "arguments", "[", "0", "]", ";", "proxy", "=", "new", "HSVDistanceProxy", "(", ")", ";", "}", "if", "(", "this", ...
Sorts the list by relative distance to each predecessor, starting with the darkest color in the list. @param {toxi.color.*{DistanceProxy}} proxy @param isReversed true, if list is to be sorted in reverse. @return itself
[ "Sorts", "the", "list", "by", "relative", "distance", "to", "each", "predecessor", "starting", "with", "the", "darkest", "color", "in", "the", "list", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/ColorList.js#L345-L391
train
hapticdata/toxiclibsjs
lib/toxi/math/noise/simplexNoise.js
function(g, x, y, z, w) { var n = g[0] * x + g[1] * y; if(z){ n += g[2] * z; if(w){ n += g[3] * w; } } return n; }
javascript
function(g, x, y, z, w) { var n = g[0] * x + g[1] * y; if(z){ n += g[2] * z; if(w){ n += g[3] * w; } } return n; }
[ "function", "(", "g", ",", "x", ",", "y", ",", "z", ",", "w", ")", "{", "var", "n", "=", "g", "[", "0", "]", "*", "x", "+", "g", "[", "1", "]", "*", "y", ";", "if", "(", "z", ")", "{", "n", "+=", "g", "[", "2", "]", "*", "z", ";",...
Computes dot product in 2D. @param g 2-vector (grid offset) @param {Number} x @param {Number} y @param {Number} z @param {Number} w @return {Number} dot product @api private
[ "Computes", "dot", "product", "in", "2D", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/math/noise/simplexNoise.js#L190-L199
train
hapticdata/toxiclibsjs
lib/toxi/color/accessors.js
make
function make( type, setters ){ var name = type + 'Accessor', arry = type.toLowerCase(); //make HSV hsv etc exports[name] = function( comp ){ this.component = comp; //compare() could easily be used in incorrect scope, bind it this.compare = bind( this.compare, this ); }; exports[name].prototype.compar...
javascript
function make( type, setters ){ var name = type + 'Accessor', arry = type.toLowerCase(); //make HSV hsv etc exports[name] = function( comp ){ this.component = comp; //compare() could easily be used in incorrect scope, bind it this.compare = bind( this.compare, this ); }; exports[name].prototype.compar...
[ "function", "make", "(", "type", ",", "setters", ")", "{", "var", "name", "=", "type", "+", "'Accessor'", ",", "arry", "=", "type", ".", "toLowerCase", "(", ")", ";", "//make HSV hsv etc", "exports", "[", "name", "]", "=", "function", "(", "comp", ")",...
this will attach proper exported objects for each accessor
[ "this", "will", "attach", "proper", "exported", "objects", "for", "each", "accessor" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/color/accessors.js#L7-L29
train
hapticdata/toxiclibsjs
lib/toxi/physics2d/constraints/AngularConstraint.js
function(theta_p,theta){ if(arguments.length > 1){ this.theta = theta; this.rootPos = new Vec2D(theta_p); } else { this.rootPos = new Vec2D(); this.theta = theta_p; } //due to lack-of int/float types, no support of theta in degrees }
javascript
function(theta_p,theta){ if(arguments.length > 1){ this.theta = theta; this.rootPos = new Vec2D(theta_p); } else { this.rootPos = new Vec2D(); this.theta = theta_p; } //due to lack-of int/float types, no support of theta in degrees }
[ "function", "(", "theta_p", ",", "theta", ")", "{", "if", "(", "arguments", ".", "length", ">", "1", ")", "{", "this", ".", "theta", "=", "theta", ";", "this", ".", "rootPos", "=", "new", "Vec2D", "(", "theta_p", ")", ";", "}", "else", "{", "this...
either Vec2D + angle @param {Vec2D | Number} vector | angle @param {Number} [theta]
[ "either", "Vec2D", "+", "angle" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/physics2d/constraints/AngularConstraint.js#L10-L19
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function( origin ){ var centroid = this.getCentroid(); var delta = origin !== undefined ? origin.sub( centroid ) : centroid.invert(); for( var i=0, l = this.vertices.length; i<l; i++){ this.vertices[i].addSelf( delta ); } return this; }
javascript
function( origin ){ var centroid = this.getCentroid(); var delta = origin !== undefined ? origin.sub( centroid ) : centroid.invert(); for( var i=0, l = this.vertices.length; i<l; i++){ this.vertices[i].addSelf( delta ); } return this; }
[ "function", "(", "origin", ")", "{", "var", "centroid", "=", "this", ".", "getCentroid", "(", ")", ";", "var", "delta", "=", "origin", "!==", "undefined", "?", "origin", ".", "sub", "(", "centroid", ")", ":", "centroid", ".", "invert", "(", ")", ";",...
centers the polygon so that its new centroid is at the given point @param {Vec2D} [origin] @return itself
[ "centers", "the", "polygon", "so", "that", "its", "new", "centroid", "is", "at", "the", "given", "point" ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L60-L67
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function( count ){ var num = this.vertices.length, longestID = 0, maxD = 0, i = 0, d, m; while( num < count ){ //find longest edge longestID = 0; maxD = 0; ...
javascript
function( count ){ var num = this.vertices.length, longestID = 0, maxD = 0, i = 0, d, m; while( num < count ){ //find longest edge longestID = 0; maxD = 0; ...
[ "function", "(", "count", ")", "{", "var", "num", "=", "this", ".", "vertices", ".", "length", ",", "longestID", "=", "0", ",", "maxD", "=", "0", ",", "i", "=", "0", ",", "d", ",", "m", ";", "while", "(", "num", "<", "count", ")", "{", "//fin...
Repeatedly inserts vertices as mid points of the longest edges until the new vertex count is reached. @param {Number} count new vertex count @return itself
[ "Repeatedly", "inserts", "vertices", "as", "mid", "points", "of", "the", "longest", "edges", "until", "the", "new", "vertex", "count", "is", "reached", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L246-L274
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function(){ var isPositive = false, num = this.vertices.length, prev, next, d0, d1, newIsP; for( var i = 0; i < num; i++ ){ prev = (i===0) ? num -1 : i - 1; next = (i=...
javascript
function(){ var isPositive = false, num = this.vertices.length, prev, next, d0, d1, newIsP; for( var i = 0; i < num; i++ ){ prev = (i===0) ? num -1 : i - 1; next = (i=...
[ "function", "(", ")", "{", "var", "isPositive", "=", "false", ",", "num", "=", "this", ".", "vertices", ".", "length", ",", "prev", ",", "next", ",", "d0", ",", "d1", ",", "newIsP", ";", "for", "(", "var", "i", "=", "0", ";", "i", "<", "num", ...
Checks if the polygon is convex. @return true, if convex.
[ "Checks", "if", "the", "polygon", "is", "convex", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L301-L323
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function( x1, y1, x2, y2, x3, y3, distance, out ){ var c1 = x2, d1 = y2, c2 = x2, d2 = y2; var dx1, dy1, dist1, dx2, dy2, dist2, insetX, ...
javascript
function( x1, y1, x2, y2, x3, y3, distance, out ){ var c1 = x2, d1 = y2, c2 = x2, d2 = y2; var dx1, dy1, dist1, dx2, dy2, dist2, insetX, ...
[ "function", "(", "x1", ",", "y1", ",", "x2", ",", "y2", ",", "x3", ",", "y3", ",", "distance", ",", "out", ")", "{", "var", "c1", "=", "x2", ",", "d1", "=", "y2", ",", "c2", "=", "x2", ",", "d2", "=", "y2", ";", "var", "dx1", ",", "dy1", ...
Given the sequentially connected points p1, p2, p3, this function returns a bevel-offset replacement for point p2. Note: If vectors p1->p2 and p2->p3 are exactly 180 degrees opposed, or if either segment is zero then no offset will be applied. @param x1 @param y1 @param x2 @param y2 @param x3 @param y3 @param distanc...
[ "Given", "the", "sequentially", "connected", "points", "p1", "p2", "p3", "this", "function", "returns", "a", "bevel", "-", "offset", "replacement", "for", "point", "p2", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L343-L396
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function( minEdgeLen ){ minEdgeLen *= minEdgeLen; var vs = this.vertices, reduced = [], prev = vs[0], num = vs.length - 1, vec; reduced.push(prev); for( var i = 0; i < num; i++ ){ vec = vs[i];...
javascript
function( minEdgeLen ){ minEdgeLen *= minEdgeLen; var vs = this.vertices, reduced = [], prev = vs[0], num = vs.length - 1, vec; reduced.push(prev); for( var i = 0; i < num; i++ ){ vec = vs[i];...
[ "function", "(", "minEdgeLen", ")", "{", "minEdgeLen", "*=", "minEdgeLen", ";", "var", "vs", "=", "this", ".", "vertices", ",", "reduced", "=", "[", "]", ",", "prev", "=", "vs", "[", "0", "]", ",", "num", "=", "vs", ".", "length", "-", "1", ",", ...
Reduces the number of vertices in the polygon based on the given minimum edge length. Only vertices with at least this distance between them will be kept. @param minEdgeLen @return itself
[ "Reduces", "the", "number", "of", "vertices", "in", "the", "polygon", "based", "on", "the", "given", "minimum", "edge", "length", ".", "Only", "vertices", "with", "at", "least", "this", "distance", "between", "them", "will", "be", "kept", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L444-L464
train
hapticdata/toxiclibsjs
lib/toxi/geom/Polygon2D.js
function( tolerance ){ //if tolerance is 0, it will be faster to just use 'equals' method var equals = tolerance ? 'equalsWithTolerance' : 'equals'; var p, prev, i = 0, num = this.vertices.length; var last; for( ; i<num; i++ ){ p = this.vertice...
javascript
function( tolerance ){ //if tolerance is 0, it will be faster to just use 'equals' method var equals = tolerance ? 'equalsWithTolerance' : 'equals'; var p, prev, i = 0, num = this.vertices.length; var last; for( ; i<num; i++ ){ p = this.vertice...
[ "function", "(", "tolerance", ")", "{", "//if tolerance is 0, it will be faster to just use 'equals' method", "var", "equals", "=", "tolerance", "?", "'equalsWithTolerance'", ":", "'equals'", ";", "var", "p", ",", "prev", ",", "i", "=", "0", ",", "num", "=", "this...
Removes duplicate vertices from the polygon. Only successive points are recognized as duplicates. @param {Number} tolerance snap distance for finding duplicates @return itself
[ "Removes", "duplicate", "vertices", "from", "the", "polygon", ".", "Only", "successive", "points", "are", "recognized", "as", "duplicates", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/geom/Polygon2D.js#L473-L498
train
hapticdata/toxiclibsjs
lib/toxi/math/ScaleMap.js
function(val) { var t = ((val - this._in.min) / this._interval); return this.mapFunction.interpolate(0, this.mapRange, t) + this._out.min; }
javascript
function(val) { var t = ((val - this._in.min) / this._interval); return this.mapFunction.interpolate(0, this.mapRange, t) + this._out.min; }
[ "function", "(", "val", ")", "{", "var", "t", "=", "(", "(", "val", "-", "this", ".", "_in", ".", "min", ")", "/", "this", ".", "_interval", ")", ";", "return", "this", ".", "mapFunction", ".", "interpolate", "(", "0", ",", "this", ".", "mapRange...
Computes mapped value in the target interval. Does check if input value is outside the input range. @param val @return mapped value
[ "Computes", "mapped", "value", "in", "the", "target", "interval", ".", "Does", "check", "if", "input", "value", "is", "outside", "the", "input", "range", "." ]
3712b44242128245084f18cbad7f0dfa0fc41d9b
https://github.com/hapticdata/toxiclibsjs/blob/3712b44242128245084f18cbad7f0dfa0fc41d9b/lib/toxi/math/ScaleMap.js#L89-L92
train
jonathantneal/media-player
src/index.js
onPlayChange
function onPlayChange() { if (paused !== media.paused) { paused = media.paused; $(self.play, { 'aria-label': paused ? lang.play || 'play' : lang.pause || 'pause' }); $(self.playSymbol, { 'aria-hidden': !paused }); $(self.pauseSymbol, { 'aria-hidden': paused }); clearInterval(interval); if (!pause...
javascript
function onPlayChange() { if (paused !== media.paused) { paused = media.paused; $(self.play, { 'aria-label': paused ? lang.play || 'play' : lang.pause || 'pause' }); $(self.playSymbol, { 'aria-hidden': !paused }); $(self.pauseSymbol, { 'aria-hidden': paused }); clearInterval(interval); if (!pause...
[ "function", "onPlayChange", "(", ")", "{", "if", "(", "paused", "!==", "media", ".", "paused", ")", "{", "paused", "=", "media", ".", "paused", ";", "$", "(", "self", ".", "play", ",", "{", "'aria-label'", ":", "paused", "?", "lang", ".", "play", "...
when the play state changes
[ "when", "the", "play", "state", "changes" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L104-L122
train
jonathantneal/media-player
src/index.js
onTimeChange
function onTimeChange() { if (currentTime !== media.currentTime || duration !== media.duration) { currentTime = media.currentTime; duration = media.duration || 0; const currentTimePercentage = currentTime / duration; const currentTimeCode = timeToTimecode(currentTime); const remainingTimeCode = timeTo...
javascript
function onTimeChange() { if (currentTime !== media.currentTime || duration !== media.duration) { currentTime = media.currentTime; duration = media.duration || 0; const currentTimePercentage = currentTime / duration; const currentTimeCode = timeToTimecode(currentTime); const remainingTimeCode = timeTo...
[ "function", "onTimeChange", "(", ")", "{", "if", "(", "currentTime", "!==", "media", ".", "currentTime", "||", "duration", "!==", "media", ".", "duration", ")", "{", "currentTime", "=", "media", ".", "currentTime", ";", "duration", "=", "media", ".", "dura...
when the time changes
[ "when", "the", "time", "changes" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L125-L156
train
jonathantneal/media-player
src/index.js
onLoadStart
function onLoadStart() { media.removeEventListener('canplaythrough', onCanPlayStart); $(media, { canplaythrough: onCanPlayStart }); $(self.download, { href: media.src, download: media.src }); onPlayChange(); onVolumeChange(); onFullscreenChange(); onTimeChange(); }
javascript
function onLoadStart() { media.removeEventListener('canplaythrough', onCanPlayStart); $(media, { canplaythrough: onCanPlayStart }); $(self.download, { href: media.src, download: media.src }); onPlayChange(); onVolumeChange(); onFullscreenChange(); onTimeChange(); }
[ "function", "onLoadStart", "(", ")", "{", "media", ".", "removeEventListener", "(", "'canplaythrough'", ",", "onCanPlayStart", ")", ";", "$", "(", "media", ",", "{", "canplaythrough", ":", "onCanPlayStart", "}", ")", ";", "$", "(", "self", ".", "download", ...
when media loads for the first time
[ "when", "media", "loads", "for", "the", "first", "time" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L159-L170
train
jonathantneal/media-player
src/index.js
onCanPlayStart
function onCanPlayStart() { media.removeEventListener('canplaythrough', onCanPlayStart); // dispatch new "canplaystart" event dispatchCustomEvent(media, 'canplaystart'); if (!paused || media.autoplay) { media.play(); } }
javascript
function onCanPlayStart() { media.removeEventListener('canplaythrough', onCanPlayStart); // dispatch new "canplaystart" event dispatchCustomEvent(media, 'canplaystart'); if (!paused || media.autoplay) { media.play(); } }
[ "function", "onCanPlayStart", "(", ")", "{", "media", ".", "removeEventListener", "(", "'canplaythrough'", ",", "onCanPlayStart", ")", ";", "// dispatch new \"canplaystart\" event", "dispatchCustomEvent", "(", "media", ",", "'canplaystart'", ")", ";", "if", "(", "!", ...
when the media can play
[ "when", "the", "media", "can", "play" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L178-L187
train
jonathantneal/media-player
src/index.js
onVolumeChange
function onVolumeChange() { const volumePercentage = media.muted ? 0 : media.volume; const isMuted = !volumePercentage; $(self.volume, { 'aria-valuenow': volumePercentage, 'aria-valuemin': 0, 'aria-valuemax': 1 }); const dirIsInline = /^(ltr|rtl)$/i.test(volumeDir); const axisProp = dirIsInline ? 'width' : ...
javascript
function onVolumeChange() { const volumePercentage = media.muted ? 0 : media.volume; const isMuted = !volumePercentage; $(self.volume, { 'aria-valuenow': volumePercentage, 'aria-valuemin': 0, 'aria-valuemax': 1 }); const dirIsInline = /^(ltr|rtl)$/i.test(volumeDir); const axisProp = dirIsInline ? 'width' : ...
[ "function", "onVolumeChange", "(", ")", "{", "const", "volumePercentage", "=", "media", ".", "muted", "?", "0", ":", "media", ".", "volume", ";", "const", "isMuted", "=", "!", "volumePercentage", ";", "$", "(", "self", ".", "volume", ",", "{", "'aria-val...
when the volume changes
[ "when", "the", "volume", "changes" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L190-L204
train
jonathantneal/media-player
src/index.js
onDownloadClick
function onDownloadClick() { const a = document.head.appendChild($('a', { download: '', href: media.src })); a.click(); document.head.removeChild(a); }
javascript
function onDownloadClick() { const a = document.head.appendChild($('a', { download: '', href: media.src })); a.click(); document.head.removeChild(a); }
[ "function", "onDownloadClick", "(", ")", "{", "const", "a", "=", "document", ".", "head", ".", "appendChild", "(", "$", "(", "'a'", ",", "{", "download", ":", "''", ",", "href", ":", "media", ".", "src", "}", ")", ")", ";", "a", ".", "click", "("...
click from download control
[ "click", "from", "download", "control" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L248-L254
train
jonathantneal/media-player
src/index.js
onFullscreenClick
function onFullscreenClick() { if (requestFullscreen) { if (player === fullscreenElement()) { // exit fullscreen exitFullscreen().call(document); } else { // enter fullscreen requestFullscreen.call(player); // maintain focus in internet explorer self.fullscreen.focus(); // maintain...
javascript
function onFullscreenClick() { if (requestFullscreen) { if (player === fullscreenElement()) { // exit fullscreen exitFullscreen().call(document); } else { // enter fullscreen requestFullscreen.call(player); // maintain focus in internet explorer self.fullscreen.focus(); // maintain...
[ "function", "onFullscreenClick", "(", ")", "{", "if", "(", "requestFullscreen", ")", "{", "if", "(", "player", "===", "fullscreenElement", "(", ")", ")", "{", "// exit fullscreen", "exitFullscreen", "(", ")", ".", "call", "(", "document", ")", ";", "}", "e...
click from fullscreen control
[ "click", "from", "fullscreen", "control" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L257-L286
train
jonathantneal/media-player
src/index.js
onTimeKeydown
function onTimeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(timeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : keyCode - 39; media...
javascript
function onTimeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(timeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : keyCode - 39; media...
[ "function", "onTimeKeydown", "(", "event", ")", "{", "const", "{", "keyCode", ",", "shiftKey", "}", "=", "event", ";", "// 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN", "if", "(", "37", "<=", "keyCode", "&&", "40", ">=", "keyCode", ")", "{", "event", ".", "prevent...
keydown from play control or current time control
[ "keydown", "from", "play", "control", "or", "current", "time", "control" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L289-L303
train
jonathantneal/media-player
src/index.js
onVolumeKeydown
function onVolumeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(volumeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : isLTR ? 39 - keyCod...
javascript
function onVolumeKeydown(event) { const { keyCode, shiftKey } = event; // 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN if (37 <= keyCode && 40 >= keyCode) { event.preventDefault(); const isLTR = /^(btt|ltr)$/.test(volumeDir); const offset = 37 === keyCode || 39 === keyCode ? keyCode - 38 : isLTR ? 39 - keyCod...
[ "function", "onVolumeKeydown", "(", "event", ")", "{", "const", "{", "keyCode", ",", "shiftKey", "}", "=", "event", ";", "// 37: LEFT, 38: UP, 39: RIGHT, 40: DOWN", "if", "(", "37", "<=", "keyCode", "&&", "40", ">=", "keyCode", ")", "{", "event", ".", "preve...
keydown from mute control or volume control
[ "keydown", "from", "mute", "control", "or", "volume", "control" ]
f2ee40c4576269f06d14e1d54b3b17b292276f6f
https://github.com/jonathantneal/media-player/blob/f2ee40c4576269f06d14e1d54b3b17b292276f6f/src/index.js#L306-L318
train
riot/compiler
src/generators/template/builder.js
createBindingsTag
function createBindingsTag(sourceNode, bindingsSelector) { if (!bindingsSelector) return sourceNode return { ...sourceNode, // inject the selector bindings into the node attributes attributes: [{ name: bindingsSelector }, ...getNodeAttributes(sourceNode)] } }
javascript
function createBindingsTag(sourceNode, bindingsSelector) { if (!bindingsSelector) return sourceNode return { ...sourceNode, // inject the selector bindings into the node attributes attributes: [{ name: bindingsSelector }, ...getNodeAttributes(sourceNode)] } }
[ "function", "createBindingsTag", "(", "sourceNode", ",", "bindingsSelector", ")", "{", "if", "(", "!", "bindingsSelector", ")", "return", "sourceNode", "return", "{", "...", "sourceNode", ",", "// inject the selector bindings into the node attributes", "attributes", ":", ...
Nodes having bindings should be cloned and new selector properties should be added to them @param {RiotParser.Node} sourceNode - any kind of node parsed via riot parser @param {string} bindingsSelector - temporary string to identify the current node @returns {RiotParser.Node} the original node parsed having the new...
[ "Nodes", "having", "bindings", "should", "be", "cloned", "and", "new", "selector", "properties", "should", "be", "added", "to", "them" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/generators/template/builder.js#L36-L46
train
riot/compiler
src/generators/template/builder.js
createTagWithBindings
function createTagWithBindings(sourceNode, sourceFile, sourceCode) { const bindingsSelector = isRootNode(sourceNode) ? null : createBindingSelector() const cloneNode = createBindingsTag(sourceNode, bindingsSelector) const tagOpeningHTML = nodeToString(cloneNode) switch(true) { // EACH bindings have prio 1 ...
javascript
function createTagWithBindings(sourceNode, sourceFile, sourceCode) { const bindingsSelector = isRootNode(sourceNode) ? null : createBindingSelector() const cloneNode = createBindingsTag(sourceNode, bindingsSelector) const tagOpeningHTML = nodeToString(cloneNode) switch(true) { // EACH bindings have prio 1 ...
[ "function", "createTagWithBindings", "(", "sourceNode", ",", "sourceFile", ",", "sourceCode", ")", "{", "const", "bindingsSelector", "=", "isRootNode", "(", "sourceNode", ")", "?", "null", ":", "createBindingSelector", "(", ")", "const", "cloneNode", "=", "createB...
Create only a dynamic tag node with generating a custom selector and its bindings @param {RiotParser.Node} sourceNode - any kind of node parsed via riot parser @param {stiring} sourceFile - source file path @param {string} sourceCode - original source @param {BuildingState} state - state representing the curren...
[ "Create", "only", "a", "dynamic", "tag", "node", "with", "generating", "a", "custom", "selector", "and", "its", "bindings" ]
fa9cea9cf6b8a369e057c966c4e2698940a3fafc
https://github.com/riot/compiler/blob/fa9cea9cf6b8a369e057c966c4e2698940a3fafc/src/generators/template/builder.js#L74-L93
train