La sfera dei colori non comprende solo la buccia con primari e secondari, ma anche i colori terziari che andando verso il centro perdono la saturazione formando il grigio medio.
Un colore che sulla buccia vale r,g,b, passando lungo il diametro,
si trasforma dalla parte opposta in 100-r,100-g,100-b.
Pertanto se il raggio della sfera è 1, alla distanza x dal centro sfera il colore sarà:
(r-50)*x+50,(g-50)*x+50,(b-50)*x+50
che per x=1 dà r,g,b e per x=-1 dà 100-r,100-g,100-b
Nell'esempio, per mostrare le sfere interne, sono state disposte in sequenza.
In teoria le sfere più piccole si ingrigiscono, pur essendo
l'effetto poco evidente in 3D.
Le sfere andrebbero immaginate una dentro all'altra con unico centro.
!!!Istruzioni per ottenere l'oggetto GDL in figura
!Elenco parametri -------------------------------------------:
n=10 !divisoni semimeridiano
m=10 !divisoni lungo equatore
t=0 !bit: =1 RGB, =0 CMYK
p=1 !pen
s="linee in vista" !abc
l="opaco" !abc
g="Top view" !abc
o=1 !mostra facce in 2D
!Script parametri -------------------------------------------:
VALUES "s" "linee in vista","colori"
VALUES "l" "opaco","metallo","plastica","vetro","brillante"
VALUES "g" "Top view","Side view","Frontal axonometry",
"Isometric axonometry","Monometric axonometry","Dimetric axonometry"
! TESTO 2D --------------------------------------------------:
if g="Top view" then pr=3
if g="Side view" then pr=4
if g="Frontal axonometry" then pr=6
if g="Isometric axonometry" then pr=7
if g="Monometric axonometry" then pr=8
if g="Dimetric axonometry" then pr=9
if s="linee in vista" then w=2
if s="colori" then w=3
project2 pr,270,w
!TESTO 3D----------------------------------------------------:
pen p
x=100
gosub 1
n=8
m=8
addx 1.8
x=80
gosub 1
n=6
m=6
addx 1.4
x=60
gosub 1
n=4
m=4
addx 1
x=40
gosub 1
n=2
m=2
addx 0.6
x=20
gosub 1
del top
end
1: if l="opaco" then w=2
if l="metallo" then w=3
if l="plastica" then w=4
if l="vetro" then w=5
if l="brillante" then w=6
!parte superiore lomgitudine 0-120 da green a blue, polo white
r1=not(t)*100
g1=t*100
b1=not(t)*100
r2=not(t)*100
g2=not(t)*100
b2=t*100
r3=100
g3=100
b3=100
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "aij" w,
Re/100,Gr/100,Bu/100
MATERIAL "aij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
rotz 120
!parte superiore lomgitudine 120-240 da blue a red, polo white
r1=not(t)*100
g1=not(t)*100
b1=t*100
r2=t*100
g2=not(t)*100
b2=not(t)*100
r3=100
g3=100
b3=100
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "bij" w,
Re/100,Gr/100,Bu/100
MATERIAL "bij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
rotz 120
!parte superiore lomgitudine 240-360 da red a green, polo white
r1=t*100
g1=not(t)*100
b1=not(t)*100
r2=not(t)*100
g2=t*100
b2=not(t)*100
r3=100
g3=100
b3=100
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "cij" w,
Re/100,Gr/100,Bu/100
MATERIAL "cij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
rotz 120
mulz -1
!calotta inferiore lomgitudine 0-120 da green a blue, polo black
r1=not(t)*100
g1=t*100
b1=not(t)*100
r2=not(t)*100
g2=not(t)*100
b2=t*100
r3=0
g3=0
b3=0
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "dij" w,
Re/100,Gr/100,Bu/100
MATERIAL "dij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
rotz 120
!calotta inferiore lomgitudine 120-240 da blue a red, polo black
r1=not(t)*100
g1=not(t)*100
b1=t*100
r2=t*100
g2=not(t)*100
b2=not(t)*100
r3=0
b3=0
g3=0
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "eij" w,
Re/100,Gr/100,Bu/100
MATERIAL "eij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
rotz 120
!calotta inferiore lomgitudine 240-360 da red a green, polo black
r1=t*100
g1=not(t)*100
b1=not(t)*100
r2=not(t)*100
g2=t*100
b2=not(t)*100
r3=0
b3=0
g3=0
for j=0 to m-1
for i=0 to n-1 ! da ((r1-50)*x/100+50),((g1-50)*x/100+50),((b1-50)*x/100+50) a ((r2-50)*x/100+50),((g2-50)*x/100+50),((b2-50)*x/100+50) (riga in basso) e da ((r3-50)*x/100+50),((g3-50)*x/100+50),((b3-50)*x/100+50) a a r4,g4,b4 (riga in alto)
Re=((r1-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1)+(((r2-50)*x/100+50)+j*(((r3-50)*x/100+50)-((r2-50)*x/100+50))/(n-1)-((r1-50)*x/100+50)-j*(((r3-50)*x/100+50)-((r1-50)*x/100+50))/(n-1))/(m-1)*i
Gr=((g1-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1)+(((g2-50)*x/100+50)+j*(((g3-50)*x/100+50)-((g2-50)*x/100+50))/(n-1)-((g1-50)*x/100+50)-j*(((g3-50)*x/100+50)-((g1-50)*x/100+50))/(n-1))/(m-1)*i
Bu=((b1-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1)+(((b2-50)*x/100+50)+j*(((b3-50)*x/100+50)-((b2-50)*x/100+50))/(n-1)-((b1-50)*x/100+50)-j*(((b3-50)*x/100+50)-((b1-50)*x/100+50))/(n-1))/(m-1)*i
DEFINE MATERIAL "fij" w,
Re/100,Gr/100,Bu/100
MATERIAL "fij"
base
vert x/100*cos(j*90/m)*cos(i*120/n),x/100*cos(j*90/m)*sin(i*120/n),x/100*sin(j*90/m)!1
vert x/100*cos(j*90/m)*cos((i+1)*120/n),x/100*cos(j*90/m)*sin((i+1)*120/n),x/100*sin(j*90/m)!2
vert x/100*cos((j+1)*90/m)*cos((i+1)*120/n),x/100*cos((j+1)*90/m)*sin((i+1)*120/n),x/100*sin((j+1)*90/m)!3
vert x/100*cos((j+1)*90/m)*cos(i*120/n),x/100*cos((j+1)*90/m)*sin(i*120/n),x/100*sin((j+1)*90/m)!4
edge 1,2,-1,-1,0
edge 2,3,-1,-1,0
edge 3,4,-1,-1,0
edge 4,1,-1,-1,0
pgon 4,0,-1,1,2,3,4
next i
next j
del 6, ntr()-5
return