1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

paiza.ioでelixirAdvent Calendar 2022

Day 19

paiza.ioでelixir その69

Last updated at Posted at 2022-11-13

概要

paiza.ioでelixirやってみた。
Ray Tracerやってみた。

参考にしたページ

サンプルコード


IO.puts """
<!doctype html>
<html>
  <head>
    <link rel="stylesheet" href="lib/style.css">
  </head>
  <body>
    <canvas id="canvas" width="80" height="60"></canvas>
    <script>
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var img = ctx.createImageData(80, 60);
var data = img.data;
var v = [
"""
nx = 80
ny = 60
for y <- ny - 1..0 do
    for x <- 0..nx - 1 do
        [x / nx, y / ny, 0.2]
        |> Enum.map(fn n ->
            255 * n
            |> floor
            |> IO.write
            IO.write ","
		end)
		IO.write "255,"
    end
end
IO.puts """

0];
for (var i = 0; i < 80 * 60 * 4; i++) 
{
	data[i] = v[i];
}
    ctx.putImageData(img, 0, 0);
alert(v[2]);
    </script>
  </body>
</html>
"""


実行結果

image.png

成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?