Skip to content

a4-nelson-diaz #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
package-lock.json
64 changes: 13 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,23 @@
Assignment 4 - Creative Coding: Interactive Multimedia Experiences
===

Due: October 2nd, by 11:59 AM.
Nelson Diaz

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.
Link to Project: http://a4-nelson-diaz.glitch.me

[WebAudio / Canvas Tutorial](https://github.com/cs-4241-2023/cs4241-2023.github.io/blob/main/using.webaudio_and_canvas.md)
[SVG + D3 tutorial](https://github.com/cs-4241-2023/cs-4241-2023.github.io/blob/main/using.svg_and_d3.md)
# Conway's Game of Life

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.


## Summary
This application is an interactive implementation on Conway's Game of Life. It is implemented using the Canvas API, Pointer Events API, and Tweakpane. A user is able to interact with the game by Starting/Pausing the simulation, changing the speed of the simulation, changing the rules for cell survival on the grid, changing the rules for cell generation on the grid, creating/removing cells at will by clicking & dragging, and more. The instructions for how to use the application are displayed on the right side of the screen when first navigating to the website. Challenges for this project included implementing click/drag functionality as well has using the [tweakpane-infodump](https://github.com/doersino/tweakpane-plugin-infodump) plugin to add the 'Information' tab.

### Infodump plugin difficulty
When searching for how to add plain text into tweakpane, I came across this plugin that would allow me to do exactly what I wanted. The only problem was that the plugin was out of date compared to the most recent version of tweakpane. To resolve this issue I needed to step through the tweakpane execution with the debugger to see where it was failing so that I could resolve the issue. Eventually, I discovered that the only thing I needed to get the plugin in load was to add a variable specifying what version it was valid for. However, after I got the plugin loaded, I also needed to put the css that should have been loaded with the plugin into it's own CSS file named "tweakpane-plugin-infodump.css". This resolved the issue of the plugin's visual components not being rendered with CSS.

### Click & Drag difficulty
When implementing click and drag I ran into a bug caused by the user clicking withing the canvas, dragging the cursor outside the canvas, and then releasing outside the canvas. This caused the cursor to paint cells when hovering over the canvas grid even without clicking. To remedy this I use the [MouseEvent.buttons](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons) property to check and see if the user is currently pressing a button while draggin over the canvas and only painting the grid if so.
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "a4-nelson-diaz",
"version": "",
"description": "",
"author": "",
"scripts": {
"start": "node server.improved.js"
},
"dependencies": {
"express": "^4.16.4"
},
"engines": {
"node": "16.x"
}
}
42 changes: 42 additions & 0 deletions public/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
body {
min-height: 100vh;
margin: 0;
padding: 1em;
display: flex;
align-items: center;
overflow-y: auto;
box-sizing: border-box;
}

main {
width: 100vw;
display: flex;
flex-flow: row;
align-items: flex-start;
justify-content: space-evenly;
}

canvas {
background-color: black;
border: 1px solid black;
}

#canvasDiv {
padding: 0 1em;
}

#optionsDiv {
margin: 0 auto;

padding: 0 1em;
box-sizing: border-box;
}

#optionsDiv > * {
min-width: 333px;
}

.tp-rotv {
/*font-size: 13px !important;*/
font-size: smaller !important;
}
91 changes: 91 additions & 0 deletions public/css/tweakpane-plugin-infodump.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/**
* All css in this file was taken from the tweakpane-plugin-infodump-0.3.0.js file.
* I don't know why it wasn't being applied automatically, but I have already spent
* long enough getting the plugin to work in the first place and this gets the job done.
* Source: https://github.com/doersino/tweakpane-plugin-infodump
*/
.tp-induv {
position: relative;
align-items: center;
display: flex;
line-height: 1.3;
padding-left: var(--cnt-h-p);
padding-right: var(--cnt-h-p)
}

.tp-induv.tp-v-disabled {
opacity: .5
}

.tp-induv .tp-induv_t {
color: var(--lbl-fg);
flex: 1;
-webkit-hyphens: auto;
hyphens: auto;
padding: 2px 4px 2px;
width: 1px
}

.tp-induv .tp-induv_t>*:first-child {
margin-top: 0
}

.tp-induv .tp-induv_t>*:last-child {
margin-bottom: 0
}

.tp-induv .tp-induv_t p,
.tp-induv .tp-induv_t h1,
.tp-induv .tp-induv_t h2,
.tp-induv .tp-induv_t h3,
.tp-induv .tp-induv_t ol,
.tp-induv .tp-induv_t ul,
.tp-induv .tp-induv_t blockquote,
.tp-induv .tp-induv_t pre {
margin: .5em 0
}

.tp-induv .tp-induv_t a {
color: var(--btn-bg)
}

.tp-induv .tp-induv_t a:active {
color: var(--btn-bg-a)
}

.tp-induv .tp-induv_t a:hover {
color: var(--btn-bg-h)
}

.tp-induv .tp-induv_t h1 {
font-size: 1.3em;
font-weight: bold
}

.tp-induv .tp-induv_t h2 {
font-size: 1em;
font-weight: bold
}

.tp-induv .tp-induv_t h3 {
font-size: 1em;
font-weight: normal
}

.tp-induv .tp-induv_t ol,
.tp-induv .tp-induv_t ul,
.tp-induv .tp-induv_t blockquote {
padding-left: 28px
}

.tp-indubv::before {
border: var(--mo-fg) dashed 1px;
border-radius: var(--elm-br);
bottom: 0;
content: "";
left: var(--cnt-v-p);
opacity: .3;
position: absolute;
right: var(--cnt-v-p);
top: 0
}
28 changes: 28 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>CS4241 Assignment 4</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Author: Nelson Diaz, Assignment: a4-creative-coding,
Class: CS4241 Webware, Instructor: Charlie Roberts, Summary: An interactive implementation of Conway's Game of Life">

<link rel="stylesheet" href="/css/tweakpane-plugin-infodump.css">
<link rel="stylesheet" href="/css/custom.css">

<script type="module" src="/js/tweakpane-plugin-infodump-0.3.0.js"></script>
<script type="module" src="/js/main.js"></script>

<!-- get rid of favicon error -->
<link rel="icon" href="data:;base64,iVBORw0KGgo=">
</head>

<body>
<main>
<div id="canvasDiv">
<canvas id="myCanvas" width="800" height="450"></canvas>
</div>
<div id="optionsDiv"></div> <!-- Holds tweakpane Pane object -->
</main>
</body>
</html>
Loading