Peripheral drift illusion: Difference between revisions
Content added Content deleted
m (Adjusting Media setting.) |
m (Minor improvements to code.) |
||
Line 352: | Line 352: | ||
public PeripheralDrift() { |
public PeripheralDrift() { |
||
setPreferredSize( new Dimension( |
setPreferredSize( new Dimension(600, 600) ); |
||
setBackground(LIGHT_OLIVE); |
setBackground(LIGHT_OLIVE); |
||
} |
} |
||
Line 370: | Line 370: | ||
final int cellSize = outerSquare / 12; |
final int cellSize = outerSquare / 12; |
||
final int boxSize = cellSize * 75 / 100; |
final int boxSize = cellSize * 75 / 100; |
||
final int margin = ( cellSize - boxSize ) / 2; |
|||
for ( int row = 0; row < 12; row++ ) { |
for ( int row = 0; row < 12; row++ ) { |
||
int x = border + row * cellSize; |
int x = border + margin + row * cellSize; |
||
for ( int col = 0; col < 12; col++ ) { |
for ( int col = 0; col < 12; col++ ) { |
||
int y = border + col * cellSize; |
int y = border + margin + col * cellSize; |
||
drawBox(x, y, boxSize, EDGES.get(col).get(row), aGraphics2D); |
drawBox(x, y, boxSize, EDGES.get(col).get(row), aGraphics2D); |
||
} |
} |
||
Line 431: | Line 432: | ||
} |
} |
||
</syntaxhighlight> |
</syntaxhighlight> |
||
[[File:PeripheralDriftJava.png]] |
|||
{{ out }} |
|||
[[File:PeripheralDriftIllusionJava.png]] |
|||
=={{header|Julia}}== |
=={{header|Julia}}== |