Spirograph Art + Alpha Blending: Art Gallery!! :-)

Post your FreeBASIC tips and tricks here. Please don’t post your code without including an explanation.
KristopherWindsor
Posts: 2428
Joined: Jul 19, 2006 19:17
Location: Sunnyvale, CA
Contact:

Spirograph Art + Alpha Blending: Art Gallery!! :-)

Postby KristopherWindsor » Feb 05, 2008 3:58

Here are some new FBGFX effects, possibly inspired by this program!! :-)

Here are some sketches without alpha:
Image
Image

And with alpha:
Image

Alpha blending creates lighting effects:
Image
Image

Some more:
Image
Image
Image
Image

Enter the vortex:
Image

Paint or furniture?
Image
Image

Using lines instead of pixels:
Image
Image

And the winner is:
Image

These screen shots were all produced by these two programs, and slight modifications of them:

Code: Select all

' Spirograph Alpha! v1.0
' (C) 2008 Innova and Kristopher Windsor

#include "fbgfx.bi"

Const screenx = 800, screeny = 600
Const spin_max = 3, pi = Atn(1) * 4

Type spin_type
  As Double angle, size, velocity
End Type

Dim As Double x, y, x2, y2
Dim As spin_type spin(1 To spin_max)

Screenres screenx, screeny, 32,, fb.GFX_ALPHA_PRIMITIVES
Randomize Timer

For a As Integer = 1 To spin_max
  With spin(a)
    .angle = Rnd * pi * 2
    .size = rnd * 500 / a '(spin_max - a + 1) 'rnd * 500 / a
    .velocity = Rnd / 400
  End With
Next a

Do
  x = screenx / 2
  y = screeny / 2
  x2 = x: y2 = y
 
  For a As Integer = 1 To spin_max
    With spin(a)
      .angle += .velocity
      x += Cos(.angle) * .size
      y += Sin(.angle) * .size
      x2 -= Cos(.angle) * .size
      y2 -= Sin(.angle) * .size
    End With
  Next a
 
  Pset (x, y), &H0F88FF88
  Pset (x2, y2), &H0F8888FF
Loop Until Inkey = Chr(27)
Bsave "art-" & Rnd & ".bmp", 0


Note that this version draws to a buffer, which is larger than the screen:

Code: Select all

' Spirograph Alpha! v1.0b
' (C) 2008 Innova and Kristopher Windsor

#include "fbgfx.bi"

Const screenx = 800, screeny = 600
Const canvasx = 1200, canvasy = 900

Const spin_max = 3, pi = Atn(1) * 4

Type spin_type
  As Double angle, size, velocity
End Type

Dim As Integer fc
Dim As Double x, y
Dim As spin_type spin(1 To spin_max)
Dim As fb.image Ptr canvas

Screenres screenx, screeny, 32,, fb.GFX_ALPHA_PRIMITIVES
canvas = imagecreate(canvasx, canvasy, &HFF000000)
Randomize Timer

For a As Integer = 1 To spin_max
  With spin(a)
    .angle = Rnd * pi * 2
    .size = canvasy / (a * 5) '(spin_max - a + 1) 'rnd * 500 / a
    .velocity = Rnd / 400
  End With
Next a

Do
  fc += 1
 
  x = canvasx / 2
  y = canvasy / 2
 
  For a As Integer = 1 To spin_max - 1
    With spin(a)
      .angle += .velocity
      x += Cos(.angle) * .size
      y += Sin(.angle) * .size
    End With
  Next a
 
  With spin(spin_max)
    Line canvas, (x, y) - Step(Cos(.angle) * .size * 2, Sin(.angle) * .size * 2), &H0F8888FF
    Line canvas, (x, y) - Step(-Cos(.angle) * .size * 2, -Sin(.angle) * .size * 2), &H0FFF8888
  End With
 
  If (fc Mod 10000) = 0 Then Put (0, 0), canvas, Pset
Loop Until Inkey = Chr(27)
Bsave "art-" & Rnd & ".bmp", canvas
imagedestroy(canvas)


I'm sure someone can produce some new effects if they play with the programs. xD

Tags: kristopherwindsor_program_graphics kristopherwindsor_feature_program
Last edited by KristopherWindsor on Mar 22, 2008 6:43, edited 1 time in total.
Pritchard
Posts: 5492
Joined: Sep 12, 2005 20:06
Location: Ohio, USA

Postby Pritchard » Feb 05, 2008 4:06

I love you.
JohnB
Posts: 236
Joined: Jul 22, 2005 3:53
Location: Minnesota Arizona

Postby JohnB » Feb 05, 2008 4:20

GREAT eye candy !!!

JohnB
D.J.Peters
Posts: 7852
Joined: May 28, 2005 3:28

Postby D.J.Peters » Feb 05, 2008 7:23

looks realy nice

Joshy
tinram
Posts: 88
Joined: Nov 30, 2006 13:35
Location: UK

Postby tinram » Feb 05, 2008 12:29

Excellent. The first program generates some really sublime patterns at times.
notthecheatr
Posts: 1759
Joined: May 23, 2007 21:52
Location: Cut Bank, MT
Contact:

Postby notthecheatr » Feb 05, 2008 17:01

Beautiful! I'll look at these programs themselves later.

Return to “Tips and Tricks”

Who is online

Users browsing this forum: No registered users and 1 guest