Sphere ( animated )

Post Reply
Operator
Posts: 138
Joined: Mon May 06, 2013 5:52 am

Sphere ( animated )

Post by Operator »

Yuhuu,
this is my first snippet post on this forum,
took a bit for porting ( now learning smart basic )
enjoy...

REM Rotating Pseudo Sphere by Operator
REM inspired by DrChip, ported from Basic!
REM smart Basic 2.0.1 / iPhone 4 / iOS 6.1

option angle radians
PI = 3.14159265
graphics
draw color 1,1,1

scwh = Screen_Width()/2
schh = Screen_Height()/2

sizee = 120 ' radius of the sphere
segments = 11 ' segment of the sphere

loop:
graphics lock

' clear the background
fill color 0,0,1
fill circle scwh,schh SIZE sizee

' sphere segment rotation increment
a = a + PI/(2*segments)
draw color 1,1,1

' draw sphere
draw size 1
FOR i = 0 TO PI STEP PI/segments
draw circle scwh-sizee*SIN(i+a), schh-sizee TO scwh+sizee*SIN(i+a),schh+sizee
draw circle scwh-sizee,schh-sizee*SIN(i) TO scwh+sizee,schh+sizee*SIN(i)
NEXT i

' overlay fading circles over the sphere
draw size 5.1
FOR i = 1 TO sizee STEP 5
alf = 0.98-(i*0.9/sizee)
draw alpha alf
draw COLOR 0,0,0
draw CIRCLE scwh,schh SIZE sizee-(i)
NEXT i
draw alpha 1

' last circle overlay
draw size 5
draw COLOR 0,0,0
draw CIRCLE scwh,schh SIZE sizee

graphics unlock
pause 0.1

GOTO loop
Attachments
image.jpg
image.jpg (69.14 KiB) Viewed 2516 times

Henko
Posts: 816
Joined: Tue Apr 09, 2013 12:23 pm
My devices: iPhone,iPad
Windows
Location: Groningen, Netherlands
Flag: Netherlands

Re: Sphere ( animated )

Post by Henko »

Nice effect, the "glowing" globe.
Congrats with your first SB program. As you can see, I'm also porting some of my programs from the Basic! forum. Now busy to rewrite the "Automaton". The much higher execution speed of SB is an advantage here.

Post Reply