xxxxxxxxxx
277
var stamp = [];
var citynames = [];
var palette = [];
var textpos = [];
let mg;
let timeOffset = 0;
let yIncrement = 0.09; //0.05 default
let filter;
var grad;
var layoutMode = 0;
var font = [];
let bg = "#E9DCCC"; //change bg color #E9DCCC before: "#1f2325"
var ns = 2;
var price = ["10", "20", "30", "40", "50", "60", "70", "80", "90"];
function preload() {
stamp[0] = [300, 300]; //sq
stamp[1] = [432, 300]; //landscape
stamp[2] = [300, 432]; //portrait
font[0] = loadFont("fonts/ANTIQUE.ttf");
font[1] = loadFont("fonts/AQBL.ttf");
font[2] = loadFont("fonts/AQCT.ttf");
font[3] = loadFont("fonts/AQL.ttf");
font[4] = loadFont("fonts/Amsterdamer-Garamont Italic.ttf");
font[5] = loadFont("fonts/Antique Olive Italic.ttf");
font[6] = loadFont("fonts/Antique Olive Regular.ttf");
font[7] = loadFont("fonts/AntiqueOlive.ttf");
font[8] = loadFont("fonts/OLVR55W.TTF");
font[9] = loadFont("fonts/OLVR56W.TTF");
font[10] = loadFont("fonts/Trim Web Regular.ttf");
font[11] = loadFont("fonts/AQCT.ttf");
}
function setup() {
createCanvas(500, 500);
palette = random(colorpalette);
ns = floor(random(0, 3));
filter = new makeFilter();
noLoop();
}
function draw() {
background(bg);
noStroke();
fill(255);
rectMode(CENTER);
rect(width / 2, height / 2, stamp[ns][0], stamp[ns][1]);
let circlesize = 20;
let stampheight = stamp[ns][1]; //how to define it in
let stampwidth = stamp[ns][0];
let offset = 5;
for (let row = 0; row < stampheight / (circlesize + offset); row++) {
push();
translate(width / 2 - stampwidth / 2, height / 2 - stampheight / 2);
fill(bg);
ellipse(0, row * (circlesize + offset), circlesize, circlesize);
ellipse(stampwidth, row * (circlesize + offset), circlesize, circlesize);
pop();
}
for (let column = 0; column < stampwidth / (circlesize + offset); column++) {
push();
translate(
width / 2 - (stampwidth + offset) / 2,
height / 2 - stampheight / 2
);
fill(bg);
ellipse(column * (circlesize + offset), 0, circlesize, circlesize);
ellipse(
column * (circlesize + offset),
stampheight,
circlesize,
circlesize
);
pop();
}
noStroke();
fill(palette);
rect(width / 2, height / 2, stampwidth - 25, stampheight - 25);
let leftX = width / 2 - stampwidth / 2 + 20;
let rightX = width / 2 + stampwidth / 2 - 20;
let topY = height / 2 - stampheight / 2 + 50;
let bottomY = height / 2 + (stampheight - 25) / 2 - 10;
var textX = [leftX, rightX];
var textY = [topY, bottomY];
var tx;
var ty;
var px;
var py;
var fx;
var fy;
var r = random(0, 1);
let currentPrice = random(price);
mg = createGraphics(stampwidth, stampheight);
grad = drawingContext.createLinearGradient(0, 100, 0, stamp[ns][1]); //height
grad.addColorStop(0, "white"); //#E9DCCC -- which looks better?
grad.addColorStop(1, palette);
mg.drawingContext.fillStyle = grad;
mg.noStroke();
mg.beginShape();
let yOffset = 0;
for (let x = 0; x <= width; x += 10) {
let y = noise(yOffset, timeOffset) * 400;
mg.vertex(x, y);
yOffset += yIncrement;
}
mg.vertex(width, height);
mg.vertex(0, height);
mg.endShape(CLOSE);
mg.push();
mg.scale(random(0.5, 1));
let n = floor(random(8, 12));
let p = floor(random(20, 50));
let rtextX = random(textX);
let rtextY = random(textY);
// console.log(rtextY);
flower(mg, rtextX, rtextY, n, p);
rtextX = random(textX);
rtextY = random(textY);
flower(mg, rtextX, rtextY + 50, n, p);
flower(mg, rtextX + 60, rtextY, n, p);
rtextX = random(textX);
rtextY = random(textY);
flower(mg, rtextX, rtextY, n, p);
mg.pop();
imageMode(CENTER);
image(mg, width / 2, height / 2, stampwidth - 25, stampheight - 25);
image(
overAllTexture,
width / 2,
height / 2,
stampwidth - 25,
stampheight - 25
);
if (r > 0.5) {
layoutMode = 0;
tx = textX[0];
px = textX[1];
} else {
layoutMode = 1;
tx = textX[1]; //right
px = textX[0]; //left
}
r = random(0, 1);
if (r > 0.5) {
ty = textY[0];
py = textY[1];
} else {
ty = textY[1]; //bottomY
py = textY[0] + 15; //topY, ratio of the text size, map
}
let currentTown = random(UStowns);
if (currentTown.indexOf("\n") >= 0) {
ty = height / 2 + (stampheight - 25) / 2 - 50;
}
if (layoutMode == 0) {
textAlign(LEFT);
} else {
textAlign(RIGHT);
}
fill(255);
textFont(random(font));
textSize(32);
text(currentTown, tx, ty);
if (layoutMode == 0) {
textAlign(RIGHT);
} else {
textAlign(LEFT);
}
noFill();
stroke(255);
strokeWeight(1);
textSize(60);
text(currentPrice, px, py);
fill(255);
textFont(font[4]);
textAlign(LEFT);
textSize(20);
textFont(font[4]);
text('made by Anel Alpysbayeva', 324, 492);
}
function flower(mg, x, y, numPetals, petalsize) {
noStroke();
grad = drawingContext.createLinearGradient(0, 100, 0, 5); //height
grad.addColorStop(0, "white"); //#E9DCCC -- which looks better?
grad.addColorStop(1, palette);
mg.drawingContext.fillStyle = grad;
mg.push();
mg.translate(x, y);
for (let m = 0; m < numPetals; m++) {
mg.ellipse(0, 30, petalsize, 80);
mg.rotate(TWO_PI / numPetals);
}
sun = ["orange", "gold", "coral"];
flin = random(sun);
mg.fill(flin);
mg.ellipse(0, 0, 3 * numPetals, 3 * numPetals);
mg.pop();
}
function makeFilter() {
colorMode(HSB, 360, 100, 100, 100);
drawingContext.shadowColor = color(74, 68, 211, 95);
overAllTexture = createGraphics(stamp[ns][0], stamp[ns][1]);
overAllTexture.loadPixels();
for (var i = 0; i < width; i++) {
for (var j = 0; j < height; j++) {
overAllTexture.set(
i,
j,
color(0, 0, 0, noise(i / 3, j / 3, (i * j) / 50) * random(5, 15))
);
}
}
overAllTexture.updatePixels();
}
function keyPressed() {
if (key == "s") {
save("sentfrom.png");
}
}
function mousePressed() {
palette = random(colorpalette);
ns = floor(random(0, 3));
redraw();
}
// ella bandouveris
// anel alpysbayeva
//add flowers in one corner, price in one corner, clouds at the top