Obrázok:Random go position.png

Z Wikipédie

Tento súbor je zdieľaný zdroj a môže byť použitý v iných wiki.


Wikimedia Commons Logo Toto je súbor z Wikimedia Commons. Prosíme pozrite si jeho popisnú stránku .

A Go position, used to illustrate the rules of Go.

David Benbennick made it with the following Metapost program, modified slightly from the code at Image:Go position, life and death, 1.png:

scale=0.6in;   % scale is the diameter of a stone
linethickness = scale/25;
pickup pencircle scaled linethickness;
num = 150;  % Levels of shading in each stone.

color shadow;
shadow = (0.44,0.36,0.18);

lx = -0.35;
ly = 0.35;
lz = sqrt(1-lx*lx-ly*ly);
  % light source direction vector.
  % note that lz = cos(ltip).
ltheta = angle(lx, ly);
ltip = angle(lz, lx++ly);
  % the angle at which the light source is tipped.

path ellipse;
ellipse := fullcircle scaled scale xscaled lz;


% First, we draw the black stone, and a special version for the bottom row:
picture blackstone;
blackstone = currentpicture;
picture blackstoneb;
blackstoneb = currentpicture;
picture blackstoner;
blackstoner = currentpicture;

addto blackstone contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto blackstoneb contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto blackstoner contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto blackstone doublepath (0.55*scale,0)--(0,0)--(0,-0.55*scale)
  withpen currentpen;
addto blackstoneb doublepath (0.55*scale,0)--(0,0)
  withpen currentpen;
addto blackstoner doublepath (0,-0.55*scale)--(0,0)
  withpen currentpen;
addto blackstone contour fullcircle scaled scale;
addto blackstoneb contour fullcircle scaled scale;
addto blackstoner contour fullcircle scaled scale;

for ratio = 1 step -1/num until 0 :
  path ourellipse;
  ourellipse = ellipse scaled ratio
    shifted (scale*(1+-+ratio)*sind(ltip)/2, 0)
    rotated ltheta;

  addto blackstone contour ourellipse withcolor (0.7*(1+-+ratio)**2*white);
  addto blackstoneb contour ourellipse withcolor (0.7*(1+-+ratio)**2*white);
  addto blackstoner contour ourellipse withcolor (0.7*(1+-+ratio)**2*white);
endfor;


% Next, we draw a white stone, and a special version for the bottom row:
picture whitestone;
whitestone = currentpicture;
picture whitestoneb;
whitestoneb = currentpicture;
picture whitestoner;
whitestoner = currentpicture;

basewhite = 0.7;
addto whitestone contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto whitestoneb contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto whitestoner contour fullcircle scaled scale
  shifted (0.05*scale*dir(ltheta+180)) 
  withcolor shadow;
addto whitestone doublepath (0.55*scale,0)--(0,0)--(0,-0.55*scale)
   withpen currentpen;
addto whitestoneb doublepath (0.55*scale,0)--(0,0) withpen currentpen;
addto whitestoner doublepath (0,-0.55*scale)--(0,0) withpen currentpen;
addto whitestone contour fullcircle scaled scale
   withcolor (basewhite*white);
addto whitestoneb contour fullcircle scaled scale
   withcolor (basewhite*white);
addto whitestoner contour fullcircle scaled scale
   withcolor (basewhite*white);

for ratio = 1 step -1/num until 0 :
  path ourellipse;
  ourellipse = ellipse scaled ratio
    shifted (scale*(1+-+ratio)*sind(ltip)/2, 0)
    rotated ltheta;

  addto whitestone contour ourellipse withcolor
    (basewhite + (1-basewhite)*((1+-+ratio)**4))*white;
  addto whitestoneb contour ourellipse withcolor
    (basewhite + (1-basewhite)*((1+-+ratio)**4))*white;
  addto whitestoner contour ourellipse withcolor
    (basewhite + (1-basewhite)*((1+-+ratio)**4))*white;
endfor;


boardwidth = 5;
boardheight = 5;
  % a 5-by-5 positions of a go board.

def drawboard = 
  pickup pencircle scaled linethickness;
  fill unitsquare xscaled ((boardwidth+0.2)*scale)
    yscaled ((boardheight+0.2)*scale) shifted (-0.6*scale, -0.6scale)
    withcolor (0.86,0.70,0.36);
  for i = 0 upto boardwidth - 1 :
    draw (scale*i,0) -- (scale*i, (boardheight-1)*scale);
  endfor;
  for j = 0 upto boardheight - 1 :
    draw (0,scale*j) -- ((boardwidth-1)*scale,scale*j);
  endfor;
enddef;

def wh(expr x, y) =
  if y = 0 :
    draw whitestoneb shifted (x*scale, y*scale);
  elseif x = boardwidth - 1 :
    draw whitestoner shifted (x*scale, y*scale);
  else :
    draw whitestone shifted (x*scale, y*scale);
  fi;
enddef;
def bl(expr x, y) =
  if y = 0 :
    draw blackstoneb shifted (x*scale, y*scale);
  elseif x = boardwidth - 1 :
    draw blackstoner shifted (x*scale, y*scale);
  else :
    draw blackstone shifted (x*scale, y*scale);
  fi;
enddef;
def lab(expr num, x, y, color) =
  draw thelabel(num, (0, 0)) scaled (0.75*scale/10pt)
    shifted (x*scale, y*scale) withcolor color;
enddef;


beginfig(1);
  drawboard;

  bl(1,4);bl(4,4);bl(0,3);bl(1,3);wh(3,3);bl(4,3);wh(2,2);wh(0,1);
  wh(2,1);bl(3,1);wh(4,1);bl(1,0);wh(2,0);wh(3,0);

 currentpicture := currentpicture shifted (3in, 3in);
endfig;
end;

With the above code as Random_go_position.mp, run

mpost Random_go_position.mp
convert -density 800 Random_go_position.1 Random_go_position.pnm
pnmcrop Random_go_position.pnm | pnmtopng > Random_go_position.png.uncrush
pngcrush -reduce -brute -l 9 Random_go_position.png.uncrush Random_go_position.png

to reproduce this image.

I, the author of this work, hereby publish it under the following licenses:
GNU head Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".

العربية | Deutsch | English | Español | Français | Italiano | 日本語 | 한국어 | Nederlands | Polski | Português | Slovenčina | Svenska | עברית +/-

Creative Commons License
Creative Commons Attribution iconCreative Commons Share Alike icon
This file is licensed under Creative Commons Attribution ShareAlike 2.0 License
You may select the license of your choice.

Na tento obrázok odkazujú nasledujúce články: