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

begin_contour and end_contour not working #172

Closed
ziyaointl opened this issue May 28, 2020 · 0 comments
Closed

begin_contour and end_contour not working #172

ziyaointl opened this issue May 28, 2020 · 0 comments
Labels

Comments

@ziyaointl
Copy link
Member

ziyaointl commented May 28, 2020

Describe the bug
An error was thrown when using begin_contour and end_contour. If I delete the block of code that describes the contour (i.e. leaving the code that uses begin_shape and end_shape) the program runs as expected.

To Reproduce

from p5 import *

def draw():
	translate(50, 50)
	stroke(255, 0, 0)
	begin_shape()
	# Exterior part of shape, clockwise winding
	vertex(-40, -40)
	vertex(40, -40)
	vertex(40, 40)
	vertex(-40, 40)
	# # Interior part of shape, counter-clockwise winding
	begin_contour()
	vertex(-20, -20)
	vertex(-20, 20)
	vertex(20, 20)
	vertex(20, -20)
	end_contour()
	end_shape('CLOSE')

run(mode="P2D")

Expected behavior
A square ring is displayed on the screen.
Example from https://p5js.org/reference/#/p5/beginContour

System information:

  • p5 release (version number or latest commit): commit fb9373c
  • Python version: Python 3.7.7
  • Operating system: Ubuntu 18.04 LTS

Additional context
Stderr:

WARNING: Traceback (most recent call last):
  File "/home/ziyao/Github/p5/test.py", line 34, in <module>
    run(mode="P2D")
  File "/home/ziyao/Github/p5/p5/sketch/userspace.py", line 161, in run
    app.run()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/_default_app.py", line 62, in run
    return default_app.run()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/application.py", line 152, in run
    return self._backend._vispy_run()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 194, in _vispy_run
    self._vispy_process_events()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 183, in _vispy_process_events
    timer._tick()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/backends/_glfw.py", line 516, in _tick
    self._vispy_timer._timeout()
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/app/timer.py", line 168, in _timeout
    count=self.iter_count)
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/util/event.py", line 455, in __call__
    self._invoke_callback(cb, event)
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/util/event.py", line 475, in _invoke_callback
    self, cb_event=(cb, event))
  << caught exception here: >>
  File "/home/ziyao/.local/lib/python3.7/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    cb(event)
  File "/home/ziyao/Github/p5/p5/sketch/base.py", line 105, in on_timer
    self.draw_method()
  File "/home/ziyao/Github/p5/test.py", line 32, in draw
    end_shape('CLOSE')
  File "/home/ziyao/Github/p5/p5/core/primitives.py", line 70, in wrapped
    draw_shape(s)
  File "/home/ziyao/Github/p5/p5/core/primitives.py", line 588, in draw_shape
    draw_shape(child_shape)
  File "/home/ziyao/Github/p5/p5/core/primitives.py", line 582, in draw_shape
    p5.renderer.render(shape)
  File "/home/ziyao/Github/p5/p5/sketch/renderer2d.py", line 219, in render
    vertices = shape._draw_vertices
  File "/home/ziyao/Github/p5/p5/core/shape.py", line 363, in _draw_vertices
    self._retriangulate()
  File "/home/ziyao/Github/p5/p5/core/shape.py", line 333, in _retriangulate
    segments=triangulation_segments, holes=self.get_interior_point(self.contour))
  File "/home/ziyao/Github/p5/p5/core/shape.py", line 313, in get_interior_point
    if vertex not in shape_vertices:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> for Event
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 2
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 4
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 8
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 16
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 32
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 64
ERROR: Invoking <bound method Sketch.on_timer of <Sketch (Glfw) at 0x7efe85c96d10>> repeat 128
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant