FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
RaytracerCollection/Python/surface.py at master · lpython/RaytracerCollection · GitHub
lpython
RaytracerCollection
Repository navigation
Code
Issues
Pull requests
1
(1)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
RaytracerCollection
/
Python
/
surface.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
67 lines (51 loc) · 1.39 KB
Breadcrumbs
RaytracerCollection
/
Python
/
surface.py
Copy path
File metadata and controls
67 lines (51 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import
math
from
collections
import
namedtuple
# from abc import ABCMeta, abstractmethod
import
color
from
vector
import
Vector
from
ray_types
import
Surface
shiny
=
Surface
(
diffuse
=
lambda
n
:
color
.
white
,
specular
=
lambda
n
:
color
.
grey
,
reflect
=
lambda
n
:
0.7
,
roughness
=
250
)
#inline module
class
Checker
():
@
staticmethod
def
diffuse
(
pos
:
Vector
):
if
((
math
.
floor
(
pos
.
z
)
+
math
.
floor
(
pos
.
x
))
%
2
!=
0
):
return
color
.
white
else
:
return
color
.
black
@
staticmethod
def
specular
(
pos
:
Vector
):
return
color
.
white
@
staticmethod
def
reflect
(
pos
:
Vector
):
if
((
math
.
floor
(
pos
.
z
)
+
math
.
floor
(
pos
.
x
))
%
2
!=
0
):
return
0.1
else
:
return
0.7
checkerboard
=
Surface
(
Checker
.
diffuse
,
Checker
.
specular
,
Checker
.
reflect
,
roughness
=
150
)
# class Surface(metaclass=ABCMeta):
# @property
# @abstractmethod
# def diffuse(self): pass
# @property
# @abstractmethod
# def specular(self): pass
# @property
# @abstractmethod
# def reflect(self): pass
# class Shiny(Surface):
# _diffuse = color.white
# @property
# @classmethod
# def diffuse(cls):
# return cls._diffuse
# _specular = color.grey
# @property
# def specular(self):
# return self._specular
# @property
# def reflect(self):
# return 0.7
Back
|
FazBrowse Home
|
New Git URL