Page 1 of 1

Rotating Squares pattern

Posted: Wed Dec 24, 2014 9:11 am
by DrChip
REM rotating squares
REM iPhone 6 Plus Tested

init:
graphics
rem
graphics clear 0,0,0
s=160
x1=100
y1=100
x2=100
y2=-100
x3=-100
y3=-100
x4=-100
y4=100

loop:
sq=rnd(.10) 'sequence in pattern
graphics clear 0,0,0
for r=0 to 3000
rr=r*sq
cc=cos(rr)
ss=sin(rr)
x11=x1*cc-y1*ss
y11=x1*ss+y1*cc
x11=x11+s
y11=y11+s
x22=x2*cc-y2*ss
y22=x2*ss+y2*cc
x22=x22+s
y22=y22+s
x33=x3*cc-y3*ss
y33=x3*ss+y3*cc
x33=x33+s
y33=y33+s
x44=x4*cc-y4*ss
y44=x4*ss+y4*cc
x44=x44+s
y44=y44+s
c=rnd(.255)
draw size 3
draw color 1,c,c
draw line x11,y11 to x22,y22
draw size 2
draw color c,1,c
draw line to x33,y33
draw size 1
draw color c,c,1
draw line to x44,y44
draw line to x11,y11
NEXT r
goto loop

Re: Rotating Squares pattern

Posted: Wed Dec 24, 2014 9:30 am
by Mr. Kibernetik
Great!
I can suggest this modification:

Code: Select all

REM rotating squares
REM iPhone 6 Plus Tested

init:
graphics
rem
graphics clear 0,0,0
s=160
x1=100
y1=100
x2=100
y2=-100
x3=-100
y3=-100
x4=-100
y4=100

refresh off
shadow on
loop:
graphics clear 0,0,0
for r=0 to 3000
rr=r*.3 'sequence in pattern 
cc=cos(rr)
ss=sin(rr)
x11=x1*cc-y1*ss
y11=x1*ss+y1*cc
x11=x11+s
y11=y11+s
x22=x2*cc-y2*ss
y22=x2*ss+y2*cc
x22=x22+s
y22=y22+s
x33=x3*cc-y3*ss
y33=x3*ss+y3*cc
x33=x33+s
y33=y33+s
x44=x4*cc-y4*ss
y44=x4*ss+y4*cc
x44=x44+s
y44=y44+s
c=rnd(.255)
draw size 3
draw color 1,c,c
draw line x11,y11 to x22,y22
draw size 2
draw color c,1,c
draw line to x33,y33
draw size 1
draw color c,c,1
draw line to x44,y44
draw line to x11,y11
refresh
NEXT r
goto loop

Re: Rotating Squares pattern

Posted: Wed Dec 24, 2014 9:34 am
by DrChip
I forgot the random sequence for the patern. I updated the code, it looks a bit better. Thanks! :)

Re: Rotating Squares pattern

Posted: Thu Dec 25, 2014 8:18 am
by Henko
Nice! May i suggest the following init: part to make it hardware independent

Code: Select all

init:
graphics
rem
graphics clear 0,0,0
sw=screen_width() ! s=sw/2 ! d=sw/3
x1=d
y1=d
x2=d
y2=-d
x3=-d
y3=-d
x4=-d
y4=d

Re: Rotating Squares pattern

Posted: Thu Dec 25, 2014 10:13 am
by smbstarv
To make orientation independent..

init:
graphics
rem
graphics clear 0,0,0
get orientation p
if p=2 or p=3 then ! sw=screen_height() ! else ! sw=screen_width() ! end if
s=sw/2 ! d=sw/3

Etc.

Re: Rotating Squares pattern

Posted: Thu Dec 25, 2014 2:28 pm
by Henko
smbstarv wrote:To make orientation independent..

init:
graphics
rem
graphics clear 0,0,0
get orientation p
if p=2 or p=3 then ! sw=screen_height() ! else ! sw=screen_width() ! end if
s=sw/2 ! d=sw/3

Etc.
Just a tiny detail:

if p=2 or p=3 then sw=screen_height() else sw=screen_width()

is a valid statement, no need for the multi-statement exclamation marks

s

Re: Rotating Squares pattern

Posted: Fri Dec 26, 2014 1:21 am
by DrChip
REM rotating squares v2
REM iPhone 6 Plus Tested
REM v2 - tweaked colors

init:
graphics
rem
graphics clear 0,0,0
sw=screen_width()
sh=screen_height()
s1=sw/2
s2=sh/2
x1=200
y1=200
x2=200
y2=-100
x3=-200
y3=-100
x4=-100
y4=1
'refresh off
'shadow on
loop:
sq=rnd(.10) 'sequence in pattern
graphics clear 0,0,0
for r=0 to 3000
rr=r*sq
cc=cos(rr)
ss=sin(rr)
x11=x1*cc-y1*ss
y11=x1*ss+y1*cc
x11=x11+s1
y11=y11+s2
x22=x2*cc-y2*ss
y22=x2*ss+y2*cc
x22=x22+s1
y22=y22+s2
x33=x3*cc-y3*ss
y33=x3*ss+y3*cc
x33=x33+s1
y33=y33+s2
x44=x4*cc-y4*ss
y44=x4*ss+y4*cc
x44=x44+s1
y44=y44+s2
c=rnd(.255)
draw size 1
draw color 1,c,c
draw line x11,y11 to x22,y22
draw size 1
draw color c,1,c
draw line to x33,y33
draw size 1
draw color c,c,1
draw line to x44,y44
draw size 1
draw color c,c,c
draw line to x11,y11
'refresh
NEXT r
goto loop

Re: Rotating Squares pattern

Posted: Fri Dec 26, 2014 3:22 pm
by Mr. Kibernetik
Ok, my modification:

Code: Select all

REM rotating squares v2
REM iPhone 6 Plus Tested
REM v2 - tweaked colors

graphics
sw=screen_width()
sh=screen_height()
s1=sw/2
s2=sh/2
x1=200
y1=200
x2=200
y2=-100
x3=-200
y3=-100
x4=-100
y4=1
refresh off 
shadow on

sq=.5'rnd(1) 'sequence in pattern 
draw size 3
loop:
r+=1
rr=r*sq
cc=cos(rr)
ss=sin(rr)
x11=x1*cc-y1*ss
y11=x1*ss+y1*cc
x11+=s1
y11+=s2
x22=x2*cc-y2*ss
y22=x2*ss+y2*cc
x22+=s1
y22+=s2
x33=x3*cc-y3*ss
y33=x3*ss+y3*cc
x33+=s1
y33+=s2
x44=x4*cc-y4*ss
y44=x4*ss+y4*cc
x44+=s1
y44+=s2
c=rnd(.25)
draw alpha rnd(1)+.5
draw color 1,c,c
draw line x11,y11 to x22,y22
draw alpha rnd(1)+.5
draw color c,1,c
draw line to x33,y33
draw alpha rnd(1)+.5
draw color c,c,1
draw line to x44,y44
draw alpha rnd(1)+.5
draw color c,c,c
draw line to x11,y11
refresh
goto loop