Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .glitch-assets
Empty file.
91 changes: 33 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,36 @@
Assignment 4 - Creative Coding: Interactive Multimedia Experiences
===

Due: October 4th, by 11:59 AM.

For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser.

[WebAudio / Canvas / Three Tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/webaudio_canvas_three.md)
[SVG + D3 tutorial](https://github.com/cs4241-21a/cs4241-21a.github.io/blob/main/using_svg_and_d3.md)

Baseline Requirements
---

Your application is required to implement the following functionalities:

- A server created using Express. This server can be as simple as needed.
- A client-side interactive experience using at least one of the following web technologies frameworks.
- [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences
- [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations
- [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers
- [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML.
- [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback.
- A user interface for interaction with your project, which must expose at least four parameters for user control. [tweakpane](https://cocopon.github.io/tweakpane/) is highly recommended for this, but you can also use regular HTML `<input>` tags (the `range` type is useful to create sliders). You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that both mouse and touch events will both be supported in your app.
- Your application should display basic documentation for the user interface when the application first loads.

The interactive experience should possess a reasonable level of complexity. Some examples:
### Three.js
- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents.
- A simple 3D game... you really want this to be a simple as possible or it will be outside the scope of this assignment.
- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization.
### Canvas
- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using <canvas>; we'll be checking to ensure that your implementation is not a copy of these.
- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience.
### Web Audio API
- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. If you want to use higher-level instruments instead of the raw WebAudio API sounds, consider trying the instruments provided by [Tone.js]() or [Gibber](https://github.com/charlieroberts/gibber.audio.lib).
### D3.js
- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements.
3. Test your project to make sure that when someone goes to your main page on Glitch/Heroku/etc., it displays correctly.
4. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it.
5. Fork this repository and modify the README to the specifications below. *NOTE: If you don't use Glitch for hosting (where we can see the files) then you must include all project files that you author in your repo for this assignment*.
6. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your hosting link e.g. http://a4-charlieroberts.glitch.me

Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include:

- the goal of the application
- challenges you faced in realizing the application
- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here.
## DoodleBoard

https://a4-bryan-lima.glitch.me/

# Goal
This website is a simple stress relieving drawing application. Users can draw whatever their heart desires with some options for customization to the tools.

# Accomplishments
- Created a simple Express server
- Utilized the Canvas framework
- User Interaction:
- The option to pick between eight different colors
- Increase/decrease brush size
- The option to use the round, square, or butt brush
- The ability to clear the entire drawing
- Includes basic instructions on the homepage and showcases controls on the canvas page


# Challenges
I struggled with the implementation of tweakpane. As an alternative, I thought it would be cool to utilize event listeners for things such as mouse and key clicks.
This way, a user can have a variety of different controls to change the parameters of their brush.

I also had some trouble with Glitch throughout my work on this project such as trouble with CSS styling, the server displaying the correct page, and using Canvas, but I was able to get past these challenges with the help of office hours.

# Instructions

Click & Drag: Doodle!
Up Arrow: Increase Brush Size
Down Arrow: Decrease Brush Size
X: Clear Drawing
B: Butt Brush
R: Round Brush
S: Square Brush
52 changes: 52 additions & 0 deletions canvas.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="/canvas.js"></script>
<script type="text/javascript" src="/controller.js"></script>
<link type="text/css" rel="stylesheet" href="/style.css" />

<title>DoodleBoard</title>

<meta charset="utf-8" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
type="text/css"
href="https://fonts.googleapis.com/css2?family=Azeret+Mono:wght@300&display=swap"
rel="stylesheet"
/>
</head>
<body id="indexbody">

<div id="instructions">
<ul>
Controls:
<li>Click & Drag: Doodle!</li>
<li>Up Arrow: Increase Brush Size</li>
<li>Down Arrow: Decrease Brush Size</li>
<li>X: Clear Drawing</li>
<li>B: Butt Brush</li>
<li>R: Round Brush</li>
<li>S: Square Brush</li>
</ul></div>

<div id="toolbar">
<div id="toolbar-content">
<label id="colors">Color Picker:</label>
<input type="button" id="red" class="color" value="Red" />
<input type="button" id="blue" class="color" value="Blue" />
<input type="button" id="yellow" class="color" value="Yellow" />
<input type="button" id="green" class="color" value="Green" />
<input type="button" id="black" class="color" value="Black" />
<input type="button" id="white" class="color" value="White" />
<input type="button" id="pink" class="color" value="Pink" />
<input type="button" id="purple" class="color" value="Purple" />
<input type="button" id="clear" value="Clear Drawing" />
</div>
</div>

<div id="canvasDiv">
<canvas tabindex="0" id="canvas"></canvas>
</div>
</body>
</html>
118 changes: 118 additions & 0 deletions canvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
window.addEventListener("load", () => {
const canvas = document.querySelector("canvas"),
c = canvas.getContext("2d"),
doodleBtn = document.getElementById("doodle"),
redBtn = document.getElementById("red"),
blueBtn = document.getElementById("blue"),
yellowBtn = document.getElementById("yellow"),
greenBtn = document.getElementById("green"),
blackBtn = document.getElementById("black"),
whiteBtn = document.getElementById("white"),
pinkBtn = document.getElementById("pink"),
purpleBtn = document.getElementById("purple"),
clearBtn = document.getElementById("clear"),
popup = document.getElementById("popup"),
welcomeScreen = document.getElementById("welcomeScreen");

canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
c.lineCap = "round";
c.lineWidth = 10;

let isPainting = false;

function startPosition(e) {
isPainting = true;
doodle(e);
}

function endPosition() {
isPainting = false;
c.beginPath();
}

function checkKey(e) {
e = e || window.event;

//Up Arrow
if (e.keyCode == "38") {
c.lineWidth += 1;
}

//Down Arrow
else if (e.keyCode == "40") {
c.lineWidth -= 1;
}

//X Key
else if (e.keyCode == "88") {
c.clearRect(0, 0, canvas.width, canvas.height);
}

//R Key
else if (e.keyCode == "82") {
c.lineCap = "round";
}

//B Key
else if (e.keyCode == "66") {
c.lineCap = "butt";
}

//S Key
else if (e.keyCode == "83") {
c.lineCap = "square";
}
}

function doodle(e) {
if (!isPainting) return;

c.lineTo(e.clientX, e.clientY);
c.stroke();
c.beginPath();
c.moveTo(e.clientX, e.clientY);
}

redBtn.addEventListener("click", function() {
c.strokeStyle = "red";
});

blueBtn.addEventListener("click", function() {
c.strokeStyle = "blue";
});

yellowBtn.addEventListener("click", function() {
c.strokeStyle = "yellow";
});

greenBtn.addEventListener("click", function() {
c.strokeStyle = "green";
});

blackBtn.addEventListener("click", function() {
c.strokeStyle = "black";
});

whiteBtn.addEventListener("click", function() {
c.strokeStyle = "white";
});

pinkBtn.addEventListener("click", function() {
c.strokeStyle = "pink";
});

purpleBtn.addEventListener("click", function() {
c.strokeStyle = "purple";
});

clearBtn.addEventListener("click", function() {
c.clearRect(0, 0, canvas.width, canvas.height);
});

window.addEventListener("keydown", checkKey);

canvas.addEventListener("mousedown", startPosition);
canvas.addEventListener("mouseup", endPosition);
canvas.addEventListener("mousemove", doodle);
});
126 changes: 126 additions & 0 deletions home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="/home.js"></script>
<title>DoodleBoard</title>

<meta charset="utf-8" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
type="text/css"
href="https://fonts.googleapis.com/css2?family=Azeret+Mono:wght@300&display=swap"
rel="stylesheet"
/>
<style>
h1 {
font-family: "Azeret Mono", monospace;
background-image: linear-gradient(
to left,
violet,
indigo,
blue,
green,
yellow,
orange,
red
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
font-weight: bold;
border: 5px solid #000;
border-radius: 25px;
}

.demo-wrap {
background: white;
}

h2 {
font-family: "Azeret Mono", monospace;
text-align: center;
}

body {
font-family: "Azeret Mono", monospace;
background-image: url("https://www.ft.com/__origami/service/image/v2/images/raw/https%3A%2F%2Fd1e00ek4ebabms.cloudfront.net%2Fproduction%2F86215940-4642-4ac3-952e-0c81a0f637a0.jpg?fit=scale-down&source=next&width=700");
background-repeat: no-repeat;
background-size: cover;
height: 100%;
opacity: 0.95;
}

p {
font-family: "Azeret Mono", monospace;
font-size: 24px;
}

#popup {
font-family: "Azeret Mono", monospace;
display: block;
width: 555px;
height: 375px;
background: #FFFFFF;
border: 5px solid #000;
border-radius: 25px;
position: relative;
top: 150px;
left: 375px;
text-align: center;
}

#welcomeScreen {
font-family: "Azeret Mono", monospace;
display: block;
}

#doodleBtn {
background-image: linear-gradient(
to left,
violet,
indigo,
blue,
green,
yellow,
orange,
red
);
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
margin: 4px 2px;
font-weight: bold;
border: 5px solid #000;
border-radius: 25px;
cursor: pointer;
}

</style>
</head>
<body id="homebody">
<div class="demo-wrap">
<div class="demo-content">
<h1 class="rainbow-text">DoodleBoard</h1>
</div>
</div>

<div id="popup">
<div id="welcomeScreen">
<h2>Instructions</h2>
<p>
Once you hit the Doodle button, feel free to draw whatever you desire!
</p>
<button id="doodleBtn" onclick="window.location.href='canvas.html'">
Doodle!
</button>
<p>
Just left click, drag your mouse, and put together a masterpiece!
</p>
</div>
</div>
</body>
</html>
Loading