This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based on https://github.com/processing/processing/blob/a6e0e227a948e7e2dc042c04504d6f5b8cf0c1a6/core/src/processing/core/PApplet.java#L5093 | |
var scale = function(opts){ | |
var istart = opts.domain[0], | |
istop = opts.domain[1], | |
ostart = opts.range[0], | |
ostop = opts.range[1]; | |
return function scale(value) { | |
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* url sets the path */ | |
font-url(file) | |
return '/public/stylesheets/fonts/' + file | |
/* abstracts all the specifics*/ | |
webfont(family, file, style, weight) | |
@font-face | |
font-family family | |
font-weight weight | |
font-style style |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vendor(prop, args) | |
-webkit-{prop} args | |
-moz-{prop} args | |
-ms-{prop} args | |
-o-{prop} args | |
{prop} args | |
border-radius() | |
vendor('border-radius', arguments) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This snippet is an example on how the detecting overlaping annotations | |
// was implemented inside the Substance Composer app. | |
function annotate(type) { | |
// Check for existing annotation | |
var sel = this.surface.selection(); | |
if (!sel) return; | |
if (_.include(["em", "str"], type)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns the absolute offset from the top of the container | |
function getCharacterOffsetWithin(sel, node) { | |
var range = sel.getRangeAt(0); | |
var selStr = sel.toString(); | |
// we sanitize linebreaks and white spaces | |
selLen = selStr.replace(/[^A-Za-z0-9.-:\/$ ]/g, "").replace(/(\r\n|\n|\r|\s+)/gm, ' ').length; | |
var treeWalker = document.createTreeWalker( node, NodeFilter.SHOW_TEXT, function(node) { |
NewerOlder