Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8509123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T03:20:58+00:00 2026-06-11T03:20:58+00:00

Does anybody know what’s wrong with this code? It shows nothing in the browser.

  • 0

Does anybody know what’s wrong with this code? It shows nothing in the browser.

My intention is to draw two eyes based on the mouse location. So I define an Eye class and then call its draw method with variable mouseX and mouseY.
However, it shows nothing on the browser.

Also, I wonder how to detect the size of the browser because screen.width and screen.height don’t seem to work within a browser.

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="processing.js"></script>
<script type="text/processing" data-processing-target="mycanvas">


void setup(){
    size(400,400);
    smooth();
    background(225);
    }

if (mousePressed){
    Face.draw(mouseX,mouseY);}

class Face{
    float x,y,a;

    Face(float ax,float ay){
    x=ax;
    y=ay;
    a=random(1,5);}

    void draw{

        noFill();
        stroke(0);
        //eye1
        ellipse(x+2.2*a,y-a,a/2,a/2);
        //eyelashes1
        arc(x+2.2*a,y-.5*a,1.2*a,1.2*a,PI,2*PI);
        //eyebrows1
        arc(x+3*a,y-.3,2*a,2*a,5/4*PI,9/4*PI);

        //eye2
        ellipse(x-2.2*a,y-a,a/2,a/2);
        //eyelashes2
        arc(x-2.2*a,y-.5*a,1.2*a,1.2*a,PI,2*PI);
        //eyebrows2
        arc(x-3*a,y-.3,2*a,2*a,5/4*PI,9/4*PI);



    }


    }


</script>
</head>
<body></body>
<canvas id="mycanvas"></canvas>
</html>

I’m a beginner, so I don’t know if my problem is stupid or not.

But any hint is welcomed:)

Btw how to add color to the code on stackoverflow?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T03:21:00+00:00Added an answer on June 11, 2026 at 3:21 am

    There are a some problems with your script.

    Related with the html page:

    • You have to declare the encoding of the document in the header section: <meta charset="utf-8">
    • The canvas element should be included inside the html body.

    Related with the processing code:

    • The processing script needs at least one setup() function and one draw() function. You defined a draw() method in your Face class, but not the main draw() function (by the way, you missed the brackets in your draw() method).
    • The mousePressed functionality should be included inside the main draw() method.
    • You need at least to declare one instance of your Face class (inside the setup() function). For example: Face myFace = new Face(10, 10);.
    • And probably more syntax errors inside your draw() method…

    My recommendations:

    • Start with something simpler: The more lines you write from scratch, the harder to debug. Try to draw first just an ellipse and incrementally add more things to your code.
    • Keep your processing script in a separate file. It’s cleaner and you can debug it using the processing editor or the processing online sketch:
        <!DOCTYPE html>
        <html lang="en">
            <head>
                <meta charset="utf-8">
                <title>Testing testing</title>
                <script type="text/javascript" src="processing.js"></script>
            </head>
    
            <body>
                <canvas id="my-sketch" data-processing-sources="my-sketch.pde"></canvas>
            </body>
        </html>
    
    • Check this tutorial to get some ideas about objects and classes in processing.
    • The syntax in processing is very similar to java, and there’re a lot more resources for understanding the basics of OOP for that language. Just google for it.

    For syntax highlightning, look here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does anybody know a correct solution for this code? BOOL maximized = [myWindow isMaximized];
Does anybody know, how it can be, that this code echoes yahoo ? There
Does anybody know why this function, when passed an invalid date (e.g. timestamp) to
Does anybody know how to programmatically disable the keyboard individual letter pop-up? (This blue
does anybody know how to insert code into lyx? just like what is available
Does anybody know how to parse a string below to get these two strings:
Does anybody know of a javascript library for auto generating a form based upon
Does anybody know what I'm doing wrong? I'm trying to alter the order on
Does anybody know any how-to that shows tracing and monitoring Silverlight apps with AviCode?
Does anybody know whether this can be achieved in jQuery. Target/addClass to the last

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.