12 lines of JavaScript code drawing a gossip map

Source: Internet
Author: User
Tags pow

In a word: Build a 1024*1024 color matrix with limited code, show your programming & Art Beauty

One of the problems that originated in Stackexchange is a bit of an extension that supports more programming languages and relaxes the limits of code length.
Rules

Goal:
By implementing a function Get_color_at (x, y) in the template, draw the "interesting" pattern on a 1024*1024 canvas.

Parameters:
int x, int y, values are 0-1023, corresponding to the canvas on the punctuation, the upper left corner is the starting point (0,0)

Return:
int r, int g, int b, int alpha, RGBA component of corresponding color, all 0-255.

Attention:
The alpha component definitions in each language may be different, and the unified conversion of the template to: 0-255, the greater the value the more transparent.

Requirements:
You can only edit code in the Get_color_at (x, y) function body/{{Code start}}-//{{code end}} in the template;
The total number of code characters cannot exceed 1024, and is of good readability.

1 2 3 4 5 6 7 8 9 of if (typeof f_c== "undefined") {f_c=function (x,y,px,py,r) {return math.sqrt (Math.pow (x-px,2) +math.pow (y-py,2)) <=r ; }; } var x0=x-512,y0=y-512; r=g=b=128; if (F_c (x0,y0,0,0,512)) r=g=b= (x0>0) 255:0; if (F_c (x0,y0,0,256,256) &&x0<=0) r=g=b=255; if (F_c (x0,y0,0,-256,256) &&x0>0) r=g=b=0; if (F_c (x0,y0,0,256,64)) r=g=b=0; if (F_c (x0,y0,0,-256,64)) r=g=b=255;
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.