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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Lupo Montero
September 25, 2020
Programming
50
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
43
Reduzco, reuso y reciclo
lupomontero
0
48
Web Assembly, Rust y el futuro de JavaScript
lupomontero
0
67
Primeros pasos con Rust y WebAssembly
lupomontero
0
560
Paralelizando promesas
lupomontero
0
370
Other Decks in Programming
See All in Programming
Intent as Code
shoppingjaws
6
1.1k
iOS 27でニュースアプリはどう変わる!? 〜日経電子版の新機能対応と、開発事例から〜
lynnswap
7
13k
Heart of Swift Concurrency
koher
0
1.1k
iOSDC Japan 2026 - Swiftで作って学ぼう!データベース自作入門
kaseken
2
410
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
19
19k
AGENTS.md Is Not Enough:Build Skills, Don't Download Them
lx_t
0
130
仕様駆動開発による爆速プロダクト開発 / Bakusoku Spec Driven Development
kobakei
0
150
アクセシビリティから考える情報設計
high_g_engineer
0
430
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
410
Featured
See All Featured
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Into the Great Unknown - MozCon
thekraken
41
2.7k
We Have a Design System, Now What?
morganepeng
55
8.3k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.9k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
69
66k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
270
Marketing to machines
jonoalderson
1
5.8k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
2k
Designing for Performance
lara
611
70k
エンジニアに許された特別な時間の終わり
watany
109
250k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
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