Skip to content

Instantly share code, notes, and snippets.

@chadochan
Last active Feb 22, 2016
Embed
What would you like to do?
SuperCollider 3.6.5: create a 25x6 letter matrix for projecting text. Includes project, random letter sprinkle, and text clear functions.
// TEXTWALL by chadochan. 7/12/2015 Durham
// Creates a 25x6 text matrix with text project, random text, and text clearing functions.
(
var font = Font("Luxi Mono", 90);
var backgroundcolor = Color.black;
var lettercolor = Color.white;
var letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12, letter13, letter14, letter15, letter16, letter17, letter18, letter19, letter20, letter21, letter22, letter23, letter24, letter25, letter26, letter27, letter28, letter29, letter30, letter31, letter32, letter33, letter34, letter35, letter36, letter37, letter38, letter39, letter40, letter41, letter42, letter43, letter44, letter45, letter46, letter47, letter48, letter49, letter50, letter51, letter52, letter53, letter54, letter55, letter56, letter57, letter58, letter59, letter60, letter61, letter62, letter63, letter64, letter65, letter66, letter67, letter68, letter69, letter70, letter71, letter72, letter73, letter74, letter75, letter76, letter77, letter78, letter79, letter80, letter81, letter82, letter83, letter84, letter85, letter86, letter87, letter88, letter89, letter90, letter91, letter92, letter93, letter94, letter95, letter96, letter97, letter98, letter99, letter100, letter101, letter102, letter103, letter104, letter105, letter106, letter107, letter108, letter109, letter110, letter111, letter112, letter113, letter114, letter115, letter116, letter117, letter118, letter119, letter120, letter121, letter122, letter123, letter124, letter125, letter126, letter127, letter128, letter129, letter130, letter131, letter132, letter133, letter134, letter135, letter136, letter137, letter138, letter139, letter140, letter141, letter142, letter143, letter144, letter145, letter146, letter147, letter148, letter149, letter150;
var letterarray;
var scrambledLetterArray;
var composite1, composite2, composite3, composite4, composite5, composite6;
var letterspacing = 55@55;
var alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"];
// make window and composite views:
~window = QWindow(": :", Rect(15, 15, 1400, 788), border:true); // 16:9 aspect ratio
~window.view.background_(backgroundcolor);
//~window.front;
~window.view.keyDownAction = { |v, char, mod, unicode, keycode, key |
if(keycode == 17, { ~letterSprinkle.reset.play });
if(keycode == 8, { ~clearAllLetters.reset.play });
if(keycode == 1, { ~statement.reset.play });
if(keycode == 15, { ~revstatement.reset.play });
};
CmdPeriod.doOnce({~window.close});
composite1 = QHLayoutView(~window, Rect(10, 90, 1380, 90));
composite2 = QHLayoutView(~window, Rect(10, 192, 1380, 90));
composite3 = QHLayoutView(~window, Rect(10, 294, 1380, 90));
composite4 = QHLayoutView(~window, Rect(10, 396, 1380, 90));
composite5 = QHLayoutView(~window, Rect(10, 498, 1380, 90));
composite6 = QHLayoutView(~window, Rect(10, 600, 1380, 90));
// set letter properties, make arrays:
#letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12, letter13, letter14, letter15, letter16, letter17, letter18, letter19, letter20, letter21, letter22, letter23, letter24, letter25 = { StaticText(composite1, letterspacing).string_("").stringColor_(lettercolor).font_(font) } ! 25;
#letter26, letter27, letter28, letter29, letter30, letter31, letter32, letter33, letter34, letter35, letter36, letter37, letter38, letter39, letter40, letter41, letter42, letter43, letter44, letter45, letter46, letter47, letter48, letter49, letter50 = { StaticText(composite2, letterspacing).string_("").stringColor_(lettercolor).font_(font) } ! 25;
#letter51, letter52, letter53, letter54, letter55, letter56, letter57, letter58, letter59, letter60, letter61, letter62, letter63, letter64, letter65, letter66, letter67, letter68, letter69, letter70, letter71, letter72, letter73, letter74, letter75 = { StaticText(composite3, letterspacing).string_("").stringColor_(lettercolor).font_(font) } ! 25;
#letter76, letter77, letter78, letter79, letter80, letter81, letter82, letter83, letter84, letter85, letter86, letter87, letter88, letter89, letter90, letter91, letter92, letter93, letter94, letter95, letter96, letter97, letter98, letter99, letter100 = { StaticText(composite4, letterspacing).string_("").stringColor_(lettercolor).font_(font) } ! 25;
#letter101, letter102, letter103, letter104, letter105, letter106, letter107, letter108, letter109, letter110, letter111, letter112, letter113, letter114, letter115, letter116, letter117, letter118, letter119, letter120, letter121, letter122, letter123, letter124, letter125 = { StaticText(composite5, letterspacing).string_("")
.stringColor_(lettercolor).font_(font) } ! 25;
#letter126, letter127, letter128, letter129, letter130, letter131, letter132, letter133, letter134, letter135, letter136, letter137, letter138, letter139, letter140, letter141, letter142, letter143, letter144, letter145, letter146, letter147, letter148, letter149, letter150 = { StaticText(composite6, letterspacing).string_("")
.stringColor_(lettercolor).font_(font) } ! 25;
letterarray = [ letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10, letter11, letter12, letter13, letter14, letter15, letter16, letter17, letter18, letter19, letter20, letter21, letter22, letter23, letter24, letter25, letter26, letter27, letter28, letter29, letter30, letter31, letter32, letter33, letter34, letter35, letter36, letter37, letter38, letter39, letter40, letter41, letter42, letter43, letter44, letter45, letter46, letter47, letter48, letter49, letter50, letter51, letter52, letter53, letter54, letter55, letter56, letter57, letter58, letter59, letter60, letter61, letter62, letter63, letter64, letter65, letter66, letter67, letter68, letter69, letter70, letter71, letter72, letter73, letter74, letter75, letter76, letter77, letter78, letter79, letter80, letter81, letter82, letter83, letter84, letter85, letter86, letter87, letter88, letter89, letter90, letter91, letter92, letter93, letter94, letter95, letter96, letter97, letter98, letter99, letter100, letter101, letter102, letter103, letter104, letter105, letter106, letter107, letter108, letter109, letter110, letter111, letter112, letter113, letter114, letter115, letter116, letter117, letter118, letter119, letter120, letter121, letter122, letter123, letter124, letter125, letter126, letter127, letter128, letter129, letter130, letter131, letter132, letter133, letter134, letter135, letter136, letter137, letter138, letter139, letter140, letter141, letter142, letter143, letter144, letter145, letter146, letter147, letter148, letter149, letter150 ];
scrambledLetterArray = letterarray.scramble;
// letter functions:
~clearAllLetters = Routine({
scrambledLetterArray.do({ |item, i|
{ item.string_(""); item.stringColor_(Color.white) }.defer ;
0.005.wait;
});
scrambledLetterArray = scrambledLetterArray.scramble
});
~letterSprinkle = Routine({
scrambledLetterArray.do({ |item, i|
{ item.stringColor_(Color.white); item.string_(alphabet[rand(26)]) }.defer;
0.005.wait;
});
scrambledLetterArray = scrambledLetterArray.scramble
});
~textinsert = { |text|
Routine.run({
var offset, alpha;
offset = 150 - text.size;
offset = rand(offset);
alpha = 0.2;
text.size.do({ |i|
{{ letterarray[(offset+i)].stringColor = Color.grey(alpha);
letterarray[(offset+i)].string = text[i] }.defer }.value;
0.007.wait;
})
})
};
~revtextinsert = { |text|
Routine.run({
var offset, textsize, startpoint, endpoint;
textsize = text.size;
offset = 150 - textsize;
startpoint = rand(offset);
endpoint = startpoint + textsize;
textsize.do({ |i|
{{ letterarray[(endpoint - i)].string = text[(textsize - 1) - i] }.defer }.value;
0.007.wait;
})
})
};
)
//~window.fullScreen;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment