Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,30 +0,0 @@
|
|||
with Glib; use Glib;
|
||||
with Cairo; use Cairo;
|
||||
with Cairo.Png; use Cairo.Png;
|
||||
with Cairo.Pattern; use Cairo.Pattern;
|
||||
with Cairo.Image_Surface; use Cairo.Image_Surface;
|
||||
with Ada.Numerics;
|
||||
|
||||
procedure Sphere is
|
||||
subtype Dub is Glib.Gdouble;
|
||||
|
||||
Surface : Cairo_Surface;
|
||||
Cr : Cairo_Context;
|
||||
Pat : Cairo_Pattern;
|
||||
Status_Out : Cairo_Status;
|
||||
M_Pi : constant Dub := Dub (Ada.Numerics.Pi);
|
||||
|
||||
begin
|
||||
Surface := Create (Cairo_Format_ARGB32, 512, 512);
|
||||
Cr := Create (Surface);
|
||||
Pat :=
|
||||
Cairo.Pattern.Create_Radial (230.4, 204.8, 51.1, 204.8, 204.8, 256.0);
|
||||
Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 0.0, 1.0, 1.0, 1.0, 1.0);
|
||||
Cairo.Pattern.Add_Color_Stop_Rgba (Pat, 1.0, 0.0, 0.0, 0.0, 1.0);
|
||||
Cairo.Set_Source (Cr, Pat);
|
||||
Cairo.Arc (Cr, 256.0, 256.0, 153.6, 0.0, 2.0 * M_Pi);
|
||||
Cairo.Fill (Cr);
|
||||
Cairo.Pattern.Destroy (Pat);
|
||||
Status_Out := Write_To_Png (Surface, "SphereAda.png");
|
||||
pragma Assert (Status_Out = Cairo_Status_Success);
|
||||
end Sphere;
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
with Display; use Display;
|
||||
with Display.Basic; use Display.Basic;
|
||||
|
||||
procedure Main is
|
||||
Ball : Shape_Id := New_Circle
|
||||
(X => 0.0,
|
||||
Y => 0.0,
|
||||
Radius => 20.0,
|
||||
Color => Blue);
|
||||
begin
|
||||
null;
|
||||
end Main;
|
||||
|
|
@ -14,7 +14,7 @@ proc sphere r k amb dir[] .
|
|||
if z >= 0
|
||||
s = vdot dir[] norm [ x y sqrt z ]
|
||||
if s < 0 : s = 0
|
||||
lum = 100 * (pow s k + amb) / (1 + amb)
|
||||
lum = (pow s k + amb) / (1 + amb)
|
||||
gcolor3 lum lum lum
|
||||
grect 50 + x / 5, 50 + y / 5, 0.3 0.3
|
||||
.
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
; Draw a sphere
|
||||
|
||||
(defun normalize (v)
|
||||
"Normalize a vector."
|
||||
(setq invlen (/ 1.0 (sqrt (dot v v))))
|
||||
(mapcar (lambda (x) (* invlen x)) v))
|
||||
|
||||
(defun dot (v1 v2)
|
||||
"Dot product of two vectors."
|
||||
(+ (* (car v1) (car v2))
|
||||
(* (cadr v1) (cadr v2))
|
||||
(* (caddr v1) (caddr v2))))
|
||||
|
||||
(defun make-array (size)
|
||||
"Create an empty array with size*size elements."
|
||||
(setq m-array (make-vector size nil))
|
||||
(dotimes (i size)
|
||||
(setf (aref m-array i) (make-vector size 0)))
|
||||
m-array)
|
||||
|
||||
(defun pic-lines (arr size)
|
||||
"Turn array into a string."
|
||||
(setq all "")
|
||||
(dotimes (y size)
|
||||
(setq line "")
|
||||
(dotimes (x size)
|
||||
(setq line (concat line (format "%i \n" (elt (elt arr y) x)))))
|
||||
(setq all (concat all line "\n")))
|
||||
all)
|
||||
|
||||
(defun pic-show (arr size)
|
||||
"Convert size*size array to grayscale PBM image and show it."
|
||||
(insert-image (create-image (concat (format "P2
|
||||
%i %i 255\n" size size) (pic-lines arr size)) 'pbm t)))
|
||||
|
||||
(defun sphere (size k amb dir)
|
||||
"Draw a sphere."
|
||||
(let ((arr (make-array size))
|
||||
(ndir (normalize dir))
|
||||
(r (/ size 2)))
|
||||
(dotimes (yp size)
|
||||
(dotimes (xp size)
|
||||
(setq x (- xp r))
|
||||
(setq y (- yp r))
|
||||
(setq z (- (* r r) (* x x) (* y y)))
|
||||
(if (>= z 0)
|
||||
(let* ((vec (normalize (list x y (sqrt z))))
|
||||
(s (max 0 (dot vec ndir)))
|
||||
(lum (max 0 (min 255 (* 255 (+ amb (expt s k))
|
||||
(/ (1+ amb)))))))
|
||||
(setf (elt (elt arr yp) xp) lum)))))
|
||||
(pic-show arr size)))
|
||||
|
||||
(sphere 200 1.5 0.2 '(-30 -30 50))
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
shades = Array(".", ":", "!", "*", "o", "e", "&", "#", "%", "@")
|
||||
light = Array(30, 30, -50)
|
||||
|
||||
Sub Normalize(v)
|
||||
length = Sqr(v(0)*v(0) + v(1)*v(1) + v(2)*v(2))
|
||||
v(0) = v(0)/length : v(1) = v(1)/length : v(2) = v(2)/length
|
||||
End Sub
|
||||
|
||||
Function Dot(x, y)
|
||||
d = x(0)*y(0) + x(1)*y(1) + x(2)*y(2)
|
||||
If d < 0 Then Dot = -d Else Dot = 0 End If
|
||||
End Function
|
||||
|
||||
'floor function is the Int function
|
||||
'ceil function implementation
|
||||
Function Ceil(x)
|
||||
Ceil = Int(x)
|
||||
If Ceil <> x Then Ceil = Ceil + 1 End if
|
||||
End Function
|
||||
|
||||
Sub DrawSphere(R, k, ambient)
|
||||
Dim i, j, intensity, inten, b, x, y
|
||||
Dim vec(3)
|
||||
For i = Int(-R) to Ceil(R)
|
||||
x = i + 0.5
|
||||
line = ""
|
||||
For j = Int(-2*R) to Ceil(2*R)
|
||||
y = j / 2 + 0.5
|
||||
If x * x + y * y <= R*R Then
|
||||
vec(0) = x
|
||||
vec(1) = y
|
||||
vec(2) = Sqr(R * R - x * x - y * y)
|
||||
Normalize vec
|
||||
b = dot(light, vec)^k + ambient
|
||||
intensity = Int((1 - b) * UBound(shades))
|
||||
If intensity < 0 Then intensity = 0 End If
|
||||
If intensity >= UBound(shades) Then
|
||||
intensity = UBound(shades)
|
||||
End If
|
||||
line = line & shades(intensity)
|
||||
Else
|
||||
line = line & " "
|
||||
End If
|
||||
Next
|
||||
WScript.StdOut.WriteLine line
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Normalize light
|
||||
DrawSphere 20, 4, 0.1
|
||||
DrawSphere 10,2,0.4
|
||||
Loading…
Add table
Add a link
Reference in a new issue