antiboredom / p5.vscode

A VS Code extension to generate new p5.js project files.
Other
56 stars 16 forks source link

Instance Extension Issues #25

Closed darrenjcosborne closed 3 years ago

darrenjcosborne commented 3 years ago

I'm not sure if it's me or the p5.vscode plugin... I am trying to make a simple clock sketch (similar to https://www.youtube.com/watch?v=E4RyStef-gY), except that I have written with a p5 instance:

function clockGUI() {

    var object = function(p5){

        p5.setup = function() {
            p5.createCanvas(window.innerWidth, 600);
            p5.textSize(20); 
            p5.angleMode(p5.DEGREES);
        }

        p5.draw = function() {

            p5.background(215, 255, 215);

            p5.stroke(0, 0, 0);
            p5.strokeWeight(8);

            //p5.rotate(-90); //--> does not work

            p5.arc(400, 150, 250, 250, -90, 270)
        }
    }

    var objectP5 = new p5(object);
}

rotate --> Simply does not draw the arc...

What am I doing wrong? Any help appreciated... thanks

antiboredom commented 3 years ago

hi @darrenjcosborne - this is actually not quite the right place to ask p5 questions, as this is just the home for my p5 vscode extension and not p5 in general. For general p5 bugs you should take a look at: https://github.com/processing/p5.js

That said, I believe your issue is that you need to call the translate function before rotation, translating to where you want to draw, and then draw your arc at 0,0. Something like this:

p5.translate(400, 150)
p5.rotate(-90);
p5.arc(0, 0, 250, 250, -10, 270)