Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Trigonometría Bella
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Lupo Montero
September 25, 2020
Programming
51
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
110
Manejo de memoria en Rust: Ownership
lupomontero
0
51
Hola Rust! Aprendiendo con rustlings
lupomontero
1
350
WebThing: construyamos una lámpara 💡
lupomontero
1
110
Combinando y grabando ⏺ video 🎥 y audio 🎙 en el navegador
lupomontero
0
45
Reduzco, reuso y reciclo
lupomontero
0
48
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
68
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
380
Other Decks in Programming
See All in Programming
R8 の設定見直しでアプリサイズ削減
andpad
0
230
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
170
Compiling a real-world CLI tool to native with Static Hermes
tmikov2023
0
130
AmebaブログはKMPから卒業します
kmars0605
0
220
🇪🇸 React Alicante 2026 (Workshop)
ythecombinator
PRO
0
110
AI時代のTerminal環境を UNIX哲学で設計・運用する
yasunori0418
1
200
GraphQL の onError と Nullability のこれから
quramy
0
180
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
3
1.1k
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
200
【加筆修正版】Laravel のアプリケーションをどこにデプロイするか #phpcon_ehime
akase244
0
160
Rでドレミ/Do-Re-Mi_with_R
florets1
0
130
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
50
10k
Building AI with AI
inesmontani
PRO
1
1.3k
Java REST API Framework Comparison - PWX 2021
mraible
34
9.8k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
300
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.4k
A designer walks into a library…
pauljervisheath
211
25k
Thoughts on Productivity
jonyablonski
76
5.4k
HDC tutorial
michielstock
2
970
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
440
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
Bash Introduction
62gerente
615
220k
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