xxxxxxxxxx
44
let xMin = -200;
let xMax = 200;
let yMin = -200;
let yMax = 200;
let xScale = 1;
let yScale = 1;
function setup() {
createCanvas(400, 400);
xScale = width / ()
}
function draw() {
background(220);
strokeWeight(3);
translate(width/2, height/2);
scale(1, -1);
stroke(0);
point(0, 0);
stroke('red');
point(100, 100);
stroke('blue');
point(-100, -100);
// axes
stroke(0);
strokeWeight(1);
line(-width/2, 0, width/2, 0); //x-axis
line(0, height/2, 0, -height/2); //y-axis
graphF();
}
// f(x) = ???
function graphF() {
for(let x = -width/2; x <= width/2; x += 0.01) {
let y = x*x; //f(x) = x^2
point(x, y);
}
}