Scratch for Java

Pen::setSize()

Sets the pen's size to the percentage.

Examples

import org.openpatch.scratch.Stage;
import org.openpatch.scratch.extensions.pen.Pen;
 
public class PenSetSize {
  public PenSetSize() {
    Stage myStage = new Stage(600, 240);
    Pen myPen = new Pen();
    myStage.add(myPen);
    myPen.setSize(10);
    while (myStage.getTimer().forMillis(3000)) {
      myPen.down();
      if (myStage.getTimer().everyMillis(500)) {
        myPen.setSize(myStage.pickRandom(5, 20));
      }
      myPen.goToRandomPosition();
      myPen.up();
      myStage.wait(200);
    }
    myStage.exit();
  }
 
  public static void main(String[] args) {
    new PenSetSize();
  }
}
 

View on GitHub

Syntax

Java

.setSize(percentage)

Scratch

set pen size to (50) %

Parameters

Name Data Type Description
percentage float A value in percent.

Return

void

setSize()