Skip to content

sketch width and height not accessable in classes #18

Open
@skilfullycurled

Description

@skilfullycurled

I suspect this might be a side effect of the fact that CS scopes variables so nicely, but in Proessing the sketch width and height given to size() are normally global, therefore they can be used inside of classes like so:

class Square
    @x = width/2
    @y = height/w

This issue is only limited to classes. The following works as expected:

dimensions: ->
    println "#{width}, #{height}"

setup: ->
    size 400, 400

draw: ->
    println "#{width}, #{height}" #prints 400, 400
    dimensions() prints #prints 400,400

It is another issue that is perhaps low on the list because there is a rather simple work around which is to declare width and height as variable before the setup. Still, might be useful in the readme.md.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions