Skip to content

Reverse engineering of the 1kb JavaScript code that draws a rose.

Notifications You must be signed in to change notification settings

ghosthamlet/1k-rose

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This is a reverse-engineering project for the amazing 1kb JavaScript code
that draws a Rose, written by Román Cortés.

The original minified-obfuscated-hand-written(!) code is in the file 1k-rose.js.
The file 1k-rose.reverse-engineered.js is the result of this project.
Check the Git history to see the steps taken for the reverse-engineering.

The code is competing in the JS1k contest:
	http://js1k.com/2012-love/demo/1022

The author explains the approach for the code in his blog:
	http://www.romancortes.com/blog/1k-rose/




Some ideas to play with the code
--------------------------------
* Get parts based on deformed squares instead of deformed circles by changing
  the test if(A * A + B * B < 1) to if(true  ||  A * A + B * B < 1)
* Draw the parts selectively by inserting conditions. For example, to draw only
  the first 5 petals, use the condition:
	if(c > 6  &&  c < 37) return;
  See values for c in the table at the end of the reverse-engineered file.
* Play with the colors by changing the fields "r" and "g" in the objects returned
  by the surface function.



TO DO
-----
* Understand the variables n, o, w, h

About

Reverse engineering of the 1kb JavaScript code that draws a rose.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published