Mark's Coding Creations

Gouraud_Circles

Home
Kaleidascope
Gouraud Ellipses
Gouraud Quads
Gouraud Triangles
Draw And Fill
Gouraud_Circles
Rotate Image

gouraud_circles1.jpg

REM Project: Gouraud_Circles_1
REM Created: 10.1.2007 17:08:58
REM Created by  Mark Garrett  e-mail  is bubbb@verizon.net
REM ***** Main Source File *****
REM
global n

dim culur(6)
culur(1) = rgb(255,0,0):culur(2) = rgb(0,255,0):culur(3) = rgb(0,0,255)
culur(4) = rgb(255,255,0):culur(5) = rgb(0,255,255):culur(6) = rgb(255,0,255)


 set display mode 1024,768,16


sync on:sync rate 0

 for w = 1 to 30
 n = 0  `RESET 'N'
cc = rnd(5)+1 :color1 = culur(cc)
cc1: cc = rnd(5)+1 :color2 = culur(cc)
if color2 = color1 then goto cc1

lock pixels

 

radius = rnd(200) :x_center = rnd(850)+100:y_center = rnd(580)+100

Cir(x_center,y_center,radius,color1,color2)
unlock pixels :sync
next w

 text 10,10,"to exit press left mouse-button"
 text 10,25,"to save and exit press right mouse-button"
 sync
 wait mouse
 if mouseclick() = 2
  get image 1,0,0,1023,767,1: save image "Gouraud_Circles.jpg",1 : wait 5000
  endif
 end
`---------------------------------------------------------------------------
`-----------------------Radius converted to 8 X 360 or 2880-----------------------------------------------
`-----------------------in steps of 0/720/1440/2160/2880-----------------------------------------------------
function Cir(x_center,y_center,radius,color1,color2)

 

dim x(4000)
dim y(4000)

dim r(4000)
dim g(4000)
dim b(4000)

 

 

 

v as float:ox as float:oy as float:color as dword

x_add as float: y_add as float

r1 as float:g1 as float:b1 as float:r2 as float:g2 as float:b2 as float
r_add as float:g_add as float:b_add as float


`-----------------------------circle_color_setup------------------------------------

 circle_color_setup:
 r1 = rgbr(color1):g1 = rgbg(color1):b1 = rgbb(color1)
 r2 = rgbr(color2):g2 = rgbg(color2):b2 = rgbb(color2)
r_add=(r2-r1)/1440 : g_add=(g2-g1)/1440 : b_add=(b2-b1)/1440

 

 

 


 `-------------determine next x,y point,---------

  Border_Loop:
 ox = cos(v)  * radius
 oy = sin(v)  * radius

  v = v + .125
  if v = 270.125 then top_n = n
  if v = 90.125 then bot_n = n


  `-------- if exit to do inner lines:
       if v = 360.125
      ` sync


        goto do_hor_lines `- -
       endif

 `----------get_next_circle_dot_color  --------------------------------------------------------

 

if v <180.25
r1 = r1 + r_add:g1 = g1 + g_add:b1 = b1+b_add
ink rgb(r1,g1,b1),0
goto NN
endif


r1 = r1 - r_add:g1 = g1 - g_add:b1 = b1-b_add
ink rgb(r1,g1,b1),0


NN:
 n = n + 1
 x_border = x_center + ox:y_border = y_center + oy
 dot x_border,y_border

`---------------store  X Y AND COLOR AT EACH POINT

x(n) =   x_border
y(n) =   y_border

r(n) = r1
g(n) = g1
b(n) = b1


 goto Border_Loop

`- - - - - - - - - - - - - - - get circle dot color -- - - - - - - - - - - - - - - - -

 

 

 

 `---------------------------------------------------------------------------------------
`---------------------------------------------------------------------------------------
 `---------------draw-horizontal-lines-----then exit function---------------------


 do_hor_lines:    `(1,440 of them)

 x1 as float:x2 as float:y1 as float:y2 as float

n1 = top_n: n2 = top_n


beggin_LOOP:   `====================================
n1 = I(n1,1)
n2 = D(n2,1)

n1y = y(n1)
n2y = y(n2)


if n2y > n1y then n2 = I(n2,1): goto beggin_LOOP
if n1y > n2y then n1 = D(n1,1): goto beggin_LOOP

if n1 = bot_n then exitfunction

gosub Poke_a_line
goto beggin_LOOP


`++++++++++++++++++++++++++++ POKE A LINE ++++++++++++++++++++++++++++++++++++
`++++++++++++++++++++++++++++ POKE A LINE ++++++++++++++++++++++++++++++++++++
`++++++++++++++++++++++++++++ POKE A LINE ++++++++++++++++++++++++++++++++++++

Poke_a_line:

`-----------------get add----xy's -and largest-span

`- - - - - - - - - -
 spanx = abs(x(n1)-x(n2))
 spany = abs(y(n1)-y(n2))

if spany>=spanx then long_span = spany
if spanx>=spany then long_span = spanx

y1 = y(n1) :y2 = y(n2)
y_add = (y1-y2)/long_span
    ` for poking the dots
x1 = x(n1) : x2 = x(n2)
x_add = (x1 - x2)/long_span

 


r1 = r(n1):g1 = g(n1):b1 = b(n1)
r2 = r(n2):g2 = g(n2):b2 = b(n2)


r_add  = (r1-r2)/long_span
g_add  = (g1-g2)/long_span
b_add  = (b1-b2)/long_span

`----------------prepare-storage-space


`---------------
for tu = 1 to long_span


x2 = x2 + x_add
y2 = y2 + y_add


r2 = r2 + r_add
g2 = g2 + g_add
b2 = b2 + b_add


ink rgb(r2,g2,b2),0
dot x2,y2
`dot x2,y2-1
`dot x2+1,y2 `:dot x2-1,y2
`line x(n2),y(n2),x(n1),y(n1)
next tu

RETURN

 

 

exitfunction_:


UNdim x(0)
UNdim y(0)

UNdim r(0)
UNdim g(0)
UNdim b(0)

 

 

 

 


  endfunction

  `                              SUPPORTING  FUNCTIONS
 `&&&&&&&&&&&&&&&&&&&&&&&&&&&&    FUNCTIONS  &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 `&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 `&&&&&&&&&&&&&&&&&&&&&&&& INC &&&&&&&&&&&&&&&&&&&&&&&&&&&

function I(value as integer,times)

for t = 1 to times
if value+1 > n then value = 0
inc value
next t

endfunction value
`&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

 `&&&&&&&&&&&&&&&&&&&&&&&&&& DEC  &&&&&&&&&&&&&&&&&&&&&&&&&


 function D(value,times)

for t = 1 to times
if value - 1 < 1 then value = n
dec value
next t

endfunction value
`&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
`&&&&&&&&&&&&&&&&&&&&&&&&&&&  INT_ &&&&&&&&&&&&&&&&&&&&&
function int_(value as float)
a# = int(value+1): a# = a# - value
b# = int(value)  : b# = value - b#

if a# > b# then true_intuger_value = int(value)
if b# > a# then true_intuger_value = int(value+1)
if b# = a# then true_intuger_value = int(value+1)

endfunction true_intuger_value
`&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
`&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&