Skip to content

Instantly share code, notes, and snippets.

xem

Block or report user

Report or block xem

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@xem
xem / readme.md
Last active Sep 15, 2019
Maths & trigonometry cheat sheet for 2D & 3D games
View readme.md

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

View keybase.md

Keybase proof

I hereby claim:

  • I am xem on github.
  • I am xem06 (https://keybase.io/xem06) on keybase.
  • I have a public key ASC5fuxaRvyhB7W-5_bu00ejCWI-x-m3W1yEDXTR-j1m8go

To claim this, I am signing this object:

@xem
xem / codegolf.md
Last active Jul 29, 2019
JS code golfing
View codegolf.md

codegolf JS

Mini projects by Maxime Euzière (xem), subzey, Martin Kleppe (aemkei), Mathieu Henri (p01), Litterallylara, Tommy Hodgins (innovati), Veu(beke), Anders Kaare, Keith Clark, Addy Osmani, bburky, rlauck, cmoreau, maettig, thiemowmde, ilesinge, adlq, solinca, xen_the,...

(For more info and other projects, visit http://xem.github.io)

(Official Slack room: http://jsgolf.club / join us on http://register.jsgolf.club)

@xem
xem / projection.md
Last active Jun 19, 2019
wip projection article
View projection.md

3D projection on a 2D canvas (wip blog post)


A very short article about a very specific topic: draw 3D points on a 2D canvas!
It's not very complex, but it puzzled me for years, until C4ntelope made this handy introduction based on his own intuition and computations, and Román Cortés helped me complete these explanations and simplify the maths and the code.
(This article is based on that Twitter thread).


View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@xem
xem / js1k 2019 ideas.md
Last active Nov 15, 2018
js1k 2019 ideas
View js1k 2019 ideas.md
  • 3D Peach Castle (CSS3D vs. raycasting feat RomanCortes)
  • 3D solar system (feat Yonatan)
  • Two3D clone (feat BalintCsala)
  • 2D physics engine (feat BalintCsala)
  • Mandelbox (feat BalintCsala)
  • An app that generates QR codes containing 1kb demos
  • A 2D WFC tracer
  • random dweet generator
  • SMB 1-1
  • 3D plotter
@xem
xem / LICENSE.txt
Last active Feb 1, 2018 — forked from 140bytes/LICENSE.txt
Mini Game of Life
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
View css.md
  • Don't modify strings (content: "...", font-family: '...')
  • Remove all CSS comments (ex: /* ... */ )
  • Remove all unnecessary spaces, tabs and line breaks (ex: around + > ~ ; : , ( ) { } /)
    • Keep spaces before : in selectors (ex: * :before != *:before)
    • Keep spaces around + and - in calc(...) (but not in nth-child and nth-of-type)
  • Remove all unnecessary ; (ex: a{color:red;})
  • Remove all unnecessary * in CSS selectors (ex: *:before => :before)
  • Remove leading and trailing zeros (ex: 0.1%, 1.0%, 0.0px)
  • Remove units after zero (ex: 0px 0rem 0% 0turn 0vmax 0dpi)
View gist:670dec8e70815842eb95
<!-- solution 1, 117b, inspired by http://www.p01.org/releases/140bytes_music_softSynth/ -->
<button onclick="new Audio('data:audio/wav;base64,UklGRl9vT19XQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YU'+Array(1e3).join(123)).play()">Beep</button>
<!-- Solution 2, 107b, inspired by http://xem.github.io/chip8/c8.html -->
<button onclick="o=(A=new AudioContext()).createOscillator();o.connect(A.destination);o.start(0);setTimeout('o.stop(0)',500)">Boop</button>
@xem
xem / LICENSE.txt
Last active Jan 26, 2017 — forked from 140bytes/LICENSE.txt
Challenge: Executing more than 140 JS characters in a tweet!
View LICENSE.txt
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
You can’t perform that action at this time.