|
/* |
|
* val4 is an array of 4 numbers that range from [0,100] |
|
* size is the number of pixels for width and height |
|
* use p5.js to draw a round grawscale glpyh within the bounding box |
|
*/ |
|
|
|
|
|
/* MY EDITS |
|
|
|
in Glyph4 : |
|
values[0] = How many times random is run on each point withing the constraints |
|
values[1] = Size of the dots |
|
values[2] = Size of the strokes |
|
values[3] = Color balance of the strokes and dots |
|
|
|
|
|
Size/2 = r. |
|
|
|
Using the new formula that y (height of the square) is y=r/SQRT(2) |
|
and therefore : (s2/sqrt(2)/2) to find half of that |
|
|
|
*/ |
|
function glyph4(values, size) { |
|
|
|
var lineX = []; |
|
var lineY = []; |
|
var dotSize; |
|
var dotColor; |
|
var lineColor; |
|
var dotSize; |
|
var lineSize; |
|
|
|
|
|
// Setting base Ellipse |
|
var s2 = size/2; // rad of circle for calculation |
|
fill(50); |
|
ellipse(s2, s2, size); |
|
|
|
|
|
// Set Dot and Line color based on values[3] |
|
dotColor = values[3]*2.55; |
|
fill(dotColor); |
|
lineColor = dotColor/2; |
|
stroke(lineColor); |
|
|
|
// set Dot and Line size based on values[1] and values[2] |
|
dotSize = values[1]/10; |
|
if(dotSize<4){ |
|
dotSize = 4; |
|
} |
|
lineSize = values[2]/20; |
|
if(lineSize<2){ |
|
lineSize = 2; |
|
} |
|
strokeWeight(lineSize); |
|
|
|
// Point values for top left corner |
|
for(var i = 0; i<values[0]+1; i++){ |
|
lineX[0] = Math.random((s2-(s2/sqrt(2)/2),s2)); |
|
lineY[0] = Math.random((s2-(s2/sqrt(2)/2),s2)); |
|
} |
|
|
|
// Point values for top right corner |
|
for(var i = 0; i<values[0]+1; i++){ |
|
lineX[1] = Math.random((s2+(s2/sqrt(2)/2),s2)); |
|
lineY[1] = Math.random((s2-(s2/sqrt(2)/2),s2)); |
|
} |
|
|
|
// Point values for the bottom left corner |
|
for(var i = 0; i<values[0]+1; i++){ |
|
lineX[2] = Math.random((s2-(s2/sqrt(2)/2),s2)); |
|
lineY[2] = Math.random((s2+(s2/sqrt(2)/2),s2)); |
|
} |
|
|
|
// Point values for the bottom right corner |
|
for(var i = 0; i<values[0]+1; i++){ |
|
lineX[3] = Math.random((s2+(s2/sqrt(2)/2),s2)); |
|
lineY[3] = Math.random((s2+(s2/sqrt(2)/2),s2)); |
|
} |
|
|
|
|
|
//Sizing the coordinates for the dots |
|
// This was where the issues was. I originally did not add s2/2 and this caused the offset |
|
// to not be in the right place. |
|
for(var j = 0; j<4; j++){ |
|
lineX[j] = lineX[j]*s2+(s2/2); |
|
lineY[j] = lineY[j]*s2+(s2/2); |
|
} |
|
|
|
|
|
// Drawing each dot |
|
for(var k = 0; k<4; k++){ |
|
ellipse(lineX[k],lineY[k],dotSize,dotSize); |
|
} |
|
// Drawing each line |
|
for(var l = 0; l<3; l++){ |
|
line(lineX[l],lineY[l],lineX[l+1],lineY[l+1]); |
|
} |
|
|
|
/* testing stuff |
|
ellipse(0,0,dotSize,dotSize); // origin dot location |
|
println("1 : "+lineX[0]+","+lineY[0]); // coordinates |
|
println("2 : "+lineX[1]+","+lineY[1]); |
|
println("3 : "+lineX[2]+","+lineY[2]); |
|
println("4 : "+lineX[3]+","+lineY[3]); |
|
*/ |
|
|
|
|
|
/* |
|
var color1 = map(values[0], 0, 100, 10, 70) |
|
stroke(color1); |
|
fill(color1) |
|
var s2 = size/2; |
|
ellipse(s2, s2, size); |
|
|
|
var inner_size = 0.2 + 0.4 * values[2] / 100.0; |
|
var s3 = size * inner_size; |
|
|
|
var color2 = map(values[1], 0, 100, color1+20, 240) |
|
fill(color2); |
|
stroke(color2); |
|
|
|
var shift_frac = (values[3] - 50.0) / 50.0; |
|
var max_shift = 0.5 * (size - s3); |
|
var x_shift = shift_frac * max_shift; |
|
ellipse(s2 + x_shift, s2, s3); |
|
*/ |
|
} |
|
|
|
/* |
|
* val8 is an array of 8 numbers that range from [0,100] |
|
* size is the number of pixels for width and height |
|
* use p5.js to draw a square color glpyh within the bounding box |
|
*/ |
|
function glyph8(values, size) { |
|
|
|
/* My Edits |
|
|
|
in Glyph8 |
|
|
|
Slider 1) Length of top bar |
|
Slider 2) Length of bottom bar |
|
Slider 3) Loc of top Bar higher wave |
|
Slider 4) Loc of bottom Bar Higher wave |
|
Slider 5) Loc of top bar lower wave |
|
Slider 6) Loc of bottom bar lower wave |
|
Slider 7) Color Balance top bar |
|
Slider 8) Color Balance bottom bar |
|
|
|
*/ |
|
|
|
var rodTopX; |
|
var rodTopY; |
|
var rodBotX; |
|
var rodBotY; |
|
var dotTopX; |
|
var dotBotX; |
|
// variables for holding the x coords of the top and bottom dots |
|
var highDotTopX; |
|
var highDotBotX; |
|
var lowDotTopX; |
|
var lowDotBotX; |
|
// max top and bottom dot x locations |
|
var maxDotTop; |
|
var maxDotBot; |
|
// Variables to check how much space to left and right of each dot. |
|
var spaceLeft; |
|
var spaceRight; |
|
|
|
// Color arrays |
|
var topColArr = []; |
|
var botColArr = []; |
|
|
|
// Setting up lerpColors for Top Bars (keeping it cosntrained to the blue spectrum) Has 100 opacity so bars underneath shine through |
|
fromTop = color(values[6],values[6]+25,values[6]+50,100); |
|
toTop = color(values[6]+50,values[6]+75,values[6]+100,100); |
|
interTopA = lerpColor(fromTop, toTop, .25); |
|
interTopB = lerpColor(fromTop, toTop, .50); |
|
interTopC = lerpColor(fromTop, toTop, .75); |
|
topColArr[1] = fromTop; |
|
topColArr[2] = interTopA; |
|
topColArr[3] = interTopB; |
|
topColArr[4] = interTopC; |
|
topColArr[5] = toTop; |
|
|
|
// Setting up lerpColors for Bottom Bars (keeping it constrained from neon green to purple) |
|
fromBot = color(values[7],values[7]*2,values[7]/2); |
|
toBot = color(values[7],values[7]/2,values[7]*2); |
|
interBotA = lerpColor(fromBot, toBot, .25); |
|
interBotB = lerpColor(fromBot, toBot, .50); |
|
interBotC = lerpColor(fromBot, toBot, .75); |
|
botColArr[1] = fromBot; |
|
botColArr[2] = interBotA; |
|
botColArr[3] = interBotB; |
|
botColArr[4] = interBotC; |
|
botColArr[5] = toBot; |
|
|
|
noStroke(); |
|
fill(192,192,192); |
|
rect(0,0,size,size); |
|
|
|
rodTopX = 0; |
|
rodTopY = (size/6)*2; |
|
rodBotX = 0; |
|
rodBotY = (size/6)*4; |
|
|
|
fill(50,50,50,50); |
|
|
|
// Check to see that rod top and bottom does not have a less than adequate value for the dots to appear on |
|
if(values[0]<(size/8)){ |
|
values[0] = size/8; |
|
}if(values[1]<(size/8)){ |
|
values[1] = size/8; |
|
} |
|
|
|
// Draws the top and bottom bar |
|
rect(rodTopX,rodTopY,(size/100)*values[0],size/8); |
|
rect(rodBotX,rodBotY,(size/100)*values[1],size/8); |
|
|
|
// Sets the location of the upper wave dot on the top and bottom bar |
|
maxDotTop = (size/100)*values[0]; |
|
maxDotBot = (size/100)*values[1]; |
|
|
|
|
|
// Setting top rod high wave dot location |
|
highDotTopX = (size/100)*values[2]+((size/8)/2); |
|
if(highDotTopX<0){ |
|
highDotTopX = 0; |
|
} |
|
if(highDotTopX>maxDotTop){ |
|
highDotTopX = maxDotTop-((size/8)/2); |
|
} |
|
// Setting up bottom rod high wave dot location |
|
highDotBotX = (size/100)*values[3]+((size/8)/2); |
|
if(highDotBotX<0){ |
|
highDotBotX = 0; |
|
} |
|
if(highDotBotX>maxDotBot){ |
|
highDotBotX = maxDotBot-((size/8)/2); |
|
} |
|
// Setting the top rod low wave dot location |
|
lowDotTopX = (size/100)*values[4]+((size/8)/2); |
|
if(lowDotTopX<0){ |
|
lowDotTopX = 0; |
|
} |
|
if(lowDotTopX>maxDotTop){ |
|
lowDotTopX = maxDotTop-((size/8)/2); |
|
} |
|
// Setting the bottom rod low wave dot location |
|
lowDotBotX = (size/100)*values[5]+((size/8)/2); |
|
if(lowDotBotX<0){ |
|
lowDotBotX = 0; |
|
} |
|
if(lowDotBotX>maxDotBot){ |
|
lowDotBotX = maxDotBot-((size/8)/2); |
|
} |
|
|
|
|
|
// Drawing the center rods that represent the middle of the top waves |
|
rect(highDotTopX-((size/8)/2),rodTopY-((size/6)*2),size/8,(size/6)*2); |
|
rect(highDotBotX-((size/8)/2),rodBotY-((size/6)*2),size/8,(size/6)*2); |
|
// Drawing the center rods that represent the middle fo the low waves |
|
rect(lowDotTopX-((size/8)/2),rodTopY,size/8,(size/6)*2); |
|
rect(lowDotBotX-((size/8)/2),rodBotY,size/8,(size/6)*2); |
|
|
|
fill(100,100,100,100); |
|
// Drawing both the top and bottom rod high wave origin dots |
|
ellipse(highDotTopX,rodTopY,size/8,size/8); |
|
ellipse(highDotBotX,rodBotY,size/8,size/8); |
|
// Drawing both the top and bottom rod low wave origin dots |
|
ellipse(lowDotTopX,rodTopY+((size/8)/2),size/8,size/8); |
|
ellipse(lowDotBotX,rodBotY+((size/8)/2),size/8,size/8); |
|
|
|
// Drawing the radiating bars for the Top Low wave |
|
spaceLeft = 0+lowDotTopX; |
|
spaceRight = size-lowDotTopX; |
|
|
|
for(var i = 5; i>0; i--){ |
|
fill(botColArr[i]); |
|
rect(lowDotTopX-((spaceLeft/5)*i),0+((size/6)*2)+(size/8),spaceLeft/5,(((size/6)*2)/5)*(6-i)); |
|
rect(lowDotTopX+((spaceRight/5)*i)-(spaceRight/5),0+((size/6)*2)+(size/8),spaceRight/5,(((size/6)*2)/5)*(6-i)); |
|
} |
|
|
|
// Drawing the radiating bars for the Bottom Low wave |
|
spaceLeft = 0+lowDotBotX; |
|
spaceRight = size-lowDotBotX; |
|
|
|
for(var i = 5; i>0; i--){ |
|
fill(botColArr[i]); |
|
rect(lowDotBotX-((spaceLeft/5)*i),0+((size/6)*4)+(size/8),spaceLeft/5,(((size/6))/5)*(6-i)); |
|
rect(lowDotBotX+((spaceRight/5)*i)-(spaceRight/5),0+((size/6)*4)+(size/8),spaceRight/5,(((size/6))/5)*(6-i)); |
|
} |
|
|
|
|
|
// Drawing the radiating bars for Top High wave |
|
spaceLeft = 0+highDotTopX; |
|
spaceRight = size-highDotTopX; |
|
|
|
for(var i = 5; i>0; i--){ |
|
fill(topColArr[i]); |
|
rect(highDotTopX-((spaceLeft/5)*(6-i)),0+((size/6)*2)-((((size/6)*2)/5)*i),spaceLeft/5,(((size/6)*2)/5)*i); |
|
rect(highDotTopX+((spaceRight/5)*(5-i)),0+((size/6)*2)-((((size/6)*2)/5)*i),spaceRight/5,(((size/6)*2)/5)*i); |
|
} |
|
|
|
// Drawing the radiating bars for the Bottom High wave |
|
spaceLeft = 0+highDotBotX; |
|
spaceRight = size-highDotBotX; |
|
|
|
for(var i = 5; i>0; i--){ |
|
fill(topColArr[i]); |
|
rect(highDotBotX-((spaceLeft/5)*(6-i)),0+((size/6)*4)-((((size/6)*2)/5)*i),spaceLeft/5,(((size/6)*2)/5)*i); |
|
rect(highDotBotX+((spaceRight/5)*(5-i)),0+((size/6)*4)-((((size/6)*2)/5)*i),spaceRight/5,(((size/6)*2)/5)*i); |
|
} |
|
|
|
|
|
/* |
|
var red = [255, 0, 0]; |
|
var green = [0, 255, 0]; |
|
var blue = [0, 0, 255]; |
|
var white = [255, 255, 255]; |
|
var colors = [red, green, blue, white, red, green, blue, white]; |
|
stroke(0); |
|
fill(0); |
|
rect(0, 0, size, size); |
|
for(var i=0; i<8; i++) { |
|
stroke(colors[i]); |
|
fill(colors[i]); |
|
offsety = i * size / 8; |
|
offsetx = (size * values[i]) / 100; |
|
rect(0, offsety, offsetx, size); |
|
} |
|
|
|
*/ |
|
|
|
} |