{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# CS Education Week\n",
"## The Baldwin School and TechGirlz\n",
"\n",
"**Instructor**: Professor Doug Blank, dblank@cs.brynmawr.edu\n",
"\n",
"**This URL**: https://athena.brynmawr.edu/jupyter/hub/dblank/public/CSEdWeek2015/Schedule.ipynb\n",
"\n",
"**Goals**: Create drawings, animations, and games using Java with Processing.\n",
"\n",
"**Survey**: http://www.goo.gl/gJw9WY\n",
"\n",
"**Internet**: \n",
"\n",
"* Wireless: **Baldwin_Guest**\n",
"* Username: **baldwin**\n",
"* Password: **thinkinggirls**\n",
"\n",
"\n",
"Time | Activity \n",
"----- | --------\n",
"1pm | Welcome!\n",
"1:15 - 1:30 | Graph Paper Drawing; 0,0 is upper left hand corner, 500 x 500\n",
"1:30 - 2:00 | Computing with Jupyter! Put graph paper drawing on sketch\n",
"2:00 - 2:30 | Adding a character to the scene: graph-paper-it with 0,0 in center\n",
"2:30 - 2:45 | Break\n",
"2:45 - 3:45 | Animation and Games; functions, mouse, distance\n",
"3:45 | End of TechShop\n",
"\n",
"
\n",
"\n",
"**Shape Functions**:\n",
"\n",
"* `ellipse(x, y, width, height);` - x,y is center\n",
"* `line(x1, y1, x2, y2);` \n",
"* `rect(x, y, width, height);` - x,y is upper left hand corner\n",
"* `triangle(x1, y1, x2, y2, x3, y3);`\n",
"* `quad(x1, y1, x2, y2, x3, y3, x4, y4);`\n",
"* `arc(x, y, width, height, start, stop);` - x,y is center\n",
"\n",
"**Line thickness**:\n",
"\n",
"* `strokeWidth(SIZE);`\n",
"\n",
"**Color**:\n",
"\n",
"* `color(RED, GREEN, BLUE);` - values are 0 to 255\n",
"* `stroke(COLOR);` - change the line color\n",
"* `fill(COLOR);` - change the fill color\n",
"\n",
"**Code**:\n",
"\n",
"* all lowercase\n",
"* all lines end with a semicolon\n",
"* don't forget commas and parentheses\n",
"* double quotes are different from single quotes\n",
"\n",
"**Processing Reference**:\n",
"\n",
"* http://processingjs.org/reference/\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Additional Functions\n",
"\n",
"* background(COLOR);\n",
"* size(WIDTH, HEIGHT);\n",
"\n",
"```java\n",
"void setup() {\n",
" // This is where one-time setup code goes\n",
"}\n",
"\n",
"void draw() {\n",
" // this is where code that is redrawn over and over goes\n",
"}\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Mouse \n",
"\n",
"* mouseX, mouseY - where the mouse is\n",
"* mousePressed - function to handle the mouse pressing"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Distance\n",
"\n",
"The distance between x1, y1 to x2, y2 is: the square root of the sum of the differences squared of each dimension.\n",
"\n",
"* Difference: x1 - x2 \n",
"* Square: pow(x1 - x2, 2)\n",
"* Square root: sqrt()\n",
"\n",
"```java\n",
"float distance(int x1, int y1, int x2, int y2) {\n",
" return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));\n",
"}\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Review\n",
"\n",
"1. Draw background on graph paper, 0,0 in upper lefthand corner\n",
"1. Convert to Java\n",
"1. Convert to a function, drawBackground()\n",
"1. Add a setup() and draw(); drawBackground in setup or draw\n",
"1. Draw character on graph paper, 0,0 in center\n",
"1. Create a function, add x to all x values; add y to all y values\n",
"1. void drawMouse(int x, int y)\n",
"1. Use distance(x1, y1, x2, y2) to find distance\n",
"1. Global variables to keep track of where character is"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false,
"format": "tab"
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"%%html\n",
""
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Calysto Processing",
"language": "java",
"name": "calysto_processing"
},
"language_info": {
"codemirror_mode": {
"name": "text/x-java",
"version": 2
},
"file_extension": ".java",
"mimetype": "text/x-java",
"name": "java"
}
},
"nbformat": 4,
"nbformat_minor": 0
}