/*
///////////////////////////////////////////////////
//Programming Concepts and Applications
//for Artists and Designers
//Keith Kelley/task 05
/////////////////////////////////////////////////
// Covering the canvas (very slowly)
// plotting distance from a point
// set dimensions for new document
var w = 500; // units
var h = 500;
// instantiate raster canvas for use
var RC = new RasterCanvas(w, h, Units.PIXELS)
//create background_gradation from off center circle
// initialize variables
var opacity = 1;
var px = w * .8;
var py = h * .5;
// need to know maximum distance we can encounter for normalization purposes
var maxDistance = distanceFromPoint(0,0, px,py);
// cover the canvas:
// for every x, traverse entire y range
for (var x = 0; x < w; x++) {
for (var y = 0; y < h; y++) {
// use a helper function to find current distance from point
// then normalize distance and invert to use as grey
var grey = 1 - (distanceFromPoint(x,y, px,py) / maxDistance);
//change from nuetral to color
RC.setPenColor(.3, grey, grey);
RC.setPixel(x,y, opacity);
}
}
var x = 0;
var y = 0;
//create layer to place circles on
var curLayer = RC.newArtLayer(LayerKind.NORMAL);
// set a color to use_white
RC.setPenColor(1, 1, 1);
// initialize variables
// opacity will stay full throughout loop
var opacity = 1;
// define limit x and y to help stay on canvas
var limX = w-1;
var limY = h-1;
// define centerpoint of circle_left side
var centerX = limX / 9;
var centerY = limY / 2;
// define radius of circle to plot_small circle
var radius = Math.min(w, h) /50;
// plot a circle using polar coordinates:
// increment a radian angle around the unit circle [0,2pi],
// staying a constant distance from the center
for (var radianAngle = 0; radianAngle < 2*Math.PI; radianAngle += .02) {
// convert polar point (radius, angle) to cartesian for plotting
var cartesianPoint = polarToCartesian(radius, radianAngle);
// plot cartesian point (x,y)
// result of polarToCartesian function is two-element array-- [x,y]
RC.setPixel(centerX+cartesianPoint[0], centerY+cartesianPoint[1], opacity);
}
//second circle green undertone
RC.setPenColor(.4, .4, .2)
var limX = w-1;
var limY = h-1;
// define centerpoint of circle_just right of first circle
var centerX = limX / 5;
var centerY = limY / 2;
// define radius of circle to plot_slightly larger than first circle
var radius = Math.min(w, h) / 25;
// plot a circle using polar coordinates:
// increment a radian angle around the unit circle [0,2pi],
// staying a constant distance from the center
for (var radianAngle = 0; radianAngle < 2*Math.PI; radianAngle += .02) {
// convert polar point (radius, angle) to cartesian for plotting
var cartesianPoint = polarToCartesian(radius, radianAngle);
// plot cartesian point (x,y)
// result of polarToCartesian function is two-element array-- [x,y]
RC.setPixel(centerX+cartesianPoint[0], centerY+cartesianPoint[1], opacity);
}
//Third circle_dark red
RC.setPenColor(.6, .2, .1)
// initialize variables
// opacity will stay full throughout loop
var opacity = 1;
// define limit x and y to help stay on canvas
var limX = w-1;
var limY = h-1;
// define centerpoint of circle_offcenter
var centerX = limX / 3;
var centerY = limY / 2;
// define radius of circle to plot_double plus size over second circle
var radius = Math.min(w, h) /10;
// plot a circle using polar coordinates:
// increment a radian angle around the unit circle [0,2pi],
// staying a constant distance from the center
for (var radianAngle = 0; radianAngle < 2*Math.PI; radianAngle += .02) {
// convert polar point (radius, angle) to cartesian for plotting
var cartesianPoint = polarToCartesian(radius, radianAngle);
// plot cartesian point (x,y)
// result of polarToCartesian function is two-element array-- [x,y]
RC.setPixel(centerX+cartesianPoint[0], centerY+cartesianPoint[1], opacity);
}
//Fourth circle_red
RC.setPenColor(.9, .1, 0)
var limX = w-1;
var limY = h-1;
// define centerpoint of circle_center
var centerX = limX / 2;
var centerY = limY / 2;
// define radius of circle to plot
var radius = Math.min(w, h) / 7;
// plot a circle using polar coordinates:
// increment a radian angle around the unit circle [0,2pi],
// staying a constant distance from the center
for (var radianAngle = 0; radianAngle < 2*Math.PI; radianAngle += .02) {
// convert polar point (radius, angle) to cartesian for plotting
var cartesianPoint = polarToCartesian(radius, radianAngle);
// plot cartesian point (x,y)
// result of polarToCartesian function is two-element array-- [x,y]
RC.setPixel(centerX+cartesianPoint[0], centerY+cartesianPoint[1], opacity);
}
// release object referencess
RC = null;