Scratch for Java

Pen::setColor()

Sets the pen's color to the amount. This does only have an effect on new points, which are created by setting the position.

Examples

import org.openpatch.scratch.*;
import org.openpatch.scratch.extensions.pen.*;

public class PenSetColor {
  public PenSetColor() {
    Stage myStage = new Stage(600, 240);
    Pen myPen = new Pen();
    myStage.add(myPen);
    myPen.down();
    myPen.setSize(10);
    myPen.setColor(0, 255, 0);
    myPen.setPosition(120, 45);
    myStage.wait(500);
    myStage.exit();
  }

  public static void main(String[] args) {
    new PenSetColor();
  }
}

View on GitHub

Syntax

Java

.setColor(hue)
.setColor(r, g, b)

Scratch

Parameters

NameData TypeDescription
huefloatA hue value in the range of 0 ... 255
rintA red value in the range of 0 ... 255
gintA green value in the range of 0 ... 255
bintA blue value in the range of 0 ... 255

Return

void