Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone translate this code from JAVA to PROCESSING ? StickFigure.java /* *

ID: 3604952 • Letter: C

Question

Can someone translate this code from JAVA to PROCESSING?

StickFigure.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package stickman;

/**
*
* @author Akshay Bisht
*/
import java.awt.*;

import java.applet.Applet;
import java.awt.*;

public class StickFigure extends Applet
{
public void paint (Graphics gp)
{
setBackground(Color.black);
setForeground(Color.red);
gp.drawRect(5,5,190,190);
gp.drawOval(90,60,20,20);
gp.drawLine(100,80,100,120);

gp.drawLine(100,100,80,100);
gp.drawLine(100,100,120,75);
gp.drawLine(100,120,85,135);
gp.drawLine(100,120,115,135);
gp.drawString("Stick Figure", 20, 180);

}
  
}

stick.html

<html>
<head>
<title>Stick Figures</title>
</head>
<body>
<p>Hello World Applet

<applet code="StickFigure.class" width=300 height=200>
</applet>

</body>
</html>

Explanation / Answer

The below is the code written in processing

hello-web.html:

<html>
<head>
<title>Stick Figures</title>
<script src="processing-1.0.0.min.js"></script>
</head>
<body>
<p>Hello World Applet
<applet code="StickFigure.class" width=300 height=200>
<canvas data-processing-sources="hello-web.pde"></canvas>
</applet>
</body>
</html>


save the below file hello-web.pde:

void setup() {
background(Color.black);
foreGround(Color.red);
rectanglet(5,5,190,190);
ovall(90,60,20,20);
line(100,80,100,120);

line(100,100,80,100);
line(100,100,120,75);
line(100,120,85,135);
line(100,120,115,135);
println("Stick Figure", 20, 180);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote