Closed villares closed 9 months ago
This is useful! Thank you for posting this.
I can't remember if there is already such a page, forgive me if there is already.
The page doesn't exist but it should. I'll use these comments as a starting point. Please add to this as you think of things.
@marcovicci , you might think of things that should be included here also.
The reason behind the is_key_pressed
and is_mouse_pressed
stuff has to do with Python and imported mode. In Java, you can have a variable and a method with the same name. For example, Processing has the float frameRate
for the actual frame rate and frameRate()
to set the desired frame rate. Java can distinguish between the two when it compiles your code. Python does not have the ability for multiple things to share the same name.
The is_key_pressed
and is_mouse_pressed
stuff is a bit different because the key_pressed()
and mouse_pressed()
functions are defined by the user, not py5. But in imported mode, there would be a name conflict that would interfere with how imported mode works. Therefore, the is_
prefix was added.
Let's move this to discussions!
If things get moving we could open a new issue on py5coding/py5book maybe?
At the discussions forum: https://github.com/py5coding/py5generator/discussions/389
I can't remember if there is already such a page, forgive me if there is already.
Things to mention:
Te most basic stuff is snake_case instead of camelCase:
mouseX
becomesmouse_x
, andnoFill()
becomesno_fill()
mousePressed
variable becomesis_mouse_pressed
but the event function users can define,void mousePressed(){ ...
, in Java, is now defined asdef mouse_pressed(): ...
.keyPressed
,is_key_pressed
for the variable, andkey_pressed
for the event function.No more
import processing.pdf.*;
oradd_library('pdf')
needed for PDF, SVG...Processing's
map(value, start, end, target_start, target_end)
isremap()
because of Python'smap(func, iterable)
Processing's
filter()
isapply_filter()
Processing's
set()
is complicated... You might want to read aboutset_np_pixels()
Use
frame_rate()
to set a target frame rate andget_frame_rate()
to find out the current frame rate (an exponential moving average).PS: Should this be a discussion instead of an issue?