Computer generated nice patterns

Post Reply
osscp
Posts: 2
Joined: Sun May 03, 2015 9:41 pm
My devices: ipad air

Computer generated nice patterns

Post by osscp »

' pattern arts by old school spagetti code programmer osscp
'
' version 0.9
' by Dirk 2015.05
' tested on ipad air
'
' always use your tablet in the wide orientation mode
'
' the program is inspired by computer arts literature
' it is completely useless, but shows continously changing nice graphic patterns
' feel free to modify it
'
' great thanks to the developer of the app

Code: Select all

' pattern arts by old school spagetti code programmer osscp
'
' version 0.9 
' by Dirk 2015.05
' tested on ipad air
' 
' always use your tablet in the wide orientation mode
' 
' the program is inspired by computer arts literature 
' it is completely useless, but shows continously changing nice graphic patterns
' feel free to modify it
'
' great thanks to the developer of the app

'b'
REM define funktion to draw a sqare on point x,y 
DEF SDraw (x,y,sqlenght,angle0)

x1=x ! y1=y

x2=x1 + sqlenght * SIN(angle0)  !  y2=y1 + sqlenght * COS(angle0) 
x3=x2 - sqlenght * COS(angle0)  !  y3=y2 + sqlenght * SIN(angle0)
x4=x3 - sqlenght * SIN(angle0)  !  y4=y3 - sqlenght * COS(angle0)

DRAW LINE x1,y1 TO x2,y2
DRAW LINE TO x3,y3
DRAW LINE TO x4,y4
DRAW LINE TO x1,y1

END DEF

'r'  rem figure1 is a square
DEF figure1draw(x,y,o,basis) REM o orientierung in grad b Basis
diagonale =basis * SQRT(2)
o=o+45
FOR j=1 TO 4
FILL COLOR r(j),g(j),b(j) ! FILL RECT x,y TO x+SIN(o)*diagonale, y+COS(o)*diagonale
o=o+90
NEXT j

FILL COLOR 0.1,0.1,0.1 ! FILL CIRCLE x,y SIZE kr REM this is the black circle
FILL COLOR 0.9,0.9,0.9 ! FILL CIRCLE x,y SIZE kr/5 REM this is the small white 

END DEF

DEF figure2draw(x,y,o,basis) REM little flower
diagonale =basis * SQRT(2)
o=o+45
FOR j=1 TO 4
FILL COLOR r(j),g(j),b(j) ! FILL CIRCLE x+SIN(o)*diagonale/2, y+COS(o)*diagonale/2 SIZE 25 ! o=o+90
NEXT j

FILL COLOR 0.1,0.1,0.1 ! FILL CIRCLE x,y SIZE kr REM this is the black circle
FILL COLOR 0.9,0.9,0.9 ! FILL CIRCLE x,y SIZE kr/5 REM this is the small white 
END DEF

DEF figure3draw(x,y,o,basis) REM 
diagonale =basis * SQRT(2)
o=o+45
FOR j=1 TO 4
FILL COLOR r(j),g(j),b(j) ! FILL RECT x+SIN(o)*diagonale/2, y+COS(o)*diagonale/2  SIZE 25
FILL COLOR 0.1,0.1,0.1 ! FILL CIRCLE x+SIN(o)*diagonale/2,  y+COS(o)*diagonale/2 SIZE kr 
o=o+90
NEXT j

END DEF

'c'
DEF turncolors  REM generate random colors for the 4 segments of the big square

FOR i=1 TO 4
figure1draw.r(i)=RND(1)
figure1draw.g(i)=RND(1)
figure1draw.b(i)=RND(1)
NEXT i

FOR i=1 TO 4
figure2draw.r(i)=RND(1)
figure2draw.g(i)=RND(1)
figure2draw.b(i)=RND(1)
NEXT i

FOR i=1 TO 4
figure3draw.r(i)=RND(1)
figure3draw.g(i)=RND(1)
figure3draw.b(i)=RND(1)
NEXT i

END DEF

''
REM main
REM do some initialization
SHADOW OFF
OPTION ANGLE DEGREES
sw=SCREEN_WIDTH() ! cx=sw/2 ! sh=SCREEN_HEIGHT() ! cy=sh/2
GRAPHICS ! GRAPHICS CLEAR 0.9,0.9,0.9
DRAW FONT SIZE sw/20 ! DRAW COLOR 0.5,0.5,0.5
DRAW TEXT "interactive arts !" AT cx-50,cy
DRAW TEXT "figuredraw!"        AT cx-50,cy+35
basis=50

REM init
RANDOMIZE 
figure1draw.kr=20
figure2draw.kr=20
figure3draw.kr=20
faktor=1

REM test figures and turn angle 

turncolors ! figure1draw(100,256,0,basis) 
turncolors ! figure1draw(200,256,90,basis)
turncolors ! figure1draw(300,256,180,basis) 
turncolors ! figure1draw(400,256,270,basis)

turncolors ! figure2draw(100,384,0,basis) 
turncolors ! figure2draw(200,384,90,basis)
turncolors ! figure2draw(300,384,180,basis) 
turncolors ! figure2draw(400,384,270,basis)

turncolors ! figure3draw(100,512,0,basis) 
turncolors ! figure3draw(200,512,90,basis)
turncolors ! figure3draw(300,512,180,basis) 
turncolors ! figure3draw(400,512,270,basis)

PAUSE 10

REM here the show begins

loop1:

GRAPHICS CLEAR 0,0.1,0

ang=0

FOR z=60 TO sh-50 STEP 100

FOR s=60 TO sw-50 STEP 100

figure1draw(s,z,ang,basis)

ang=ang+90*faktor

x=x+50

NEXT s

y=y+50

NEXT z


PAUSE 1 + RND(2)

turncolors

figure1draw.kr = RND(30)

faktor=RND(3)

basis=basis-1

IF basis<20 THEN GOTO exit1

GOTO loop1

exit1:



basis=50

loop2:

GRAPHICS CLEAR 0,0.1,0

ang=0

FOR z=60 TO sh-50 STEP 100

FOR s=60 TO sw-50 STEP 100

figure2draw(s,z,ang,basis)

ang=ang+90*faktor

x=x+50

NEXT s

y=y+50

NEXT z


PAUSE 1 + RND(2)

turncolors

figure1draw.kr = RND(30)

faktor=RND(3)

basis=basis-1

IF basis<20 THEN GOTO exit2

GOTO loop2

exit2:



basis=50

loop3:

GRAPHICS CLEAR 0,0.1,0

ang=0

FOR z=60 TO sh-50 STEP 100

FOR s=60 TO sw-50 STEP 100

figure3draw(s,z,ang,basis)

ang=ang+90*faktor

x=x+50

NEXT s

y=y+50

NEXT z


PAUSE 1 + RND(2)

turncolors

figure1draw.kr = RND(30)

faktor=RND(3)

basis=basis-1

IF basis<20 THEN GOTO exit3

GOTO loop3

exit3:


GRAPHICS CLEAR 0,0.1,0

DRAW TEXT " the end  !" AT cx-50,cy


END
Attachments
image.jpg
image.jpg (507.37 KiB) Viewed 1200 times
Last edited by osscp on Sat May 09, 2015 7:05 pm, edited 2 times in total.

User avatar
Mr. Kibernetik
Site Admin
Posts: 4786
Joined: Mon Nov 19, 2012 10:16 pm
My devices: iPhone, iPad, MacBook
Location: Russia
Flag: Russia

Re: Computer generated nice patterns

Post by Mr. Kibernetik »

Very nice show! :)
Thanks!

Post Reply