Skip to content

Instantly share code, notes, and snippets.

// A basic sketch of a class to parse and manage/hold color schemes
// from Adobe's Kuler (or any other list of hex value formatted colors)
// starting with a string of comma-separate hex color values
class Kuler
{
String colors = ""; // Put the sequence of comma-separated Kuler hex values here
String[] colorList;
int[] cList;
int numColors;
String toString(CircleShape circle)
{
StringBuffer buff = new StringBuffer();
Field[] fields = circle.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++)
{
//println("Field " + i + " is " + fields[i].getName());
}
@jafish
jafish / replaceForWithVar.js
Last active March 5, 2019 13:21
Replacing a for loop with a variable that is initialized to zero before the loop and updated within the loop
var y = 0;
//Column Two
for (i=63; i<128; i+=1){ //i variable stands for alpha value
//the loop adds one to the alpha value until it equals 176
//for (var y=0; y<=630; y+=10){ //y variable stands for the y coordinate of rectangle
//the loop adds 10 to the y coordinate until it equals 630
fill(255, 0, 0, i);
rect(30, y, 20, 5); //I added 30 to the x coordinate of the rectangle to
//add space between the columns
y+=10;
@jafish
jafish / Unit1Lab2UpdateWithVars.js
Last active March 5, 2019 13:37
An example showing how you can use a variable to accomplish what the interior for loop is doing without repeating the two drawing commands.
// Column 2. Draws 64 rectangles in descending order of transparency in a second column.
var y = 0;
for (i = 65; i < 128; i += 1) {
//for (y = 0; y <= 640; y += 10) {
fill(0, 255, 0, i += 1);
rect(50, y, 40, 5);
y += 10;
}
}
// Column 3. Draws 64 rectangles in descending order of transparency in a third column.
@jafish
jafish / gist:e5202439f6e8c324d05028059343362d
Last active November 13, 2021 20:48
macOS Shell Script to Cleanup Unity Project Folders
cd "$1"
find -E . -regex "./[Ll]ibrary|./[Tt]emp|./[Oo]bj|./[Bb]uilds*|./[Ll]ogs|./[Uu]ser[Ss]ettings|./\.vs.*|./.*.sln|./.*.csproj|./.*mono_crash.*|./.*.DS_Store" -prune -exec rm -rf "{}" \;
@jafish
jafish / main.tour
Created March 4, 2024 17:53
Creating Your Own Functions in p5.js
{
"$schema": "https://aka.ms/codetour-schema",
"title": "Custom Functions",
"steps": [
{
"file": "sketch.js",
"selection": {
"start": {
"line": 27,
"character": 1
@jafish
jafish / sketch.js
Created March 4, 2024 18:22
Creating a Coordinate System, the Unit Circle, and Your Own Functions in p5.js (all just to make a working clock face)
let angle = 0;
function setup() {
createCanvas(600, 600);
angleMode(DEGREES);
}
function draw() {
background(220);
// Add to my angle
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// 3rd-person movement that picks direction relative to target (usually the camera)
// commented lines demonstrate snap to direction and without ground raycast
//
// To setup animated character create an animation controller with states for idle, running, jumping
// transition between idle and running based on added Speed float, set those not atomic so that they can be overridden by...
// transition both idle and running to jump based on added Jumping boolean, transition back to idle
if (frameCount % 30 ===0){
index = index + 1
}else if (index >= windDir.length) {
index = 0
}
-- Name this file `main.lua`. Your game can use multiple source files if you wish
-- (use the `import "myFilename"` command), but the simplest games can be written
-- with just `main.lua`.
-- You'll want to import these in just about every project you'll work on.
import "CoreLibs/object"
import "CoreLibs/graphics"
import "CoreLibs/sprites"
import "CoreLibs/timer"