hp
jblog
toc

Flare

2015-10-17, post № 73

programming, Pygame, Python, #black, #glow, #mouse, #mouse controlled, #pixels, #red, #specs, #spread, #vector, #vector maths

Tinkering around with vectors, I created this fancy program. By left-clicking you spawn a white circle at your current mouse position. This circle then will emit a specific quantity of red pixels (which is 𝑐 = 𝟤 𝜋 𝑟 with 𝑟 = 𝟧𝟢). Those red pixels then get pushed across the screen until they eventually die out.

Controls

  • Left click spawns in a circle,
  • ‘Space’ saves a screenshot.
flare-15.png
flare-20.png
flare-19.png
Source code: flare.py

Gradient Triangles

2015-10-11, post № 72

programming, Pygame, Python, #3-gon, #background, #gradient, #triangles, #vector, #vector mathematics, #vectors, #wallpaper

This program uses vector mathematics and colors to create triangular gradient. By simply left-clicking you create three points which then will be filled in with color.

Controls

  • Left click adds a new position,
  • ‘Space’ saves a screenshot.
gradient-triangles-1.png
gradient-triangles-2.png
gradient-triangles-4.png
Source code: gradient-triangles.py

JDrawer

2015-10-10, post № 71

programming, Pygame, Python, #alternative, #art, #color, #colors, #draw, #drawing program

In an attempt to make drawing using a computer mouse easier, I created JDrawer. By pressing the left mouse button, you start or stop drawing. By simply moving your cursor the program then draws accordingly. The line’s colors are picked at random.

Controls

  • Left click starts and stops drawing,
  • Right click erases bits of the image,
  • ‘c’ clears the whole image,
  • ‘Space’ saves the image.
jdrawer-2.png
jdrawer-4.png
jdrawer-7.png
Source code: jdrawer.py

Sand

2015-10-04, post № 70

programming, Pygame, Python, #art, #background, #bridges, #falling, #grain, #grains, #sand, #shades

This program lets you watch grains of sand fall. The grains shift in color, according to the color algorithm assigned. You also can build bridges to change the sand’s falling behavior.

Controls

  • Left clicking spawns in new grains of sand,
  • Right clicking draws a bridge,
  • ‘Space’ saves a screenshot.
sand-7.png
sand-4.png
sand-10.png
Source code: sand.py

J-Filters III

2015-10-03, post № 69

programming, Pygame, Python, #filter, #image, #image manipulation, #img, #soft

This filter swaps the red and blue color values. It results in a rather soft image.

The original image (can also be found on my Stacking Stones post).

j-filters-iii_original.jpg

RGB Swap (just swaps the red and blue color value, that is why the lake appears red).

j-filters-iii_rgb-swap.png
Source code: j-filters-iii_rgb-swap.py

Pygame Bug

2015-09-27, post № 68

programming, Pygame, Python, #aa, #aacirlce, #anti-aliased, #antialiased, #approach, #buf, #circle, #color, #colors, #draw, #gfx, #gfxdraw, #n-gon, #pattern, #Pygame bug

Tinkering around with circles and colors, I created a program which creates interesting images, both with pygame.draw.circle() (left) and pygame.gfxdraw.circle() (right). (Both images at 𝟦𝟢𝟢 ⨉ 𝟦𝟢𝟢 pixels.)

pygame-bug_img-3_400x400-draw.png
pygame-bug_img-2_400x400-gfx.png

To get a smoother and nicer result, I tried using the pygame.gfxdraw.aacircle() function, which draws antialiased circles.

pygame-bug_img-1_400x400-aagfx.png

As expected, the antialiased function gets rid of the black spots between the colored circles.

Wanting a higher resolution, I used the same code on a 𝟣𝟢𝟢𝟢 ⨉ 𝟣𝟢𝟢𝟢 pixel wide surface.

pygame-bug_img-4_1000x1000-aagfx.png

Again, it is a smooth and neat result. But as I got higher and higher resolutions, I got this interesting result. (At 𝟥𝟢𝟢𝟢 ⨉ 𝟥𝟢𝟢𝟢 pixels)

pygame-bug_img-7_3000x3000-aagfx.png

To make sure, the problem is on pygame.gfxdraw.aacircle()’s side, I created images of equal size with both pygame.draw.circle() (left) and pygame.gfxdraw.circle() (right). (Both images again at 𝟥𝟢𝟢𝟢 ⨉ 𝟥𝟢𝟢𝟢 pixels.)
To ensure, the problem is not on my operating system’s side, I used the exact same code on Mac OSX, Debian Linux and Windows 7 and 8.1 and got the same result each time.

pygame-bug_img-9_3000x3000-draw.png
pygame-bug_img-8_3000x3000-gfx.png

At last, I used all three functions at 𝟦𝟢𝟢𝟢 ⨉ 𝟦𝟢𝟢𝟢 pixels. (pygame.draw.circle() on the left, pygame.gfxdraw.cirlce() on the right and pygame.gfxdraw.aacircle() on the bottom.)

pygame-bug_img-12_4000x4000-draw.png
pygame-bug_img-11_4000x4000-gfx.png
pygame-bug_img-10_4000x4000-aagfx.png
Source code: pygame-bug.py

Pastel

2015-09-26, post № 67

programming, Pygame, Python, #background, #beautiful, #color, #colors, #lines, #pseudo random, #random, #wallpaper

This program uses two positions and a color to create beautiful images.

Usage

  • ‘q’ saves the current image,
  • ‘Space’ pauses and resumes the image’s creation.
pastel-2.png
pastel-18.png
pastel-23.png
Source code: pastel.py

JClock V

2015-09-20, post № 66

programming, Pygame, Python, #alternative, #bar, #bar clock, #bars, #clock, #clockface, #time

This alternative clock design may not be particularly readable, but it is nice to look at.

jclock-v-1.png
Source code: jclock-v.py
Jonathan Frech's blog; built 2021/10/02 17:36:09 CEST