Skip to content

Commit

Permalink
deploy: 76bca30
Browse files Browse the repository at this point in the history
  • Loading branch information
dwursteisen committed Jan 18, 2024
1 parent 8186ce3 commit 3d628f0
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 9 deletions.
71 changes: 70 additions & 1 deletion dependencies/tiny-api.html
Original file line number Diff line number Diff line change
Expand Up @@ -2415,6 +2415,25 @@ <h4 id="_math_clamp">math.clamp()</h4>
</tr>
</tbody>
</table>
<tiny-editor style="display: none;" >

function _draw()
gfx.cls()

local pos = ctrl.touch()

local x = math.clamp(60, pos.x, 256 - 60)

gfx.dither(0xA5A5)
shape.line(64, 129, 256 - 60, 129, 9)
gfx.dither()
shape.rect(60, 128, 4, 4, 9)
shape.rect(256 - 60, 128, 4, 4, 9)
shape.circlef(pos.x, pos.y, 2, 9)
shape.circle(x, 129, 2, 8)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_dst">math.dst()</h4>
Expand All @@ -2426,6 +2445,26 @@ <h4 id="_math_dst">math.dst()</h4>
<pre class="highlight"><code class="language-lua" data-lang="lua">math.dst(x1, y1, x2, y2) -- Distance between (x1, y1) and (x2, y2).</code></pre>
</div>
</div>
<tiny-editor style="display: none;" >

function _draw()
gfx.cls()

local pos = ctrl.touch()
shape.line(pos.x, pos.y, 128, 128, 3)
shape.circlef(128, 128, 2, 9)
shape.circlef(pos.x, pos.y, 2, 9)

-- midle of the line
local x = (pos.x - 128) * 0.5
local y = (pos.y - 128) * 0.5

-- display dst
local dst = math.dst(128, 128, pos.x, pos.y)
print("dst: "..dst, 128 + x, 128 + y)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_dst2">math.dst2()</h4>
Expand All @@ -2437,6 +2476,36 @@ <h4 id="_math_dst2">math.dst2()</h4>
<pre class="highlight"><code class="language-lua" data-lang="lua">math.dst2(x1, y1, x2, y2) -- Distance not squared between (x1, y1) and (x2, y2).</code></pre>
</div>
</div>
<tiny-editor style="display: none;" >

local a = {
x = 10 + math.rnd(236),
y = 10 + math.rnd(236)
}

local b = {
x = 10 + math.rnd(236),
y = 10 + math.rnd(236)
}

function _draw()
gfx.cls()

local pos = ctrl.touch()

if math.dst2(pos.x, pos.y, a.x, a.y) > math.dst2(pos.x, pos.y, b.x, b.y) then
-- b is closer
shape.line(pos.x, pos.y, b.x, b.y, 3)
else
-- a is closer
shape.line(pos.x, pos.y, a.x, a.y, 3)
end
shape.circlef(a.x, a.y, 2, 9)
shape.circlef(b.x, b.y, 2, 9)
shape.circlef(pos.x, pos.y, 2, 9)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_rnd">math.rnd()</h4>
Expand Down Expand Up @@ -3760,7 +3829,7 @@ <h4 id="_vec2_scl">vec2.scl()</h4>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 19:00:30 UTC
Last updated 2024-01-18 13:34:56 UTC
</div>
</div>
</body>
Expand Down
71 changes: 70 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3671,6 +3671,25 @@ <h4 id="_math_clamp">math.clamp()</h4>
</tr>
</tbody>
</table>
<tiny-editor style="display: none;" >

function _draw()
gfx.cls()

local pos = ctrl.touch()

local x = math.clamp(60, pos.x, 256 - 60)

gfx.dither(0xA5A5)
shape.line(64, 129, 256 - 60, 129, 9)
gfx.dither()
shape.rect(60, 128, 4, 4, 9)
shape.rect(256 - 60, 128, 4, 4, 9)
shape.circlef(pos.x, pos.y, 2, 9)
shape.circle(x, 129, 2, 8)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_dst">math.dst()</h4>
Expand All @@ -3682,6 +3701,26 @@ <h4 id="_math_dst">math.dst()</h4>
<pre class="rouge highlight"><code data-lang="lua"><span class="n">math</span><span class="p">.</span><span class="n">dst</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">y2</span><span class="p">)</span> <span class="c1">-- Distance between (x1, y1) and (x2, y2).</span></code></pre>
</div>
</div>
<tiny-editor style="display: none;" >

function _draw()
gfx.cls()

local pos = ctrl.touch()
shape.line(pos.x, pos.y, 128, 128, 3)
shape.circlef(128, 128, 2, 9)
shape.circlef(pos.x, pos.y, 2, 9)

-- midle of the line
local x = (pos.x - 128) * 0.5
local y = (pos.y - 128) * 0.5

-- display dst
local dst = math.dst(128, 128, pos.x, pos.y)
print("dst: "..dst, 128 + x, 128 + y)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_dst2">math.dst2()</h4>
Expand All @@ -3693,6 +3732,36 @@ <h4 id="_math_dst2">math.dst2()</h4>
<pre class="rouge highlight"><code data-lang="lua"><span class="n">math</span><span class="p">.</span><span class="n">dst2</span><span class="p">(</span><span class="n">x1</span><span class="p">,</span> <span class="n">y1</span><span class="p">,</span> <span class="n">x2</span><span class="p">,</span> <span class="n">y2</span><span class="p">)</span> <span class="c1">-- Distance not squared between (x1, y1) and (x2, y2).</span></code></pre>
</div>
</div>
<tiny-editor style="display: none;" >

local a = {
x = 10 + math.rnd(236),
y = 10 + math.rnd(236)
}

local b = {
x = 10 + math.rnd(236),
y = 10 + math.rnd(236)
}

function _draw()
gfx.cls()

local pos = ctrl.touch()

if math.dst2(pos.x, pos.y, a.x, a.y) > math.dst2(pos.x, pos.y, b.x, b.y) then
-- b is closer
shape.line(pos.x, pos.y, b.x, b.y, 3)
else
-- a is closer
shape.line(pos.x, pos.y, a.x, a.y, 3)
end
shape.circlef(a.x, a.y, 2, 9)
shape.circlef(b.x, b.y, 2, 9)
shape.circlef(pos.x, pos.y, 2, 9)
end

</tiny-editor>
</div>
<div class="sect3">
<h4 id="_math_rnd">math.rnd()</h4>
Expand Down Expand Up @@ -5066,7 +5135,7 @@ <h2 id="_licences">Licences</h2>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
<style>
Expand Down
2 changes: 1 addition & 1 deletion licences.html
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ <h2 id="_licences">Licences</h2>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ <h2 id="_examples">Examples</h2>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
<script src="tiny-web-editor.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion tiny-cli.html
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ <h4 id="_examples">Examples</h4>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion tiny-install.html
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ <h2 id="_tiny_install">Tiny Install</h2>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion tiny-showcase.html
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ <h2 id="_tiny_showcase">Tiny Showcase</h2>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion tiny-tutorial.html
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ <h3 id="_step_3_draw_the_game">Step 3: Draw the Game</h3>
<div id="footer">
<div id="footer-text">
Version main<br>
Last updated 2024-01-17 18:57:57 UTC
Last updated 2024-01-18 13:32:16 UTC
</div>
</div>
</body>
Expand Down
2 changes: 1 addition & 1 deletion tiny-web-editor.js.map

Large diffs are not rendered by default.

0 comments on commit 3d628f0

Please sign in to comment.