-
Notifications
You must be signed in to change notification settings - Fork 1
/
mandelbot.html
77 lines (65 loc) · 4.14 KB
/
mandelbot.html
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
66
67
68
69
70
71
72
73
74
75
76
77
{% comment %}
Every Mandelbot must have a unique id:
id (example: mandelbot1)
Mandelbots may also have the following properties:
widthView (default: '200')
heightView (default: widthView)
widthGrid (default: widthView)
heightGrid (default: heightView)
widthStyle (default: 'auto')
heightStyle (default: 'auto')
xCenter (default: '-0.65')
yCenter (default: '0')
dxCenter (default: '1.5')
dyCenter (default: dxCenter)
bigNumbers (default: 'false')
palette (default: 'gray')
shape (default: 'rect')
idStatus (default: '')
idDebug (default: '')
idReset (default: '')
idPrevious (default: '')
idDownload (default: '')
Any property definition in the include tag overrides that property definition in the Front Matter.
{% endcomment %}
{% assign mandelbot = nil %}
{% for m in page.mandelbots %}
{% if include.id == m.id %}
{% assign mandelbot = m %}
{% break %}
{% endif %}
{% endfor %}
{% assign idView = include.id | default: 'default' %}
{% assign widthView = include.widthView | default: mandelbot.widthView | default: '200' %}
{% assign heightView = include.heightView | default: mandelbot.heightView | default: widthView %}
{% assign widthGrid = include.widthGrid | default: mandelbot.widthGrid | default: widthView %}
{% assign heightGrid = include.heightGrid | default: mandelbot.heightGrid | default: heightView %}
{% assign widthStyle = include.widthStyle | default: mandelbot.widthStyle | default: 'auto' %}
{% assign heightStyle = include.heightStyle | default: mandelbot.heightStyle | default: 'auto' %}
{% capture viewStyle %}width: {{widthStyle}}; height: {{heightStyle}}{% endcapture %}
{% assign xCenter = include.xCenter | default: mandelbot.xCenter | default: 'undefined' %}
{% assign yCenter = include.yCenter | default: mandelbot.yCenter | default: 'undefined' %}
{% assign dxCenter = include.dxCenter | default: mandelbot.dxCenter | default: 'undefined' %}
{% assign dyCenter = include.dyCenter | default: mandelbot.dyCenter | default: dxCenter %}
{% assign bigNumbers = include.bigNumbers | default: mandelbot.bigNumbers | default: 'false' %}
{% assign palette = include.palette | default: mandelbot.palette | default: 'gray' %}
{% assign shape = include.shape | default: mandelbot.shape | default: 'rect' %}
{% assign idStatus = include.idStatus | default: mandelbot.idStatus | default: '' %}
{% assign idDebug = include.idDebug | default: mandelbot.idDebug | default: '' %}
{% assign idReset = include.idReset | default: mandelbot.idReset | default: '' %}
{% assign idPrevious = include.idPrevious | default: mandelbot.idPrevious | default: '' %}
{% assign idDownload = include.idDownload | default: mandelbot.idDownload | default: '' %}
{% capture parms %}{{ widthGrid }},{{ heightGrid }},{{ xCenter }},{{ yCenter }},{{ dxCenter }},{{ dyCenter }},{{ bigNumbers }},Mandelbot.PALETTE.{{ palette | upcase }},Mandelbot.SHAPE.{{ shape | upcase }},"{{ idView }}","{{ idStatus }}"{% endcapture %}
<canvas class="mandelbot-{{ shape }}" id="{{ idView }}" width="{{ widthView }}" height="{{ heightView }}" style="{{ viewStyle }}"></canvas>
{% if idDebug != '' and page.developer or site.developer %}<button id="{{ idDebug }}" type="button">Debug</button>{% endif %}
{% if idReset != '' %}<button id="{{ idReset }}" type="button">Reset</button>{% endif %}
{% if idPrevious != '' %}<button id="{{ idPrevious }}" type="button" disabled="disabled">Previous</button>{% endif %}
{% if idDownload != '' %}<button id="{{ idDownload }}" type="button">Download</button>{% endif %}
{% if idStatus != '' %}<p class="mandelbot-status" id="{{ idStatus }}">No status</p>{% endif %}
<script type="text/javascript">
var mandelbot = newMandelbot({{ parms }});
{% if idDebug != '' and page.developer or site.developer %}if (mandelbot) mandelbot.addControl(Mandelbot.CONTROL_DEBUG, "{{ idDebug }}");{% endif %}
{% if idReset != '' %}if (mandelbot) mandelbot.addControl(Mandelbot.CONTROL_RESET, "{{ idReset }}");{% endif %}
{% if idPrevious != '' %}if (mandelbot) mandelbot.addControl(Mandelbot.CONTROL_PREVIOUS, "{{ idPrevious }}");{% endif %}
{% if idDownload != '' %}if (mandelbot) mandelbot.addControl(Mandelbot.CONTROL_DOWNLOAD, "{{ idDownload }}");{% endif %}
</script>