— boreal-kiss.net

Archive
July, 2012 Monthly archive

A company logo of Aperture Science drawn on Processing. Aperture Science is a virtual company appearing in a video game Portal.

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
void setup(){
  size(640, 640);
  background(255);
  fill(0);
  noStroke();
  smooth();
  noLoop();
}
 
void draw(){
  this.drawLogo();
}
 
void drawLogo(){
  final float RAD = 0.5 * width;
 
  //Inner radius.
  float r0 = 0.6 * RAD;
 
  //Outer radius.
  float r1 = 0.9 * RAD;
 
  //Octagon.
  final int NUM_VERTEX = 8;
 
  //Lateral angle for each shape.
  float dAngle = 2.0 * PI / (float)NUM_VERTEX;
 
  //Margin between shapes.
  float mAngle = 2.0 * PI / 180.0;
 
  final float CENTER_X = 0.5 * width;
  final float CENTER_Y = 0.5 * height;
 
  for (int i=0; i<NUM_VERTEX; i++){
    beginShape();
 
    //Add an inner vertex.
    float t0 = (i + 1) * dAngle;
    float x0 = CENTER_X + r0 * cos(t0);
    float y0 = CENTER_Y + r0 * sin(t0);
    vertex(x0, y0);
 
    //Add vertices for an arc.
    float t1 = (i - 0.5) * dAngle + mAngle;
    float t2 = (i + 0.5) * dAngle - mAngle;
    this.addVerticesForArc(CENTER_X, CENTER_Y, r1, t1, t2);
 
    endShape(CLOSE);
  }
}
 
//Add vertices for an arc. Must be used between beginShape() and endShape().
void addVerticesForArc(float centerX, float centerY, float rad, 
                                                     float startAngle, float endAngle){
  final int NUM_VERTEX = 100;
  float dt = (endAngle - startAngle) / (float)NUM_VERTEX;
 
  for (int i=0; i<NUM_VERTEX; i++){
    float x = centerX + rad * cos(startAngle + i * dt); 
    float y = centerY + rad * sin(startAngle + i * dt);
 
    //Add vertices.
    vertex(x, y);
  }
}
Read More