xxxxxxxxxx
165
let klondyker;
let sea;
let scribble;
function setup() {
pixelDensity(1);
createCanvas(400, 400);
klondyker = new Riso('charcoal');
sea = new Riso('seablue');
risoNoStroke();
scribble = new Scribble();
}
function draw() {
background(255);
//background('#4C6C73');
//boat setup
boatWidth = random(width / 4, width / 2);
boatHeight = random(height * 0.04, height * 0.1);
//Is there a better way to get this value?
boatTop = height / 2 - boatHeight / 2 + 1;
chimney = random(20, 40);
wheelhouse = random(40, 90);
wheelhousePos = width / 2 - boatWidth / 2 + random(10, 40);
bowAngle = random(5, 20);
noStroke();
//cranes
klondyker.rectMode(CORNER);
klondyker.fill(255);
for (i = 0; i < random(4); i++) {
klondyker.rect(random(width / 2 - boatWidth / 2 + 4, width / 2 + boatWidth / 2 - 4), height / 2 - boatHeight / 2, 4, random(-10, -70));
}
// Chinmey
// Add 'branding' personalisation random
klondyker.rectMode(CORNER);
klondyker.fill(80);
chimneyPinW = width / 2 + boatWidth / 2 - 10;
chimneyPinH = height / 2 - boatHeight / 2;
klondyker.quad(
chimneyPinW,
chimneyPinH,
chimneyPinW - chimney,
chimneyPinH,
chimneyPinW - chimney * random(0.8, 1),
chimneyPinH - chimney,
chimneyPinW - random(0, 2),
chimneyPinH - chimney
);
//Wheel house
// TO DO optional 2 storys
// Dark roof/ Cap on top?
klondyker.rectMode(CORNER);
klondyker.fill(80);
//Bottom section
klondyker.rect(wheelhousePos, boatTop, wheelhouse, -wheelhouse * 0.25);
//First floor
klondyker.rect(wheelhousePos, boatTop - wheelhouse * 0.25, wheelhouse * 0.75, -wheelhouse * 0.15);
// Wheelhouse portholes
klondyker.fill(255);
for (i = 10; i < wheelhouse * 0.65; i = i + 10) {
klondyker.circle(wheelhousePos + i, 200 - boatHeight / 2 - wheelhouse * 0.25, 5);
}
// Hull
klondyker.rectMode(CENTER);
klondyker.fill(255);
//rust - needs work
blendMode(HARD_LIGHT);
strokeWeight(1);
// Need to draw scribbles to a new canvas and add as Riso image
scribble.roughness = 2;
stroke(240, 60, 40,160);
scribble.scribbleFilling([
width / 2 - boatWidth / 2 + bowAngle / 2, width / 2 + boatWidth / 2,
width / 2 + boatWidth / 2, width / 2 - boatWidth / 2 + bowAngle
],
[height / 2 + boatHeight * random(0.1, 0.2), height / 2 + boatHeight * random(.1, .2),
height / 2 + boatHeight / 2, height / 2 + boatHeight / 2
],
1, random(0, 360));
blendMode(BLEND);
//sea
strokeWeight(4);
stroke('#4C6C73');
// Need to draw scribbles to a new canvas and add as Riso image
scribble.roughness = 4;
//scribble.scribbleLine(width / 2 - boatWidth / 2, height / 2 + boatHeight / 2, width / 2 + boatWidth / 2, height / 2 + boatHeight / 2);
sea.strokeWeight(4);
sea.stroke('#4C6C73');
sea.line(width / 2 - boatWidth / 2, height / 2 + boatHeight / 2, width / 2 + boatWidth / 2, height / 2 + boatHeight / 2);
noStroke();
klondyker.quad(
width / 2 - boatWidth / 2,
height / 2 - boatHeight / 2,
width / 2 + boatWidth / 2,
height / 2 - boatHeight / 2,
width / 2 + boatWidth / 2,
height / 2 + boatHeight / 2,
width / 2 - boatWidth / 2 + bowAngle,
height / 2 + boatHeight / 2
);
// Hull Stepped sides
klondyker.rectMode(CORNER);
klondyker.rect(width / 2 - boatWidth / 2, boatTop, random(30, boatWidth / 2), random(-15), 0, 0, 2, 0);
// boat name - array in russianWords.js
let textGraphic = createGraphics(width, height);
textGraphic.textAlign(LEFT);
textGraphic.fill(0);
textGraphic.textSize(8);
textGraphic.text(boatNames[Math.floor(random(boatNames.length))], 200 - boatWidth / 2 + 13, boatTop + 10);
klondyker.cutout(textGraphic);
// Instruction text
textAlign(CENTER);
fill(200);
textSize(16);
text('click to generate klondyker', width / 2, height - 40);
text('hit space to download seperation', width / 2, height - 20);
drawRiso();
noLoop();
}
function mouseClicked() {
clearRiso();
redraw();
}
function keyPressed() {
if (keyCode === 32) {
//exportRiso();
} else if (keyCode === DOWN_ARROW) {
clearRiso();
redraw();
}
return false; // prevent default
}
// function touchStarted() {
// clearRiso();
// redraw();
// return false; // prevent default
// }