Skip to content

Commit

Permalink
Merge pull request #36 from brittni-and-the-polar-bear/22-create-basi…
Browse files Browse the repository at this point in the history
…c-color-classes

22 create basic color classes
  • Loading branch information
blwatkins authored Dec 30, 2023
2 parents 99fc804 + fd69eef commit 28a2303
Show file tree
Hide file tree
Showing 32 changed files with 978 additions and 31 deletions.
6 changes: 5 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
"@typescript-eslint/no-use-before-define": "error",

"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error"
"@typescript-eslint/no-useless-constructor": "error",

"@typescript-eslint/no-inferrable-types": "off",

"@typescript-eslint/class-literal-property-style": ["error", "getters"]
}
}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ package-lock.json

# generated files
out/
dist/
zip/

# jest
tests-coverage/

# WebStorm
.idea/
32 changes: 32 additions & 0 deletions examples/color/color-grid.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2023 Brittni Watkins.
*
* This file is a part of brittni and the polar bear's Generative Art Project Template,
* which is released under the GNU Affero General Public License, Version 3.0.
* You may not use this file except in compliance with the license.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. See LICENSE or go to
* https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*/

import { sketch } from "sketch";
import { Color } from "common";

sketch.draw = (): void => {
sketch.background(0, 255, 255);
sketch.rectMode(sketch.CENTER);

const colorA: Color = new Color(sketch, sketch.color(255));
sketch.fill(colorA.color);
sketch.rect(0, 0, 250, 250);

const colorB: Color = new Color(sketch);
sketch.fill(colorB.color);
sketch.rect(0, 0, 75, 75);
}
41 changes: 41 additions & 0 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023 Brittni Watkins.
*
* This file is a part of brittni and the polar bear's Generative Art Project Template,
* which is released under the GNU Affero General Public License, Version 3.0.
* You may not use this file except in compliance with the license.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. See LICENSE or go to
* https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Affero General Public License for more details.
*/

import type { JestConfigWithTsJest } from 'ts-jest';

const config: JestConfigWithTsJest = {
collectCoverage: true,
coverageDirectory: './out/tests-coverage',
coverageReporters: ['text', 'lcov'],
errorOnDeprecated: true,
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'mjs', 'cjs', 'json', 'node'],
moduleNameMapper: {
'^assets': '<rootDir>/assets',
'^color$': '<rootDir>/src/common/color',
'^color/factory$': '<rootDir>/src/common/color/factory',
'^p5-lib$': '<rootDir>/src/common/p5',
'^random$': '<rootDir>/src/common/random',
'^range$': '<rootDir>/src/common/range',
'^common$': '<rootDir>/src/common'
},
testEnvironment: 'jsdom',
testRegex: '/tests/.*\\.(test|spec)?\\.(ts|tsx)$',
transform: {'^.+\\.(ts|tsx)$': 'ts-jest'},
verbose: true
};

export default config;
23 changes: 18 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@
"name": "generative-art-project-template",
"version": "0.1.0",
"description": "A template for new brittni and the polar bear generative art projects using TypeScript with p5",
"main": "sketch.ts",
"main": "./src/sketch.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "rm -r out zip; rollup --config",
"dev": "rm -r out zip; rollup --config --watch"
"test:lint": "npx eslint ./tests",
"test:build:start": "echo '(1/3): Removing old output'; sh ./scripts/delete-out.sh; echo '(2/3): Building project'; rollup --config; echo '(3/3): Starting tests'; npx jest",
"test": "echo '(1/2): Removing old test-coverage output'; sh ./scripts/delete-tests-coverage.sh; echo '(2/2): Starting tests'; npx jest",

"build": "echo '(1/2): Removing old output'; sh ./scripts/delete-out.sh; echo '(2/2): Building project'; rollup --config",

"start": "echo '(1/2): Removing old output'; sh ./scripts/delete-out.sh; echo '(2/2): Building project and starting development server'; rollup --config --watch",

"example:color-grid:build": "sh ./scripts/color-grid.sh",
"example:color-grid:start": "sh ./scripts/color-grid.sh -d true"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -51,12 +58,18 @@
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.5",
"@types/jest": "^29.5.11",
"@typescript-eslint/eslint-plugin": "^6.16.0",
"@typescript-eslint/parser": "^6.16.0",
"canvas": "^2.11.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"rollup": "^4.9.1",
"rollup-plugin-analyzer": "^4.0.0",
"rollup-plugin-css-only": "^4.5.2",
"rollup-plugin-dev": "^2.0.4",
"rollup-plugin-zip": "^1.0.3"
"rollup-plugin-zip": "^1.0.3",
"ts-jest": "^29.1.1",
"ts-node": "^10.9.2"
}
}
16 changes: 8 additions & 8 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@
*/

import typescript from '@rollup/plugin-typescript';
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import eslint from '@rollup/plugin-eslint';
import terser from '@rollup/plugin-terser';
import css from 'rollup-plugin-css-only';
import html from '@rollup/plugin-html';
import analyzer from "rollup-plugin-analyzer";
import analyzer from 'rollup-plugin-analyzer';
import dev from 'rollup-plugin-dev';
import zip from 'rollup-plugin-zip';

import { readFileSync } from 'node:fs';

export default {
input: 'src/sketch.ts',
input: './src/sketch.ts',
output: {
dir: 'out',
dir: './out/dist',
format: 'umd',
name: 'GenerativeArtTemplate',
sourcemap: true,
Expand All @@ -44,7 +44,7 @@ export default {
extensions: ['.ts']
}),
eslint({
include: ['src/**/*.ts'],
include: ['./src/**/*.ts'],
throwOnError: true,
throwOnWarning: true
}),
Expand All @@ -61,12 +61,12 @@ export default {
summaryOnly: true
}),
dev({
dirs: ['out'],
dirs: ['./out/dist'],
host: '127.0.0.1',
spa: true
}),
zip({
dir: 'zip'
dir: './out/zip'
})
]
};
Expand Down
39 changes: 39 additions & 0 deletions scripts/color-grid.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (C) 2023 Brittni Watkins.
#
# This file is a part of brittni and the polar bear's Generative Art Project Template,
# which is released under the GNU Affero General Public License, Version 3.0.
# You may not use this file except in compliance with the license.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. See LICENSE or go to
# https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#

while getopts d: flag
do
case "${flag}" in
d) dev=${OPTARG};;
*) dev="false";;
esac
done

echo 'Starting the /examples/color/color-grid.ts example.';

echo '(1/2): Removing old output';

sh ./scripts/delete-out.sh

if [ "$dev" == "true" ]
then
echo '(2/2): Building project and starting development server';
rollup --config --input ./examples/color/color-grid.ts --watch;
else
echo '(2/2): Building project';
rollup --config --input ./examples/color/color-grid.ts;
fi
20 changes: 20 additions & 0 deletions scripts/delete-dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2023 Brittni Watkins.
#
# This file is a part of brittni and the polar bear's Generative Art Project Template,
# which is released under the GNU Affero General Public License, Version 3.0.
# You may not use this file except in compliance with the license.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. See LICENSE or go to
# https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#

echo 'Removing /out/dist';

rm -r ./out/dist;
27 changes: 27 additions & 0 deletions scripts/delete-out.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright (C) 2023 Brittni Watkins.
#
# This file is a part of brittni and the polar bear's Generative Art Project Template,
# which is released under the GNU Affero General Public License, Version 3.0.
# You may not use this file except in compliance with the license.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. See LICENSE or go to
# https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#


echo 'Removing all output files.'

sh ./scripts/delete-dist.sh;
sh ./scripts/delete-zip.sh;
sh ./scripts/delete-tests-coverage.sh;

echo 'Removing /out';

rm -r ./out;
20 changes: 20 additions & 0 deletions scripts/delete-tests-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2023 Brittni Watkins.
#
# This file is a part of brittni and the polar bear's Generative Art Project Template,
# which is released under the GNU Affero General Public License, Version 3.0.
# You may not use this file except in compliance with the license.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. See LICENSE or go to
# https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#

echo 'Removing /out/tests-coverage';

rm -r ./out/tests-coverage;
20 changes: 20 additions & 0 deletions scripts/delete-zip.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#
# Copyright (C) 2023 Brittni Watkins.
#
# This file is a part of brittni and the polar bear's Generative Art Project Template,
# which is released under the GNU Affero General Public License, Version 3.0.
# You may not use this file except in compliance with the license.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. See LICENSE or go to
# https://www.gnu.org/licenses/agpl-3.0.en.html for full license details.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU Affero General Public License for more details.
#

echo 'Removing /out/zip';

rm -r ./out/zip;
Loading

0 comments on commit 28a2303

Please sign in to comment.