From 285e8ad9f98dcd4ff28b98bf4146a22d12fa6cb5 Mon Sep 17 00:00:00 2001 From: Tushar <30565750+tushar5526@users.noreply.github.com> Date: Sun, 18 Sep 2022 15:57:11 +0530 Subject: [PATCH] Add examples for create_graphics (#393) * Add examples for create_graphics * typo fix --- docs/examples/index.rst | 1 + docs/examples/structure/create graphics.rst | 66 +++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 docs/examples/structure/create graphics.rst diff --git a/docs/examples/index.rst b/docs/examples/index.rst index a8b44471..057baa71 100644 --- a/docs/examples/index.rst +++ b/docs/examples/index.rst @@ -19,6 +19,7 @@ Structure structure/redraw structure/function structure/recursion + structure/create graphics Transform ######### diff --git a/docs/examples/structure/create graphics.rst b/docs/examples/structure/create graphics.rst new file mode 100644 index 00000000..7dcb4d7f --- /dev/null +++ b/docs/examples/structure/create graphics.rst @@ -0,0 +1,66 @@ +*************** +Create Graphics +*************** + +.. raw:: html + + +
+ + +The ``draw_target()`` function makes it easy to draw many distinct targets. Each call to ``draw_target()`` specifies the position, size, and number of rings for each target. + +.. code:: python + + from p5 import * + + pg = None + + def setup(): + global pg + size(710, 400) + pg = create_graphics(400,250) + + def draw(): + fill(0, 12) + rect(0, 0, width, height) + fill(255) + no_stroke() + ellipse(mouse_x, mouse_y, 60, 60) + + pg.background(51) + pg.no_fill() + pg.stroke(255) + pg.ellipse(mouse_x - 150, mouse_y - 75, 60, 60) + + # Draw the offscreen buffer to the screen with image() + image(pg, 150, 75) + + if __name__ == '__main__': + # Create Graphics is only available in skia + run(renderer='skia')