Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chao - Fixes #41

Open
soggybag opened this issue Oct 27, 2020 · 0 comments
Open

Chao - Fixes #41

soggybag opened this issue Oct 27, 2020 · 0 comments

Comments

@soggybag
Copy link
Owner

function chaoDrawing(inputX,inputY){

Nice work! I like your function, I was thinking of asking everyone to do this and here you have already done it!

You can take this concept up a notch by also passing the ctx into your function as a parameter. Why? As it is your code replies on a variable outside with specific name. Passing ctx into the function injects this dependancy which makes the function work anywhere.

function draw(ctx, x, y) { ... }

Now you can call draw from anywhere with a context of any name.

const context = document.getElementById('canvas')
draw(context, 100, 400)

// or 

draw(document.getElementById('canvas'), 100, 400)

Make this change, test your work, then submit another pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant