“Math Textbook Cover” by Dave Pagurek
https://openprocessing.org/sketch/1545745
License CreativeCommons Attribution NonCommercial ShareAlike
https://creativecommons.org/licenses/by-nc-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
CC Attribution NonCommercial ShareAlike
Math Textbook Cover
Pagurek
xxxxxxxxxx
// I didn't want to make an Unsplash API key and put it in a public sketch
// so instead I just went to Unsplash, manually searched for "bear", and
// copied some image ids into here lmao
const bearURLs = [
'https://images.unsplash.com/photo-1530595467537-0b5996c41f2d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80',
'https://images.unsplash.com/photo-1589656966895-2f33e7653819?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80',
'https://images.unsplash.com/photo-1599948058230-78896e742f7e?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2282&q=80',
'https://images.unsplash.com/photo-1588167056840-13caf6e4562a?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1365&q=80',
'https://images.unsplash.com/photo-1568162603664-fcd658421851?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2281&q=80',
'https://images.unsplash.com/photo-1551336841-32a98a5917eb?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1808&q=80',
'https://images.unsplash.com/photo-1595173425119-1c54835c1874?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80',
'https://images.unsplash.com/photo-1547146092-983100a60066?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80',
'https://images.unsplash.com/photo-1576076819613-26f8537ae375?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1335&q=80',
'https://images.unsplash.com/photo-1551792714-9a8b35338793?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2316&q=80',
'https://images.unsplash.com/photo-1573920111312-04f1b25c6b85?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=987&q=80',
'https://images.unsplash.com/photo-1559899551-4037d17859c0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80',
'https://images.unsplash.com/photo-1593946460607-d1570da6268f?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2340&q=80',
'https://images.unsplash.com/photo-1633122117096-d7aa3f93a1c8?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2196&q=80',
]
let bearImages
let font
function preload() {
bearImages = bearURLs.map((url) => loadImage(url.replace(/w=\d+/, 'w=600')))
font = loadFont('https://fonts.gstatic.com/s/akshar/v1/Yq6I-LyHWTfz9rGoqDaUbHvhkAUsSagC-9eS8KfpjPaaXg.woff')
}
function setup() {
createCanvas(400, 600)
frameRate(1/3)
}
function mousePressed() {
save('textbook.png')
}
function generateTitle() {
const rawTopic = () => random([
'Statistics',
'Calculus',
'Vectors',
'Functions',
'Trigonometry',
'Proofs',
])
const topic = () => {
if (random() < 0.4) {
const prefix = random([
'Advanced ',
'Pre-',
'Graduate-Level ',
'AP ',
])
return `${prefix}${rawTopic()}`
} else {
return rawTopic()
}
}
const modifiedTopic = () => random([
() => topic(),
() => `${topic()} with Pizzazz`,
() => `Extreme ${topic()}`,
() => `${topic()} ${round(random(1, 12))}`,
() => `${topic()} for Dummies`,
() => `${topic()} for Kids`,
() => `${topic()} for English Majors`,
() => `Baby's First ${topic()}`,
])()
const title = () => random([
() => modifiedTopic(),
() => modifiedTopic(),
() => modifiedTopic(),
() => modifiedTopic(),
() => `Learning ${modifiedTopic()}`,
() => `Experiencing ${modifiedTopic()}`,
() => `${modifiedTopic()} Like Your Life Depends On It`,
])()
return title()
}
function draw() {
push()
background('#333')
translate(width/2, height/2)
imageMode(CENTER)
const bear = random(bearImages)
push()
scale(max(width/bear.width, height/bear.height))
image(bear, 0, 0)
pop()
push()
rectMode(CENTER)
const gradient = drawingContext.createLinearGradient(0, -height/2, 0, height/2)
gradient.addColorStop(0, 'rgba(0,0,0,0.5)')
gradient.addColorStop(0.25, 'rgba(0,0,0,0)')
gradient.addColorStop(0.5, 'rgba(0,0,0,0)')
gradient.addColorStop(1, 'rgba(0,0,0,1)')
noStroke()
drawingContext.fillStyle = gradient
rect(0, 0, width, height)
pop()
const arms = random([2,3,4,5,6])
const subArms = random([1,1,2,2,3,4])
const loops = random([1,1,2])
const epicycles = [
{
r: (f) => sin(f*arms*TWO_PI) * 40 + 80,
k: () => loops,
},
{
r: (f) => sin(f*subArms*TWO_PI) * 20 + 60,
k: () => 40 * arms
},
]
const samples = 10000
push()
translate(random(-1, 1)*width*0.2, height * random(0.4, 0.6))
scale(random(1.5,2))
rotate(random(TWO_PI))
noFill()
strokeWeight(0.25)
stroke(255, 200)
blendMode(ADD)
beginShape()
for (let sample = 0; sample < samples; sample++) {
const frac = (sample / samples)
const t = frac * 2 * PI
let x = 0
let y = 0
for (const { r, k } of epicycles) {
x += r(frac) * cos(k(frac) * t)
y += r(frac) * sin(k(frac) * t)
}
vertex(x, y)
}
endShape()
pop()
push()
noStroke()
fill(255)
textSize(30)
textAlign(LEFT, TOP)
textFont(font)
text(generateTitle(), -width/2 + 20, -height/2 + 20, width * 0.6)
pop()
pop()
}
See More Shortcuts