Git Product home page Git Product logo

p5's People

Contributors

1deadpixl avatar abhikpal avatar andy-python-programmer avatar antiboredom avatar arihantparsoya avatar asukaminato0721 avatar cuppajoeman avatar dbhavsar76 avatar dependabot[bot] avatar edurojasr avatar github-actions[bot] avatar hansimov avatar hunterwilkins2 avatar hx2a avatar janbehrens avatar jeremydouglass avatar kartik-byte avatar manindra29 avatar mark-summerfield avatar mr-sunglasses avatar nakul-shahdadpuri avatar niklasr22 avatar pszemsza avatar renetc avatar tabreturn avatar tushar5526 avatar vaishnavsm avatar willtryagain avatar yogeshhk avatar ziyaointl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

p5's Issues

Blank sketch window on Mac

Test script:

from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)

def draw():
    if mouse_is_pressed:
        fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
    else:
        fill(255, 15)

    circle_size = random_uniform(low=10, high=80)

    circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
    background(204)

run()

Expected behavior:
First example on repository Read-me
Actual behavior
Window opens, but no drawing occurs
Errors produced (if any):
2017-10-09 21:39:53.023 Python[1582:13154] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to /var/folders/9t/v5g1f4f12cq4fylgk0kbr6200000gn/T/org.python.python.savedState
p5 version:
p5-0.3.0a2
Python version:
3.6.3
Operating System:
Mac OS 10.11.6 (El Capitan)
screen shot 2017-10-09 at 9 41 09 pm

Strange flickering and graphical errors occurring on Arch Linux

Test script: p5-examples/basics/form/shape_primitives.py

Expected behavior:
primitives_expected-1

Actual behavior: In more complex sketches involving moving graphics, objects in which are moving begin to glitch at random intervals rather than the sketch turning to black periodically.
primitives_actual

Note: I'm unsure if this is an upstream issue or not, but I've only begun seeing it with p5 so far.

i3-gaps version (fork of i3-wm): 4.14.1-2
Xorg version: 1.19.6-2
pyglet version: 1.3.0
mesa version: 17.3.1-2

Errors produced (if any): None

p5 version: e78c4a8

Python version: Python 3.6
Operating System: Arch Linux (4.14.10-1-ARCH x86_64)

vsync() userspace function

As brought up in a previous issue I had posted (at p5/issues/25), I was having an issue with flickering and graphical errors on my laptop. I discovered that the solution was to turn on Vsync, but this can only be done by editing the module and cannot be done in userspace.

Implement saveFrame()

I tried to save a frame but saw that it wasn't in this library, so I looked up how to do it in pyglet:

pyglet.image.get_buffer_manager().get_color_buffer().save(filename)

You could then make a save_frame(filename) function that maybe parses the string like processing does to replace the "###" with the right number, and then it runs that line of code.

It's not urgent or anything, but I think it'd be nice to have

NoSuchConfigException while importing p5 on Raspbian

Here's the whole error:

Traceback (most recent call last):
  File "/usr/local/lib/python3.5/site-packages/p5/sketch/base.py", line 50, in <module>
    config = screen.get_best_config(template)
  File "/usr/local/lib/python3.5/site-packages/pyglet/canvas/base.py", line 161, in get_best_config
    raise window.NoSuchConfigException()
pyglet.window.NoSuchConfigException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    from p5 import *
  File "/usr/local/lib/python3.5/site-packages/p5/__init__.py", line 19, in <module>
    from .sketch import *
  File "/usr/local/lib/python3.5/site-packages/p5/sketch/__init__.py", line 19, in <module>
    from .base import *
  File "/usr/local/lib/python3.5/site-packages/p5/sketch/base.py", line 53, in <module>
    config = screen.get_best_config(template)
  File "/usr/local/lib/python3.5/site-packages/pyglet/canvas/base.py", line 161, in get_best_config
    raise window.NoSuchConfigException()
pyglet.window.NoSuchConfigException

I've tried all I can to fix it, I've searched for hours, I've enabled the experimental OpenGL drivers, I reinstalled everything involved in p5, all the standard stuff. I know you probably can't fix this, since it's probably a problem with Raspbian, but I just wanted to let you know.

mouse_pressed() not working

I have an installation of python 3.5.4 which has numerous modules installed, and when I run my code with that installation, everything works fine. I created a fresh installation of python, also at 3.5.4, and when I run my code on that, which only has p5 and its dependencies, everything works, except mouse_pressed() is not called when I click. My thought is that it might be one of the modules I have installed on my old installation that might be required for mouse_pressed() to work. There are too many for me to try them one by one though.

title() sometimes only sets the first character

Test script:

# put your test script here
from p5 import *
def setup():
    title('My Sketch')

def draw():
    background(245, 245, 245)

run()

Expected behavior:
I expect the title to show 'My Sketch'.
Actual behavior
The title is shown as 'M'.
Errors produced (if any):

p5 version:
0.4.0a1.dev2
Python version:
3.7.0
Operating System:
Ubuntu 16.04.5 LTS (64-bit)

Circle edges are looking 'chunky'

Test script:

from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)

def draw():
    if mouse_is_pressed:
        fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
    else:
        fill(255, 15)

    circle_size = random_uniform(low=10, high=80)

    circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
    background(204)

run()

Expected behavior:
The edges of the circle to be smooth. I referenced the GIF in the readme

Actual behavior
When I use the example script, I am seeing very chunky edges. I am on a UHD monitor, and I tried running the script with the pixels 1:1 as well as my normal scaled 150%. I suspect this is some sort of OpenGL thing. Either a scaling issue or a dpi issue.
Please let me know what other information I can provide!

image

Errors produced (if any):

p5 version:
p5==0.3.0a2

  • numpy [required: Any, installed: 1.13.3]
  • pyglet [required: Any, installed: 1.3.0]
    • future [required: Any, installed: 0.16.0]
  • PyOpenGL [required: Any, installed: 3.1.0]

Python version:
Python 3.5
Operating System:
Windows10

Bug in reference/environment/cursor.py example

Test script:

This is the cursor.py example:

# put your test script here
from p5 import *

def draw():
    if mouse_x < 180:
        cursor('CROSS')
    else:
        cursor('HAND')

run()

Expected behavior:

Actual behavior

Errors produced (if any):

$ py37 cursor.py 
WARNING: Traceback (most recent call last):
  File "cursor.py", line 9, in <module>
    run()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/p5/sketch/userspace.py", line 142, in run
    app.run()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/_default_app.py", line 62, in run
    return default_app.run()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/application.py", line 142, in run
    return self._backend._vispy_run()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 194, in _vispy_run
    self._vispy_process_events()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 183, in _vispy_process_events
    timer._tick()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 516, in _tick
    self._vispy_timer._timeout()
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/app/timer.py", line 168, in _timeout
    count=self.iter_count)
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/util/event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/util/event.py", line 475, in _invoke_callback
    self, cb_event=(cb, event))
  << caught exception here: >>
  File "/home/mark/opt/python37/lib/python3.7/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    cb(event)
  File "/home/mark/opt/python37/lib/python3.7/site-packages/p5/sketch/base.py", line 116, in on_timer
    self.draw_method()
  File "cursor.py", line 5, in draw
    cursor('CROSS')
  File "/home/mark/opt/python37/lib/python3.7/site-packages/p5/sketch/userspace.py", line 244, in cursor
    raise NotImplementedError
NotImplementedError
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> for Event
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 2
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 4
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 8
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 16
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 32
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 64
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7f81ba28d4e0>> repeat 128

p5 version:
0.4.0a1.dev2
Python version:
3.7.0
Operating System:
Ubuntu 16.04.5 LTS (64-bit)

Stroke on overlaping shape

Describe the bug
When two 2d figure overlap themself, appaer the stroke of the two objects ...

sans titre

I don't know if it's a bug or not .. I found an article about the same subjet for "p5js"
processing/p5.js#2938

To Reproduce
This is the code used :

from p5 import *

pos=0

def setup():
    size(400,400)

def draw():
    global pos;
    background(125)
    fill(255);
    rect((20,0),30,400)
    rect((200,0),100,100)
    ellipse((200,300),100,100)
    
    # Trace du rectangle flottant
    rect((pos,pos),50,50)
    pos=pos+1
    if pos>350:
        pos=0;

System information:

  • p5 release 0.5.0
  • Python version: 3.6
  • Operating system: Ubuntu 18.04

background() doesn't work as expected when called from setup().

Test script:

from p5 import *

def setup():
background(255, 0, 0)
size(600, 600)
no_loop()

def draw():
circle((300, 300), 50, "CENTER")

run()

Expected behavior: Set background color to red.

Actual behavior: background color set to black -no matter what arguments are used.
(background() works as expected when called from draw()).

Errors produced (if any): No errors.

p5 version: v0.4.0a1.dev2

Python version: 3.7.0
Operating System: Windows 10

Basic execution error works in IDLE not in .py file

Test script:

# put your test script here
from p5 import *
size(500,500)
run()

Expected behavior:
run a 500 x 500 window

Actual behavior
error

Errors produced (if any):
Traceback (most recent call last):
File "C:\Users\jayden\Desktop\p5.py", line 1, in
from p5 import *
File "C:\Users\jayden\Desktop\p5.py", line 2, in
size(500,500)
NameError: name 'size' is not defined

idle works fine

the script returns an error

p5 version:
p5 (0.3.0a2)

Python version:
3.5
Operating System:
windows

Display a video

Hi guys,

Just wanted to know if it was possible to display a video with p5py or the Video library isn't implemented yet.

Thanks

raise an error, when Vector.normalize() tries to normalize a "zero-vector"

Test script:
Problem is, when you try to normalize a Vector Object, which only has zero value, it tries to divide
them by 0 (their current magnitude), setting the values to nan. It would be handy if a error would pop up.

from p5 import *

x = Vector(0, 0)

print(x.magnitude)
x.normalize()
print(x)
print(x.magnitude)

Expected behavior:

0.0
ValueError(...)

Actual behavior

0.0
Vector(nan, nan, nan)
nan

Errors produced (if any):

p5 version:
0.3.0a2

Python version:
Python 3.6.4

Operating System:
MacOS

Mouse_x and mouse_y returning negative values

Test script:

from p5 import *
def setup():
    size(640, 360)
    background(255)

def draw():
    print(mouse_x, mouse_y)

run()

Expected behavior:
mouse_x and mouse_y respectively return values in the intervals [0, width] and [0, height]

Actual behavior
When quickly moving mouse outside of the output screen, negative values, and values exceeding width and height, get returned by mouse_x and mouse_y.

p5 version:
p5-0.3.0a2
Python version:
3.6.3
Operating System:
Mac OS 10.11.6 (El Capitan)

Error due to calling show() on uninitialized default_sketch.

Test script:

# put your test script here
from p5 import *
exit()

Expected behavior:
Should actually exit.

Actual behavior
Does not exit()

Errors produced (if any):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jessop/git/vendor/p5/p5/sketch/userspace.py", line 213,
in exit
    default_sketch.show(visible=False)
AttributeError: 'NoneType' object has no attribute 'show'

p5 version:
'0.4.0a1.dev2' from git 6d82eb8

Python version:
3.6.5
Operating System:
Manjaro

matmul operator on Python version <= 3.4 (rel: #18)

Test script:

from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)

def draw():
    if mouse_is_pressed:
        fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
    else:
        fill(255, 15)

    circle_size = random_uniform(low=10, high=80)

    circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
    background(204)

run()

Expected behavior:
The video in the README

Actual behavior
An error is thrown.

Errors produced (if any):

Traceback (most recent call last):
  File "C:/Users/User/Dropbox/Programs/p5play.py", line 1, in <module>
    from p5 import *
  File "C:\Python34\lib\site-packages\p5\__init__.py", line 19, in <module>
    from .sketch import *
  File "C:\Python34\lib\site-packages\p5\sketch\__init__.py", line 19, in <module>
    from .base import *
  File "C:\Python34\lib\site-packages\p5\sketch\base.py", line 29, in <module>
    from ..opengl import renderer
  File "C:\Python34\lib\site-packages\p5\opengl\__init__.py", line 19, in <module>
    from .renderer import *
  File "C:\Python34\lib\site-packages\p5\opengl\renderer.py", line 33, in <module>
    from ..pmath import matrix
  File "C:\Python34\lib\site-packages\p5\pmath\__init__.py", line 20, in <module>
    from .vector import *
  File "C:\Python34\lib\site-packages\p5\pmath\vector.py", line 321
    return np.arccos( (self @ other) / (self.magnitude * other.magnitude))
                            ^
SyntaxError: invalid syntax

p5 version:
Newest version

Python version:
Python 3.4.0

Operating System:
Windows 10

Vector.random_2D() only outputs positive values for vector components.

Test script:

from p5 import *

def setup():
	size(500,500)

def draw():
	background(255)
	direction = Vector.random_2D()
	direction.magnitude *=100
	translate(width/2, height/2)
	line((0,0), (direction.x, direction.y))
	
run()

Expected behavior:
The line should point at random directions.

Actual behavior
The line only ever points toward the positive quadrant.

p5 version: 0.3.0a2
Python version: 3.6.2
Operating System: Windows 10

Mouse click not working

Test script:

# put your test script here
from p5 import *
# Example sketch on homepage

Expected behavior:
Example sketch on homepage

Actual behavior
Red circles aren't drawn when I click.

Errors produced (if any):
No errors produced.

p5 version:
0.3.0a2

Python version:
Python 3.6

Operating System:
Windows 10

No module named 'OpenGL'

Test script:

from p5 import *

Expected behavior:

Import p5py

Actual behavior

Error.

Errors produced (if any):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/__init__.py", line 19, in <module>
    from .sketch import *
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/sketch/__init__.py", line 19, in <module>
    from .base import *
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/sketch/base.py", line 29, in <module>
    from ..opengl import renderer
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/opengl/__init__.py", line 19, in <module>
    from .renderer import *
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/opengl/renderer.py", line 26, in <module>
    from . import gl
  File "/Users/kyle/Library/Python/3.6/lib/python/site-packages/p5/opengl/gl.py", line 14, in <module>
    import OpenGL
ModuleNotFoundError: No module named 'OpenGL'

p5 version:

p5 (0.3.0a1)

Python version:

Python 3.6.2

Operating System:

macOS 10.12.6

Related Project

Dear Abhik Pal, via Daniel Shiffman i came to you after i let him know that i was working on a similar project. in your github repos it seems that p5py is in very early stages. I myself am working on a p5py library too. i have got about 20-30% of the p5js funcitonality in. i thougth i'd just let you know. maybe we could work together on it because to me it seems unnecessary to do double work. since my version uses tkinter (in stead of pyglet) i really have similar support as p5js has since i also simulate a few (and later more) of the DOM library (so i can create paragraphs and buttons and text inputs). please let me know what you think.

Sketch window flickers when `background()` is missing inside `draw()`

Test script:

from p5 import *

def setup():
    size(800, 600)
    background(51)

def draw():
    fill(255)
    rect((100, 100), 100, 100)

run()

Expected behavior: The sketch should draw a yellow-ish square on a gray-ish background.

Observed behavior: The yellow-ish square is visible, however, the sketch window flickers from gray to black (unlike #5, only the sketch window flickers, not the whole screen). The sketch shows the intended behavior when a call to background() is added inside draw().

Branch:: develop
Commit: e776861
Python version: 3.6.1
OS: Debian 9

#49 breaks the documentation auto generation

#49 was recently merged into develop. It does fix the very critical retina issue on mac, but it breaks the documentation auto-generation.

Running

$ make html

inside the docs folder produces a traceback with:

Running Sphinx v1.6.6

Configuration error:
There is a programable error in your configuration file:

Traceback (most recent call last):
  File ".../lib/python3.6/site-packages/sphinx/config.py", line 157, in __init__
    execfile_(filename, config)
  File ".../lib/python3.6/site-packages/sphinx/util/pycompat.py", line 150, in execfile_
    exec_(code, _globals)
  File "conf.py", line 59, in <module>
    import p5
  File ".../p5/__init__.py", line 19, in <module>
    from .sketch import *
  File ".../p5/sketch/__init__.py", line 19, in <module>
    from .base import *
  File ".../p5/sketch/base.py", line 59, in <module>
    actual_width, actual_height = window.get_viewport_size()
ValueError: not enough values to unpack (expected 2, got 0)

Implementation -- running sketches

I have been looking through your code and i found something i didn't use: you use decorators for the functions. i am not sure which way is the best but i do it differently. i look back in the stack and find from where p5 is imported. then i import the draw and setup (and maybe more) functions to the p5.py module. both can work. with my way the sketch looks a bit neater without the decorators, you's might be easier to handle in the p5.py module. I'm not sure which is best but i thought i'd let you know. you can remove this issue when you read it i think.

Also: i have got someone who wants to help too!

I only get a blank window on my Mac

I tried to ru p5 on my MacBook Pro with MacOS X, 10.9. and Anaconda Python 3.5.3 (x86, 64 Bit. This is my example code:

from p5 import *

def setup():
    size(400, 200)
    title("Dein Titel hier …")

def draw():
    background(255, 100, 150)
    center = (width / 2, height / 2)
    fill(0)
    rect_mode("RADIUS")
    square(center, 50)

run()

I only get a blank window like this:

p5whitewindow
I tried several of the examples and get always the same result (only a blank window). And it doesn't matter if I started the sketch fom the terminal, the interpreter or within TextMate. The result was always the same.

key variable not working

I can't use key as showed in the docs, the comparison always returns false.
When I tried to print key it shows it isn't the key pressed, but pyglet.window.key.

Looking at https://github.com/p5py/p5/blob/master/p5/sketch/events.py I was able to get the key using event.key (but it's always uppercase) or builtins.key.

Test script:

from p5 import *

def key_pressed(event):
    print('key: {}'.format(key));
    print('event.key: {}'.format(event.key));
    print('builtins.key: {}'.format(builtins.key));

run()

Actual behavior
When I press a:

key: <module 'pyglet.window.key' from '/home/barbara/.local/lib
/python3.5/site-packages/pyglet/window/key.py'>
event.key: A
builtins.key: a

p5 version: 0.3.0a2
Python version: 3.5.2
Operating System: Ubuntu 16.04.4 LTS

status update

Hey! you can delete this post whenever you read it. We implemented all 2D primitives (+ all position functions like translate and rotate) and its stable and on github (github.com/jonay2000/p5.py). looking at the p5.js functions we're about 10% done. (but more if you account for the fact that many p5js functions are inspired by python, for example the append() and print() function are builtin of course) It's even at the stage where we can grab simple p5.js scripts and just paste them into the draw loop since we basicly use the same syntax for p5 functions. just wanted to let you know that.

-Jonathan

matmul operator doesn't work on Python 3.4 and less.

from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)

def draw():
    if mouse_is_pressed:
        fill(random_uniform(255), random_uniform(127), random_uniform(51), 127)
    else:
        fill(255, 15)

    circle_size = random_uniform(low=10, high=80)

    circle((mouse_x, mouse_y), circle_size)

def key_pressed(event):
    background(204)

run()

I'm running p5 in a pipenv environment, python 3.4
Every sketch I run yields an error in OSX:

Traceback (most recent call last):
  File "/Users/marcleonard/Projects/p5/sketch.py", line 1, in <module>
    from p5 import *
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/__init__.py", line 19, in <module>
    from .sketch import *
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/sketch/__init__.py", line 19, in <module>
    from .base import *
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/sketch/base.py", line 29, in <module>
    from ..opengl import renderer
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/opengl/__init__.py", line 19, in <module>
    from .renderer import *
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/opengl/renderer.py", line 33, in <module>
    from ..pmath import matrix
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/pmath/__init__.py", line 20, in <module>
    from .vector import *
  File "/Users/marcleonard/.local/share/virtualenvs/p5-vgNG_uZz/lib/python3.4/site-packages/p5/pmath/vector.py", line 321
    return np.arccos( (self @ other) / (self.magnitude * other.magnitude))
                            ^
SyntaxError: invalid syntax

Ubuntu can't find the p5 module.

Test script:

# put your test script here
from p5 import *

I used your example script, copied and pasted it into IDLE in Ubuntu. The file was saved in my home folder. Where should I save these files?
I got this error:
ModuleNotFoundError: No module named 'p5'

Expected behavior:

Expected the module to be found

Actual behavior
The Module wasn't found.

It would help if I knew where the module is to point the PYTHONPATH to it. I thought this would have automatically be done by pip installing.

I had the same problem in Windows but I was able to find the p5 module but I can't find it in Ubuntu.
Errors produced (if any):

p5 version:

Python version: 3.7
Operating System: Ubuntu

Color parsing doesn't work.

Thank you very much for P5

I have been missing NodeBox 2D on Mac.
I really hope your project will grow and succeed.
One of the feature I am waiting the most is the export to PDF

For now here is the bug I encounter

Regards

Test script:

# put your test script here
from p5 import *

c = Color(255)

Errors produced (if any):
Traceback (most recent call last):
File "<pyshell#1>", line 1, in
c = Color(255)
TypeError: init() missing 2 required positional arguments: 'g' and 'b'

mouse_x and mouse_y are affected by translation.

Test script:

from p5 import *

def setup():
    size(1558, 1695)
    background(0)

def draw():
    background(0)
    translate(width/2, height/2)

    p1 = (-300, -300)
    p2 = (mouse_x, mouse_y)
    p3 = (300, -300)

    fill(255)
    triangle( p1, p2, p3 )

if __name__ == "__main__":
    run()

Expected behavior:
expected

Actual behavior
actual

Errors produced (if any): None

p5 version: e78c4a8

Python version: 3.6
Operating System: Arch Linux

There is no link to the reference in the README

Hey nice project. Looking forward to play with it. There seems to be no link to the landing page of the docs in the README. Would be nice to have. The only link is the one to the installation guide. Which also has no link to the landing page.

Trouble installing GLFW on windows

I've downloaded GLFW as instructed.

I've tried:

  • Putting the location of the DLL it into PATH
  • Putting DLL itself into SysWOW64
  • Putting DLL itself into Python36-32\Lib\site-packages\p5

Nothing works, same error.

Test script:

from p5 import *

Errors produced (if any):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\p5\__init__.py", line 19, in <module>
    from .sketch import *
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\p5\sketch\__init__.py", line 19, in <module>
    vispy.use('glfw')
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vispy\util\wrappers.py", line 96, in use
    use_app(app)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vispy\app\_default_app.py", line 47, in use_app
    default_app = Application(backend_name)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vispy\app\application.py", line 49, in __init__
    self._use(backend_name)
  File "C:\Users\andre\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vispy\app\application.py", line 223, in _use
    raise RuntimeError(msg)
RuntimeError: Could not import backend "Glfw":
[WinError 193] %1 is not a valid Win32 application

p5 version:

0.4.0a1

Python version:

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32

Operating System:

Windows 10 x64

Namespace globals?

Question/Feature Request

Is there a good way to wrap all the global variables into a namespace?
I think this would be great not just to for namespace's sake, but to allow external editors to use auto-complete and see function/global variable definitions. Alternatively, I wonder if you could generate mappings for all the global variables.

Add smooth(), stroke_weight()

I'm translating Nature of Code to p5 and I'll list the missing features as I come across them.

Chapter 1:

  • smooth()
  • stroke_weight()

p5 version: 0.3.0a2

Python version: 3.6.2
Operating System: Windows 10

`background()` inside `setup()` behaves strangely

Test script:

from p5 import *

def setup():
    size(600, 500)
    background(200)
    
# def draw():
#     fill(255, 0, 0)
#     rect((250, 250), 100, 200)
    
run()

Expected behavior: The sketch should draw a gray-ish background covering the entire window. When the draw function is uncommented, the background must be maintained.

Actual behavior: The background is partialy drawn, with the right color but does not cover the entire window. When the draw function is uncommented, that background disappears (the rectangle is drawn correctly but on a black background)

p5bug

p5bug2

p5 version: Branch develop, commit 0425714

Python version: Python 3.6.1
Operating System: Kubuntu 17.04

GLFW not found error

Test script:

# from the examples
from p5 import *

def setup():
    size(640, 360)
    no_stroke()
    background(204)
    circle((100, 100), 100)

def draw():
    circle((150, 100), 100)

run()

Expected behavior:
Basic example code
Actual behavior
Does not start
Errors produced (if any):
RuntimeError: Could not import backend "Glfw":
GLFW library not found
p5 version:
0.4.0a1.dev2
Python version:
Python 3.6.1
Operating System:
macOS

screen shot 2018-07-21 at 11 45 00 am

I'm testing on Thonny.org IDE, a beginner's IDE that comes with a Python 3.6.1 environment.
I have done a pip3 install numpy and pip3 install p5 --user as recommended and all the dependencies seem installed alright.

Screen flickers when `print()` is used inside `draw()`

Test script:

from p5 import *

def setup():
    print("inside setup()")

def draw():
    print("inside draw()")

run(draw, setup)

Expected behavior: The terminal should be flooded with inside draw() messages.

Observed behavior: Program does show the expected behavior. However, the whole screen (including sections of the screen outside the sketch window) starts flickering.

Branch:: develop
Commit: e776861
Python version: 3.6.1
OS: Debian 9

Tuple unpacking incompatible with Python 3.4 and less.

    from p5 import *
  File "/Users/arihantparsoya/Documents/p5/p5/__init__.py", line 19, in <module>
    from .sketch import *
  File "/Users/arihantparsoya/Documents/p5/p5/sketch/__init__.py", line 19, in <module>
    from .base import *
  File "/Users/arihantparsoya/Documents/p5/p5/sketch/base.py", line 29, in <module>
    from ..opengl import renderer
  File "/Users/arihantparsoya/Documents/p5/p5/opengl/__init__.py", line 19, in <module>
    from .renderer import *
  File "/Users/arihantparsoya/Documents/p5/p5/opengl/renderer.py", line 33, in <module>
    from ..pmath import matrix
  File "/Users/arihantparsoya/Documents/p5/p5/pmath/__init__.py", line 22, in <module>
    from .curves import *
  File "/Users/arihantparsoya/Documents/p5/p5/pmath/curves.py", line 46
    ret_value = func(*new_args, parameter, **kwargs)
                                       ^
SyntaxError: only named arguments may follow *expression

If tuple unpacking is something we really need we'll have to make Py3.5 a dependency, else we figure out a way to make this backwards compatible.

See #18 and #22 for more context. Also: thanks @parsoyaarihant for pointing this out!

The command-line quit when i close window

Describe the bug
When I execute a script in command-line "exec(open(script.py).read())", the module "p5" close my command-prompt/python ...
With the pyzo IDE, I need relaunch manually the kernel to execute again the script

To Reproduce
Steps to reproduce the behavior (if applicable)

Expected behavior
The use of the "p5" will be more "confortable" if we don"t need to lauch at each time a new "kernel" python

Screenshots
You can see a little video screen capture below
a.zip

System information:

  • p5 release : 0.5.0
  • Python version: 3.6
  • Operating system: Ubuntu 18.04

Can't install p5 package through pip install

Script:

$ pip install numpy
$ pip install p5 --user

Expected behavior:

The numpy and p5 packages are installed without issue

Actual behavior

The numpy package installs but the p5 package does not and returns an error.

Errors produced (if any):

$ pip install p5 --user
Collecting p5
  Using cached https://files.pythonhosted.org/packages/3b/fd/16ab17979a0c47a46d45a76d2821de512fdcccf686c0ca63b142b362ef64/p5-0.3.0a2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/_j/6bwypd896z95ndkxjfpr1rbh0000gn/T/pip-install-0UM8cd/p5/setup.py", line 20, in <module>
        with open(os.path.join(here, 'p5', '__version__.py'), 'r', encoding='utf-8') as f:
    TypeError: 'encoding' is an invalid keyword argument for this function
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/_j/6bwypd896z95ndkxjfpr1rbh0000gn/T/pip-install-0UM8cd/p5/

Additionally...

I tried to download the package from the GitHub page and drop it in /usr/local/lib/python3.6/site-packages/ , but whenever I run python3 (name of test file) it doesn't recognise script that is part of the library, such as run() at the end of the supplied example files (I've tried multiple example files, all of which don't work)

Python version:

V 3.6 is installed on my computer.

Operating System:

macOS Sierra

Vector's magnitude decreases when the vector is rotated.

Hy,

When you animate a vector v with
v.rotate
The magnitude decrease, in fact his is expected.
How would you deal with it ?

Regards

v = Vector(0, 100)
def draw():
    global dt
    dt += 0.1
    v.rotate(dt)
    print(v.magnitude)

Expected behavior:
10000
Actual behavior
9999.999800000001
9999.999000000096
9999.997200000898
9999.994000004783
9999.989000018197
9999.981800055495
9999.97200014456
9999.959200334686
9999.94300070696
9999.923001387619
9999.898802564643

Errors produced (if any):

p5 version:

Python version:
Operating System:

set font and display text

Hi, really excited to have found p5. However, is there a way to set some font and draw some text on the sketch yet? I searched through the code but couldn't find anything around this. Looking forward to see this implemented - Thanks!

Test script:

# put your test script here
from p5 import *
text("Hello P5!", 30, 50)

Expected behavior:
the text "Hello P5!" displayed on the sketch at coordinate( 30,50 )

Actual behavior
Error

Errors produced (if any):
Traceback (most recent call last):
File "test_some_text.py", line 2, in
text("hello P5!", 30, 50)
NameError: name 'text' is not defined

p5 version:
0.4.0a1.dev2

Python version:
3.5.2

Operating System:
Ubuntu 16.04 64 bit

VS Code + pylint integration with p5

Hey,

I've installed the lib on my system and copied the demo file. It runs well, but in VS Code with pylint it's giving me quite a lot of errors and warnings like:

  • E0102:function already defined line 1 (setup function)
  • E0102:function already defined line 1 (draw function)
  • E0602:Undefined variable 'mouse_is_pressed'
  • W0614:Unused import setup from wildcard import
  • and lots more

How can I set this up to play well with VS Code and pylint?
Sorry if this may sound dumb, I'm pretty new to python :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.