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でelixirやってみた。
練習問題やってみた。

練習問題

5ボルト直流電源に直列に1キロオームの抵抗をつないだ回路をシミュレートせよ。

サンプルコード


IO.puts """
<!doctype html>
<html>
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
    <title>Circuit Sandbox</title>
    <link rel="stylesheet" href="https://spinningnumbers.org/circuit-sandbox/sandbox.css" />
    <script type="text/javascript" src="https://spinningnumbers.org/circuit-sandbox/js/hammer.min.js"></script>
    <script src="https://kit.fontawesome.com/9defb49fb8.js"></script>
    <script type="text/javascript" src="https://spinningnumbers.org/circuit-sandbox/js/download.js"></script>
<script>
  function switchLanguage(_lang) {
	var head = document.getElementsByTagName('head')[0];
  	var script = document.createElement('script');
  	script.type = 'text/javascript';
	switch (_lang) 
    {
		case 'es':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/es.js';
		break;
		case 'ja':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/ja.js';
		break;
		case 'hu':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/hu.js';
		break;
		case 'hi':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/hi.js';
		break;
		case 'pt':
		case 'pt-BR':
		case 'pt-PT':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/pt.js';
		break;
		case 'zh':
		case 'zh-CN':
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/zh-CN.js';
		break;
		default:
			script.src = 'https://spinningnumbers.org/circuit-sandbox/js/en-US.js';
		}
		document.head.appendChild(script);
	}
	var browserLang = navigator.language;
    var userLang = window.localStorage.getItem('language');
    var lang = userLang ? userLang : browserLang;
	switchLanguage(lang);
</script>
<script>
  var head = document.getElementsByTagName('head')[0];
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://spinningnumbers.org/circuit-sandbox/js/cktsimvsp_sn.js';
  document.head.appendChild(script);
</script>
<script>
  var head = document.getElementsByTagName('head')[0];
  var script = document.createElement('script');
  script.type = 'text/javascript';
  script.src = 'https://spinningnumbers.org/circuit-sandbox/js/schematic.js';
  document.head.appendChild(script);
</script>
<script defer type="text/javascript" src="https://spinningnumbers.org/circuit-sandbox/js/fet_vsp.js"></script>
<script defer type="text/javascript" src="https://spinningnumbers.org/circuit-sandbox/js/fet_vsparms.js"></script>
  </head>
  <body>
    <input type="hidden" class="schematic" height="350" width="500" parts="g,v,r,s,a,c,l" analyses="dc,tran" 
"""
IO.puts """
    value = [["r",[152,64,0],{"name":"R","r":"1k","_json_":0},["1","0"]],["g",[152,112,0],{"_json_":1},["0"]],["w",[48,64,152,64]],["v",[48,64,0],{"name":"V","value":"dc(5.0)","_json_":3},["1","0"]],["g",[48,112,0],{"_json_":4},["0"]],["view",-1.9000000000000092,32.56,2.44140625,"50","1k","100k","dc","100","0.01","1000"]]
"""
IO.puts """
    >
    <p>
	    Circuit Sandbox simulator  &nbsp; &nbsp; &nbsp; &nbsp;
	    <a href="https://spinningnumbers.org">spinningnumbers.org</a> &#8275;
	    <a href="https://spinningnumbers.org/a/circuit-sandbox.html">help</a> &#8275; 
	    <a href="https://github.com/willymcallister/circuit-sandbox">github</a> &nbsp; &nbsp; &nbsp; &nbsp; 
		<select id="languageSelect" onchange="dropdownChange()">
		    <option value="en-US">Language: English</option>
	    	<option value="es">Idioma: Español</option>
		    <option value="pt">Idioma: Portugues</optionvalue>
		    <option value="hu">Nyelv: Magyar (Hungarian)</option>
		    <option value="ja">言語:日本語 (Japanese)</option>
		    <option value="hi">भाषा: हिंदी (Hindi)</option>
		    <option value="zh-CN">语言:简体中文 (Simplified Chinese)</option>
		</select>
	</p>
<script>			
	var dropdown = document.getElementById('languageSelect');
	dropdown.value = lang; 
	function dropdownChange() {
		var selectedLang = dropdown.options[dropdown.selectedIndex].value;
		switchLanguage(selectedLang);
		window.localStorage.setItem('language', selectedLang);
    }
</script>
    <p><em><small>© 2016-2020 Willy McAllister, © 2012 EdX, © 2011, 2018 MIT EECS</small></em></p>
  </body>
</html>
"""




成果物

以上。

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?