-
Notifications
You must be signed in to change notification settings - Fork 1
/
TallyArt.m
83 lines (58 loc) · 2.06 KB
/
TallyArt.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
clear all; clc; close all;
% close all;
% figure;
hold on;
colormap gray;
% Constants
paperHeight = 3000;
paperWidth = 3000;
resolution = 30;
margin = 500;
currentX = margin; % starting x
currentY = margin; % starting y
% Seeds
globalAlpha = 1.0; % location aware parameter
% Height
tallyWidthPercent = .5; % percentage of resolution
tallyHeightPercent = 10; % percentage of resolution
tallyHeightVariation = 0.02; % max variation as percentage of height
% Spacing
xSpacingPercent = 0.1; % percentage of width
ySpacingPercent = 0.02; % percentage of width
paper = zeros(paperHeight, paperWidth);
tallyHeight = tallyHeightPercent * resolution;
tallyMinHeight = round(tallyHeight * 0.8);
tallyMaxHeight = round(tallyHeight * 1.2);
tallyWidth = tallyWidthPercent * resolution;
while currentY < paperHeight - margin
currentX = margin;
totalHeight = 0;
tallyCount = 0;
while currentX < paperWidth - margin
heightDelta = round(tallyHeightVariation * tallyHeight * randn());
newTallyHeight = tallyHeight + heightDelta;
tallyHeight = max(tallyMinHeight, min(tallyMaxHeight, newTallyHeight));
totalHeight = totalHeight + tallyHeight;
tallyCount = tallyCount + 1;
x = currentX;
y = currentY;
% Create a mark
w = round(tallyWidth);
h = round(tallyHeight);
tally = DrawTally(w, h, 0.05);
% Add the mark to the paper
paper(y:y + h - 1, x:x + w - 1) = ...
paper(y:y + h - 1, x:x + w - 1) + tally;
% Change parameters
deltaX = tallyWidth + xSpacingPercent * tallyWidth * randn();
currentX = currentX + deltaX;
deltaY = ySpacingPercent * tallyHeight * randn();
currentY = currentY + deltaY;
end
currentY = currentY + totalHeight / tallyCount;
end
paper = 1-paper;
%paper = max(max(paper)) - paper;
imagesc(paper)
imwrite(paper, 'Large.png');
axis equal