Pygame Draw Triangle

EXPERIMENTAL!: meaning this API may change, or disappear in later pygame releases. If you use this, your code will break with the next pygame release.

  1. Pygame Draw Triangle Free
  2. Java Draw Triangle
  3. Pygame Draw Triangle Map
  4. Pygame Draw Triangle Map

Pygame Draw Triangle Free

Draw several shapes to a surface.

Most of the functions accept a color argument that is an RGB triplet. These can also accept an RGBA quadruplet. The color argument can also be an integer pixel value that is already mapped to the Surface's pixel format.

Pygame.draw.rect — draw a rectangle: pygame.draw.polygon — draw a polygon: pygame.draw.circle — draw a circle: pygame.draw.ellipse — draw an ellipse. What you basically do in your loop is filling the canvas with white, drawing a triangle on it from newSurf and drawing a new triangle on newSurf at the exact same place with a different color. After some iterations (when i 5 and the green is the darkest) you rotate newSurf without clearing it and drawing a new triangle on it. Finally, we can draw the triangle on the screen. GlClear(GLCOLORBUFFERBIT) glUseProgram(program) glBindVertexArray(vao) glDrawArrays(GLTRIANGLES, 0, 3) pygame.display.flip. If we want to VAO then we have to enabled firstly. We already enabled this VAO but if there are more VAO. It doesn't work properly.

For all functions the arguments are strictly positional. Only integers are accepted for coordinates and radii.

For functions like rectangle that accept a rect argument any (x, y, w, h) sequence is accepted, though instances are preferred. Note that for a the drawing will not include Rect.bottomright. The right and bottom attributes of a Rect lie one pixel outside of the Rect's boarder.

To draw an anti aliased and filled shape, first use the aa* version of the function, and then use the filled version. For example

Pygame.draw.ellipse – This function is used for drawing a round shape inside a rectangle. Pygame.draw.line – This function is used for drawing a straight line. Pygame.draw.arc – This function draws a partial section of an ellipse. Pygame.draw.lines – This function draws the multiple contiguous line segments. Sprites in pygame. A sprite is a two dimensional figure that forms part of your game. Most of the visible elements in your game will be sprites. For example, in a game of breakout, you might find the following sprite objects: The ball is a sprite that moves around the the screen, bouncing off things and destroying bricks.

Note that pygame does not automatically import pygame.gfxdraw, so you need to import pygame.gfxdraw before using it.

Threading note: each of the functions releases the GIL during the C part of the call.

The pygame.gfxdraw module differs from the draw module in the API it uses, and also the different functions available to draw. It also wraps the primitives from the library called SDL_gfx, rather than using modified versions.

Images

Note

See the module for alternative draw methods.

pygame.gfxdraw.pixel(surface, x, y, color) -> None

place a pixel

Draws a single pixel onto a surface.

pygame.gfxdraw.hline(surface, x1, x2, y, color) -> None

Draws a straight horizontal line on a Surface from x1 to x2 for the given y coordinate.

pygame.gfxdraw.vline(surface, x, y1, y2, color) -> None

draw a vertical line

Draws a straight vertical line on a Surface from y1 to y2 on the given x coordinate.

pygame.gfxdraw.rectangle(surface, rect, color) -> None

Draws the rectangle edges onto the surface. The given Rect is the area of the rectangle.

Keep in mind the Surface.fill() method works just as well for drawing filled rectangles. In fact the Surface.fill() can be hardware accelerated on some platforms with both software and hardware display modes.

pygame.gfxdraw.box(surface, rect, color) -> None

draw a box

Draws a box (a rect) onto a surface.

pygame.gfxdraw.line(surface, x1, y1, x2, y2, color) -> None

Draws a straight line on a Surface. There are no endcaps.

pygame.gfxdraw.circle(surface, x, y, r, color) -> None

draw a circle

Draws the edges of a circular shape on the Surface. The pos argument is the center of the circle, and radius is the size. The circle is not filled with color.

Java Draw Triangle

pygame.gfxdraw.arc(surface, x, y, r, start, end, color) -> None

Draws an arc onto a surface.

pygame.gfxdraw.aacircle(surface, x, y, r, color) -> None

draw an anti-aliased circle

Draws the edges of an anti aliased circle onto a surface.

pygame.gfxdraw.filled_circle(surface, x, y, r, color) -> None

Draws a filled circle onto a surface. So the inside of the circle will be filled with the given color.

pygame.gfxdraw.ellipse(surface, x, y, rx, ry, color) -> None

draw an ellipse

Draws the edges of an ellipse onto a surface.

Pygame Draw Triangle

pygame.gfxdraw.aaellipse(surface, x, y, rx, ry, color) -> None

Draws anti aliased edges of an ellipse onto a surface.

pygame.gfxdraw.filled_ellipse(surface, x, y, rx, ry, color) -> None

draw a filled ellipse
Pygame Draw Triangle

Draws a filled ellipse onto a surface. So the inside of the ellipse will be filled with the given color.

pygame.gfxdraw.pie(surface, x, y, r, start, end, color) -> None

Draws a pie onto the surface.

pygame.gfxdraw.trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None

draw a triangle

Draws the edges of a trigon onto a surface. A trigon is a triangle.

Pygame draw triangle code

pygame.gfxdraw.aatrigon(surface, x1, y1, x2, y2, x3, y3, color) -> None

Draws the anti aliased edges of a trigon onto a surface. A trigon is a triangle.

pygame.gfxdraw.filled_trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None

draw a filled trigon

Draws a filled trigon onto a surface. So the inside of the trigon will be filled with the given color.

pygame.gfxdraw.polygon(surface, points, color) -> None

Draws the edges of a polygon onto a surface.

pygame.gfxdraw.aapolygon(surface, points, color) -> None

draw an anti-aliased polygon

Draws the anti aliased edges of a polygon onto a surface.

pygame.gfxdraw.filled_polygon(surface, points, color) -> None

Draws a filled polygon onto a surface. So the inside of the polygon will be filled with the given color.

pygame.gfxdraw.textured_polygon(surface, points, texture, tx, ty) -> None

draw a textured polygon

Draws a textured polygon onto a surface.

A per-pixel alpha texture blit to a per-pixel alpha surface will differ from a Surface.blit() blit. Also, a per-pixel alpha texture cannot be used with an 8-bit per pixel destination.

pygame.gfxdraw.bezier(surface, points, steps, color) -> None

Draws a Bézier curve onto a surface.

Pygame Draw Triangle Map


Pygame Draw Triangle Map

Edit on GitHub

© Pygame Developers.
Licensed under the GNU LGPL License version 2.1.
https://www.pygame.org/docs/ref/gfxdraw.html