processing-py-site icon indicating copy to clipboard operation
processing-py-site copied to clipboard

document "with statement" usages

Open jdf opened this issue 11 years ago • 2 comments

Builtins that support the with statement should be documented as such. For example

ellipse(0, 50, 33, 33)  # Left circle
with pushStyle():
    strokeWeight(10)
    fill(204, 153, 0)
    ellipse(50, 50, 33, 33)  # Middle circle
ellipse(100, 50, 33, 33)  # Right circle

fill(255)
rect(0, 0, 50, 50)# White rectangle
with pushMatrix():
    translate(30, 20)
    fill(0)
    rect(0, 0, 50, 50)# Black rectangle
fill(100)
rect(15, 10, 50, 50)# Gray rectangle

fill(255)
stroke(180)

with pushMatrix():
    translate(50, 0)
    with beginClosedShape():
        vertex(0, 20)
        vertex(20, 20)
        vertex(20, 40)
        vertex(40, 40)
        vertex(40, 60)
        vertex(0, 60)

    translate(50, 0)
    with beginShape(QUAD_STRIP):
        vertex(0, 20)
        vertex(0, 75)
        vertex(20, 20)
        vertex(20, 75)
        vertex(35, 20)
        vertex(35, 75)
        vertex(55, 20)
        vertex(55, 75)

    translate(70, 0)
    with beginShape(LINES):
        vertex(0, 20)
        vertex(55, 20)
        vertex(55, 75)
        vertex(0, 75)

with pushMatrix():
    translate(10, 80)
    with beginShape(TRIANGLE_STRIP):
        vertex(0, 75)
        vertex(10, 20)
        vertex(20, 75)
        vertex(30, 20)
        vertex(40, 75)
        vertex(50, 20)
        vertex(60, 75)

    translate(70, 0)
    with beginShape(TRIANGLE_FAN):
        vertex(35.5, 50)
        vertex(35.5, 15)
        vertex(70, 50)
        vertex(35.5, 85)
        vertex(0, 50)
        vertex(35.5, 15)

    translate(90, 0)
    with beginShape(QUADS):
        vertex(0, 20)
        vertex(0, 75)
        vertex(20, 75)
        vertex(20, 20)
        vertex(35, 20)
        vertex(35, 75)
        vertex(55, 75)
        vertex(55, 20)


jdf avatar Aug 25 '14 02:08 jdf

Does this mean?

  1. a new "with.xml" reference page
  2. cross-referenced to each of the pages beginClosedShape, beginShape, pushMatrix, pushStyle, ...etc
  3. and each of those pages a mentions "works with with" and provides an example

jeremydouglass avatar Aug 14 '19 23:08 jeremydouglass

I think that each builtin that supports with should say so, and show an example.

jdf avatar Aug 15 '19 02:08 jdf