La personne qui a associé une œuvre avec cet acte l’a placée dans le domaine public en renonçant mondialement à tous ses droits sur cette œuvre en vertu des lois relatives au droit d’auteur, ainsi qu’à tous les droits juridiques connexes et voisins qu’elle possédait sur l’œuvre, sans autre limite que celles imposées par la loi. Vous pouvez copier, modifier, distribuer et utiliser cette œuvre, y compris à des fins commerciales, sans qu’il soit nécessaire d’en demander la permission.
http://creativecommons.org/publicdomain/zero/1.0/deed.enCC0Creative Commons Zero, Public Domain Dedicationfalsefalse
Source code
The SVG was generated by running the Lua program given below. It deliberately fails if the closest points would be overlapping in the image, because that would be confusing.
local WD, HT, NUM_POINTS = 256, 256, 16
local COLOR = { normal = '#000', closest = '#f00' }
local RADIUS = 5
math.randomseed(os.time())
local P = {}
for _ = 1, NUM_POINTS do
P[#P+1] = { x = RADIUS + (WD - 2*RADIUS) * math.random(),
y = RADIUS + (HT - 2*RADIUS) * math.random() }
end
-- Find closest pair, using naive algorithm.
local closest_a, closest_b
local min_dist
for i, p in ipairs(P) do
for j, q in ipairs(P) do
if i ~= j then
local dist = math.sqrt((p.x - q.x)^2 + (p.y - q.y)^2)
if not min_dist or dist < min_dist then
min_dist = dist
closest_a, closest_b = i, j
end
end
end
end
if min_dist < RADIUS then
error("points on top of each other, run me again")
end
io.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n',
'<svg svg="http://www.w3.org/2000/svg" version="1.0"',
' width="', WD, '" height="', HT, '">\n')
for i, p in ipairs(P) do
local color = COLOR.normal
if i == closest_a or i == closest_b then color = COLOR.closest end
io.write(' <circle cx="', RADIUS + p.x, '" cy="', RADIUS + p.y,
'" r="', RADIUS, '" style="fill:', color, '"/>\n')
end
io.write('</svg>\n')
Légendes
Ajoutez en une ligne la description de ce que représente ce fichier