Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: Sketch Pad
name
code content
//LET'S PAINT! //select all and compile var point, red, green, blue, win, view, colorTask; var redChange, greenChange, blueChange; //rate of change of each color component //mess around with these values for fun //zero results in no color change redChange = 0.01; greenChange = 0.015; blueChange = 0.02; //default starting RGB values //these values can be changed as well //maintain range of 0≤x≤1 red=0; green=0.33; blue=0.67; //window creation win = Window("FANCY ARTWORK", resizable:true, border:false); win.fullScreen; win.onClose = { if( colorTask.isPlaying, {colorTask.stop}, {} ); }; //userview creation view = UserView(win, Window.screenBounds); view.clearOnRefresh = false; view.background = Color.white; //any click sets point as current mouse location //left-click does nothing special //right-click clears palette view.mouseDownAction = { |v, x, y, mod, butNum, clkCnt| point = [x,y]; if(butNum == 1, { view.drawFunc_({nil}); view.clearDrawing; view.refresh},{} ); }; //mouse drag redefines userview drawFunc //Pen draws line from old point to current point //then sets old point equal to current point view.mouseMoveAction = { |v, x, y, mod| view.drawFunc = { Pen.strokeColor = Color.new( red.fold(0,1), green.fold(0,1), blue.fold(0,1) ); Pen.width = 3; Pen.line(point.asPoint,x@y); point = [x,y]; Pen.stroke; }; win.refresh; }; //RGB values wrap through range 0≤x<2 //and are folded into 0≤x≤1 via mouseMove function //thus RGB values oscillate linearly, out of phase with //one another, back and forth from 0 to 1 colorTask = Task({ { red = (red + redChange)%2; green = (green + greenChange)%2; blue = (blue + blueChange)%2; 0.05.wait; //arbitrary wait time }.loop; }); //comment out for no color change colorTask.start; win.front;
code description
An environment in which the user can draw using the mouse.
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change