Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
31
Task/Fractal-tree/Red/fractal-tree-1.red
Normal file
31
Task/Fractal-tree/Red/fractal-tree-1.red
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
Red [Needs: 'View]
|
||||
|
||||
color: brown
|
||||
width: 9
|
||||
view/tight/options/flags/no-wait [ ; click image to grow tree
|
||||
img: image 1097x617 draw [
|
||||
pen brown line-width 9 line 500x600 500x500] [grow]
|
||||
] [offset: 0x0] [no-border]
|
||||
|
||||
ends: reduce [500x500 pi * 3 / 2] ; list of terminal nodes
|
||||
da: pi * 30 / 180 ; angle of branches in radians
|
||||
ea: pi * 5 / 180 ; offset added to angle to break symmetry
|
||||
|
||||
l: 200 ; branches initial lenght
|
||||
scale: 0.7 ; branches scale factor
|
||||
grow: does [ ; grows branches
|
||||
l: l * scale
|
||||
color: 2 * color + leaf / 3
|
||||
width: width - 1
|
||||
newends: copy []
|
||||
foreach [p a] ends [
|
||||
a1: a + da - ea
|
||||
p1: p + as-pair l * cos a1 l * sin a1
|
||||
a2: a - da - ea
|
||||
p2: p + as-pair l * cos a2 l * sin a2
|
||||
append img/draw compose/deep [
|
||||
pen (color) line-width (width) line (p1) (p) (p2)]
|
||||
append newends reduce [p1 a1 p2 a2]
|
||||
]
|
||||
ends: newends
|
||||
]
|
||||
116
Task/Fractal-tree/Red/fractal-tree-2.red
Normal file
116
Task/Fractal-tree/Red/fractal-tree-2.red
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
Red [
|
||||
Title: "Organic Fractal Tree"
|
||||
Author: "hinjolicious"
|
||||
Needs: 'View
|
||||
Note: "Some code are adapted from Red example in Rosetta Code"
|
||||
]
|
||||
|
||||
xsize: 1920 ; display width
|
||||
ysize: 1080 ; height
|
||||
xmid: to integer! xsize / 2 ; horiz middle
|
||||
ymid: to integer! ysize / 2 ; vert middle
|
||||
dist: to integer! ysize * 0.8
|
||||
iter: 0
|
||||
plant: yes
|
||||
|
||||
INIT: does [
|
||||
if iter > 10 [ ; enough trees?
|
||||
iter: 0
|
||||
clear img/draw
|
||||
dist: to integer! ysize * 0.8
|
||||
]
|
||||
trunk-height: ysize * random 0.2 ; trunk height
|
||||
root-xpos: random xsize
|
||||
root-ypos: dist + random trunk-height
|
||||
dist: dist + (10 + random 20)
|
||||
root-pos: as-point2d root-xpos root-ypos
|
||||
branch-ypos: root-ypos - trunk-height
|
||||
branch-pos: as-point2d root-xpos branch-ypos
|
||||
|
||||
if branch-ypos > ysize [ ; how many times branch pos is out of screen?
|
||||
iter: iter + 1
|
||||
]
|
||||
color: as-color random 10 random 30 random 10 ; trunk/branch color
|
||||
width: 5 + random 10 ; trunk width
|
||||
ends: reduce [branch-pos pi * 1.5] ; list of terminal nodes
|
||||
l: 50 + random 50 ; branches initial lenght
|
||||
]
|
||||
|
||||
GROW: does [ ; grow branches
|
||||
scale: 0.6 + random 0.4
|
||||
l: l * scale
|
||||
if l < 15 [init plant: yes]
|
||||
|
||||
color: color * 1.3
|
||||
width: width * 0.8
|
||||
newends: copy []
|
||||
|
||||
; flower color
|
||||
flower: do random/only [red orange yellow cyan blue violet purple magenta pink white]
|
||||
|
||||
foreach [p a] ends [
|
||||
da: pi * ( 2 + random 30) / 180 ; angle of branches in radians
|
||||
ea: pi * (-10 + random 20) / 180 ; offset added to angle to break symmetry
|
||||
|
||||
a1: a + da - ea p1: p + as-point2d l * cos a1 l * sin a1
|
||||
a2: a - da - ea p2: p + as-point2d l * cos a2 l * sin a2
|
||||
|
||||
either l < 21 [ ; draw leaves or flowers
|
||||
either (random 100) > 97 [ ; flowers
|
||||
lc: flower * (0.5 + random 1.5) rad: 3 + random 10
|
||||
lc1: flower * (0.5 + random 1.5) rad1: 3 + random 10
|
||||
lc2: flower * (0.5 + random 1.5) rad2: 3 + random 10
|
||||
append img/draw compose/deep [
|
||||
line-width 0
|
||||
pen (lc) fill-pen (lc) circle (p) (rad)
|
||||
pen (lc1) fill-pen (lc1) circle (p1) (rad1)
|
||||
pen (lc2) fill-pen (lc2) circle (p2) (rad2)
|
||||
fill-pen 00.00.00.255 ]
|
||||
][ ; leaves
|
||||
lc: color * (0.5 + random 1.5)
|
||||
append img/draw compose/deep [
|
||||
line-width 0
|
||||
pen (lc)
|
||||
fill-pen (lc)
|
||||
line (p) (p1) (p2) (p)
|
||||
fill-pen 00.00.00.255 ]
|
||||
]
|
||||
][ ; branches
|
||||
append img/draw compose/deep [
|
||||
line-width (width)
|
||||
pen (color)
|
||||
line (p1) (p) (p2) ]
|
||||
]
|
||||
append newends reduce [p1 a1 p2 a2]
|
||||
]
|
||||
ends: newends
|
||||
]
|
||||
|
||||
TREES: does [ ; not used!
|
||||
append img/draw compose/deep [ ; trunk
|
||||
line-width (width)
|
||||
pen (color)
|
||||
line (root-pos) (branch-pos) ]
|
||||
]
|
||||
|
||||
GARDEN: does [
|
||||
either plant [plant: no trees][grow]
|
||||
]
|
||||
|
||||
MAIN: does [
|
||||
init
|
||||
view/tight/options/flags [
|
||||
img: base
|
||||
with [size: as-pair xsize ysize]
|
||||
black ; background
|
||||
draw [] ; draw are in "on-time"
|
||||
rate 10
|
||||
on-time [garden]
|
||||
[quit] ; click mouse to quit
|
||||
]
|
||||
[offset: 0x0] ; not-needed
|
||||
[no-border] ; no border!
|
||||
]
|
||||
|
||||
random/seed now/time
|
||||
main
|
||||
Loading…
Add table
Add a link
Reference in a new issue