Merge pull request #577 from HigherOrderCO/shader-guide-example

Change shader example in the guide
This commit is contained in:
Eduardo Sandalo Porto 2024-06-10 21:37:31 +00:00 committed by GitHub
commit 18b9f6654a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View File

@ -747,13 +747,13 @@ compute-heavy, but less memory-hungry, computations. For example, consider:
```python
# given a shader, returns a square image
def render(depth, shader):
def render(depth):
bend d = 0, i = 0:
when d < depth:
color = (fork(d+1, i*2+0), fork(d+1, i*2+1))
else:
width = depth / 2
color = shader(i % width, i / width)
color = demo_shader(i % width, i / width)
return color
# given a position, returns a color

View File

@ -1,11 +1,11 @@
# given a shader, returns a square image
def render(depth, shader):
def render(depth):
bend d = 0, i = 0:
when d < depth:
color = (fork(d+1, i*2+0), fork(d+1, i*2+1))
else:
width = depth / 2
color = shader(i % width, i / width)
color = demo_shader(i % width, i / width)
return color
# given a position, returns a color
@ -20,4 +20,4 @@ def demo_shader(x, y):
# renders a 256x256 image using demo_shader
def main:
return render(5, demo_shader)
return render(5)