File:Simulatedelection.png
Page contents not supported in other languages.
Tools
Actions
General
In other projects
Appearance
Simulatedelection.png (600 × 600 pixels, file size: 70 KB, MIME type: image/png)
This is a file from the Wikimedia Commons. Information from its description page there is shown below. Commons is a freely licensed media file repository. You can help. |
Summary
DescriptionSimulatedelection.png |
English: #include <stdio.h>
}
int main() { int i,j,k ; double x,y,u,v ; int xa,ya,xb,yb,xc,yc,dx,dy,xm,ym ; printf("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" "<svg xmlns=\"http://www.w3.org/2000/svg\"\n" "xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" "width=\"600\" height=\"600\">\n" "<title>A simulated election</title>\n") ; for(i=0;i<600;i++) for(j=0;j<600;j++) { u = i - 300 ; v = j - 300 ; x = exp(-(u*u+v*v)/80000) ; k = (int) (0.5 + 255 * (1-x) ) ; printf("<rect width=\"1\" height=\"1\" x=\"%d\" y=\"%d\"" " style=\"fill:rgb(%d,%d,%d)\"/>\n",i,j,k,k,k) ; } xa = 180 ; ya = 350 ; xb = 450 ; yb = 130 ; xc = 420 ; yc = 430 ; printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xa,ya) ; printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xb,yb) ; printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"red\"/>\n",xc,yc) ; printf("<circle cx=\"%d\" cy=\"%d\" r=\"4\" fill=\"yellow\"/>\n",300,300) ; xm = (xa+xb)/2 ; ym = (ya+yb)/2 ; dx = -(yb-ya) ; dy = (xb-xa) ; printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n " "style=\"stroke:red;stroke-width:2\"/>\n", xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ; xm = (xb+xc)/2 ; ym = (yb+yc)/2 ; dx = -(yc-yb) ; dy = (xc-xb) ; printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n " "style=\"stroke:red;stroke-width:2\"/>\n", xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ; xm = (xc+xa)/2 ; ym = (yc+ya)/2 ; dx = -(ya-yc) ; dy = (xa-xc) ; printf("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n " "style=\"stroke:red;stroke-width:2\"/>\n", xm-6*dx,ym-6*dy,xm+6*dx,ym+6*dy) ; printf("<text x=\"%d\" y=\"%d\" fill=\"red\">A</text>\n",(int)xa-6,(int)ya+20) ; printf("<text x=\"%d\" y=\"%d\" fill=\"red\">B</text>\n",(int)xb-6,(int)yb+20) ; printf("<text x=\"%d\" y=\"%d\" fill=\"red\">C</text>\n",(int)xc-6,(int)yc+20) ; printf("<text x=\"294\" y=\"320\" fill=\"yellow\">O</text>\n") ; printf("<text x=\"40\" y=\"520\" fill=\"red\">A–C–B</text>\n") ; printf("<text x=\"380\" y=\"560\" fill=\"red\">C–A–B</text>\n") ; printf("<text x=\"540\" y=\"420\" fill=\"red\">C–B–A</text>\n") ; printf("<text x=\"540\" y=\"100\" fill=\"red\">B–C–A</text>\n") ; printf("<text x=\"260\" y=\"40\" fill=\"red\">B–A–C</text>\n") ; printf("<text x=\"20\" y=\"90\" fill=\"red\">A–B–C</text>\n") ;printf("</svg>\n") ; |
Date | |
Source | Own work |
Author | Colin.champion |
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
- You are free:
- to share – to copy, distribute and transmit the work
- to remix – to adapt the work
- Under the following conditions:
- attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
- share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.
Items portrayed in this file
depicts
27 June 2021
File history
Click on a date/time to view the file as it appeared at that time.
Date/Time | Thumbnail | Dimensions | User | Comment | |
---|---|---|---|---|---|
current | 07:37, 12 July 2021 | 600 × 600 (70 KB) | Colin.champion | larger font, paler background | |
10:37, 27 June 2021 | 600 × 600 (75 KB) | Colin.champion | Uploaded own work with UploadWizard |
File usage
The following page uses this file:
Retrieved from "https://en.wikipedia.org/wiki/File:Simulatedelection.png"