Draw Block Parameters

On many blocks, I’ll refer to the “draw” block, there are arrows on the left to reveal spots for more parameters.

First, am I using the right vocabulary? Second what are the parameters that you might add to the draw block?

Thanks

In Javascript, you can pass values into a function. The Draw Loop is a function. Off the top of my head, I can’t think of any values you would want to pass into a draw loop, so maybe there is no practical use of it. But since it is a function block, it can be used that way. I’m sure some of the javascript experts might think of a valid use of it.

Mike

1 Like

Thanks for the reply. I can’t think of anything either, but now I have the right vocabulary, “parameters”.

1 Like

@ljohns

Parameters seem strange to send to the draw block, but they may be used if a student defines their own function elsewhere in the code.

Here is a quick example where I send an x and a y position of a drawing to a function so that I can group the code into one call. Here is a link to the project https://studio.code.org/projects/gamelab/H2xPGzMyLe4ZZqg75bN_uuZM_hJEKoDAC_O9xYSa4Ts

World.frameRate = 10 ;


function draw() {
  
  background("white");
  drawFace(randomNumber(90,110),randomNumber(90,100));
  
}


function drawFace(xPos, yPos)
{
  fill("blue");
  rect(xPos,yPos);
  
  fill("blue");
  rect(xPos+100,yPos);
  
  fill("red");
  ellipse(xPos+100,yPos+100, 200,40);
  
  
}

This is actually a bug that I’ve passed along to our engineers - we include that arrow for functions that students have created so they can add support for parameters if they wish, but it shouldn’t be included on functions that we’ve create that we know shouldn’t take a parameters. If you put a parameter in there it’ll just be ignored.

1 Like