creating pattern for texture on sphere
in
Programming Questions
•
10 months ago
Hi, I would like to find out the best way to create a pattern out of a triangle shape I have created.
I would like to use this pattern as a texture on a sphere. Please can anyone advise me?
I've included the code for the pattern below:
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
PShape pattern, bulb;
// Setup Environment
size(600, 600, P2D);
pattern = createShape(GROUP);
background(0);
noStroke();
smooth();
// Setup Variables
int[][] colours = {
{255,255,255},
{255,255,255},
{255,207,133},
{253,198,95},
{252,252,132},
{243,241,244},
{246,204,86},
{250,196,106}
};
int dot_width = 18;
int x_pos = dot_width;
int y_pos = dot_width;
int row_length = 8;
int point_length = 8;
int point_offset = 0;
// Setup Dots Pattern
for (int row = 0; row < row_length; row++) {
for (int x = 0; x < point_length; x++) {
int offset = x_pos + point_offset;
bulb = createShape(
ELLIPSE,
offset,
y_pos,
dot_width,
dot_width
);
bulb.fill(
colours[row][0],
colours[row][1],
colours[row][2]
);
pattern.addChild(bulb);
x_pos += dot_width * 2;
}
x_pos = dot_width;
y_pos += 30;
point_length -= 1;
point_offset += dot_width;
}
beginShape(TRIANGLE_FAN);
shapeMode(CORNER);
shape(pattern);
endShape();
saveFrame("panel.png");
1