Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Trigonometría Bella
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Lupo Montero
September 25, 2020
Programming
45
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Trigonometría Bella
LimaJS 25 Sep 2020
Lupo Montero
September 25, 2020
More Decks by Lupo Montero
See All by Lupo Montero
Analizadores sintácticos funcionales en JavaScript
lupomontero
0
100
Manejo de memoria en Rust: Ownership
lupomontero
0
48
Hola Rust! Aprendiendo con rustlings
lupomontero
1
330
WebThing: construyamos una lámpara 💡
lupomontero
1
93
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
34
Reduzco, reuso y reciclo
lupomontero
0
45
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
59
Primeros pasos con Rust y WebAssembly
lupomontero
0
550
Paralelizando promesas
lupomontero
0
360
Other Decks in Programming
See All in Programming
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
950
AIを活用したE2Eテスト実装効率化のあゆみ / ebisu-mobile-14-kotetu
kotetuco
0
130
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
1
420
作って学ぶ、 JSX (TSX) ランタイムの基本
syumai
7
1.7k
Vite+ Unified Toolchain for the Web
naokihaba
0
360
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
190
The NotImplementedError Problem in Ruby
koic
1
950
Javaの型とAI時代に型が大事な理由 / java types and type in AI era
kishida
2
150
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
2.3k
AIキャラアプリkaiwaの低遅延音声通話基盤をどう作ったか - AWS Gravitonで支える低遅延・低コストAI Agent基盤
mogamit
0
100
過去最大のMCPアップデート! 2026-07-28 RC版の謎に迫る
licux
6
400
エンジニアと一緒にテストコードの設計と実装を改善した話
mototakatsu
0
220
Featured
See All Featured
Optimising Largest Contentful Paint
csswizardry
37
3.7k
The Curse of the Amulet
leimatthew05
2
13k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
4.1k
Believing is Seeing
oripsolob
1
150
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.3k
Discover your Explorer Soul
emna__ayadi
2
1.1k
The Curious Case for Waylosing
cassininazir
1
400
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
870
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
310
GitHub's CSS Performance
jonrohan
1033
470k
Art, The Web, and Tiny UX
lynnandtonic
304
22k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.2k
Transcript
Trigonometría Bella @lupomontero - LimaJS 25 Sep 2020 😷
@Laboratoriala @LimaJSorg @node_lima @lupomontero @mozillaperu
None
Comencemos por la demo...
Ahora sí, veamos un poco de JavaScript
Preparando el escenario
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); // ... return canvas; };
const createCanvas = (width = 500) => { const canvas
= document.createElement('canvas'); canvas.width = width; canvas.height = width; // ... return canvas; };
El motor de la animación
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); const update = (angle = 0) => { // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); }; update(); return canvas; };
Definamos el origen
const createCanvas = (width = 500) => { const canvas
= Object.assign( document.createElement('canvas'), { width, height: width }, ); const radius = width / 2; const center = { x: radius, y: radius }; const update = (angle = 0) => { // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); }; update(); return canvas; };
Calculamos la posición del punto en la circunferencia para un
ángulo dado
const update = (angle = 0) => { const radians
= angle * Math.PI / 180; const pointOnCircle = { x: center.x + Math.cos(radians) * radius, y: center.y + Math.sin(radians) * radius, }; // Dibujar frame!! window.requestAnimationFrame(() => update(angle < 359 ? angle + 1 : 0)); };
Dibujando líneas
const drawLine = (ctx, fromX, fromY, toX, toY) => {
ctx.beginPath(); ctx.moveTo(fromX, fromY); ctx.lineTo(toX, toY); ctx.stroke(); };
Dibujando círculos
const drawCircle = (ctx, x, y, radius, color, stroke =
true) => { ctx.beginPath(); ctx.arc(x, y, radius, 0, 2 * Math.PI); if (stroke) { ctx.stroke(); } if (color) { ctx.fillStyle = color; ctx.fill(); } };
Conclusiones
Conclusiones • Explorar • Jugar • Aprender • Búsqueda de
belleza y simplicidad
Links / Bibliografía • Demo • Código fuente • Beautiful
Trigonometry - Numberphile • https://www.geogebra.org/m/S2W46Thv • https://en.wikipedia.org/wiki/Trammel_of_Archimedes • https://ee.stanford.edu/~hellman/playground/hyperspheres/radians.html • https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API
Fin