This repository has been archived by the owner on Jan 6, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#22 Add two concrete color builder classes
- Update .eslintrc - Add import path mapping to tsconfig.json - Add parent class for classes dependent on p5 methods - Add directory level exports for all folders - Update imports in color.ts - Update exports for color-factory.ts - Update exports in range.ts - Update imports and exports in mapping-color-factory.ts and random-color-factory.ts - Add random methods - Create color factory for colors created from a range of RGB values - Create color factory for random black colors - Create color factory for random blue colors - Update sketch.ts
- Loading branch information
Showing
19 changed files
with
378 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,5 @@ interface ColorFactory { | |
get name(): string; | ||
} | ||
|
||
export { type ColorFactory }; | ||
export default ColorFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { type ColorFactory } from "./color-factory"; | ||
export { type RandomColorFactory } from "./random-color-factory"; | ||
export { type MappingColorFactory } from "./mapping-color-factory"; | ||
|
||
export * from "./rgb"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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 { P5Lib } from "p5-lib"; | ||
import { randomInt } from "random"; | ||
import { Color } from "color"; | ||
|
||
import RGBRangeFactory from "./rgb-range-factory"; | ||
|
||
class BlackColorFactory extends RGBRangeFactory { | ||
public constructor(p5: P5Lib) { | ||
super(p5, 'black color factory'); | ||
} | ||
|
||
public override getRandomColor(): Color { | ||
this.p5.colorMode(this.p5.RGB, 255); | ||
const gray: number = randomInt(0, 100); | ||
return new Color(this.p5, this.p5.color(gray)); | ||
} | ||
} | ||
|
||
export { BlackColorFactory }; | ||
export default BlackColorFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 { P5Lib } from "p5-lib"; | ||
import { Range } from "range"; | ||
|
||
import RGBRangeFactory from "./rgb-range-factory"; | ||
|
||
class BlueColorFactory extends RGBRangeFactory { | ||
public constructor(p5: P5Lib) { | ||
const redRange: Range = new Range(0, 100); | ||
const greenRange: Range = new Range(0, 100); | ||
const blueRange: Range = new Range(100, 255); | ||
super(p5, 'blue color factory', redRange, greenRange, blueRange); | ||
} | ||
} | ||
|
||
export { BlueColorFactory }; | ||
export default BlueColorFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
*/ | ||
|
||
export { RGBRangeFactory } from "./rgb-range-factory"; | ||
export { BlackColorFactory } from "./black-color-factory"; | ||
export { BlueColorFactory } from "./blue-color-factory"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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 { P5Dependant, P5Lib } from "p5-lib"; | ||
import { Color } from "color"; | ||
import { Range } from "range"; | ||
import { randomInt } from "random"; | ||
|
||
import RandomColorFactory from "../random-color-factory"; | ||
|
||
abstract class RGBRangeFactory extends P5Dependant implements RandomColorFactory { | ||
|
||
protected constructor(p5: P5Lib, _name: string); | ||
protected constructor(p5: P5Lib, | ||
_name: string, | ||
_redRange: Range, | ||
_greenRange: Range, | ||
_blueRange: Range); | ||
protected constructor(p5: P5Lib, | ||
private readonly _name: string, | ||
private readonly _redRange?: Range, | ||
private readonly _greenRange?: Range, | ||
private readonly _blueRange?: Range) { | ||
super(p5); | ||
} | ||
|
||
public get name(): string { | ||
return this._name; | ||
} | ||
|
||
public getRandomColor(): Color { | ||
this.p5.colorMode(this.p5.RGB, 255); | ||
let color: Color = new Color(this.p5); | ||
|
||
if (this.redRange && this.greenRange && this.blueRange) { | ||
const r: number = randomInt(this.redRange.low, this.redRange.high); | ||
const g: number = randomInt(this.greenRange.low, this.greenRange.high); | ||
const b: number = randomInt(this.blueRange.low, this.blueRange.high); | ||
color = new Color(this.p5, this.p5.color(r, g, b)); | ||
} | ||
|
||
return color; | ||
} | ||
|
||
private get redRange(): Range | undefined { | ||
return this._redRange; | ||
} | ||
|
||
private get greenRange(): Range | undefined { | ||
return this._greenRange; | ||
} | ||
|
||
private get blueRange(): Range | undefined { | ||
return this._blueRange; | ||
} | ||
} | ||
|
||
export { RGBRangeFactory }; | ||
export default RGBRangeFactory; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { Color } from "./color"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from "color"; | ||
export * from "color/factory"; | ||
export * from "p5-lib"; | ||
export * from "random"; | ||
export * from "range"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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 P5Lib from "p5"; | ||
|
||
export { P5Lib }; | ||
export * from "./p5-dependant"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* 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 P5Lib from "p5"; | ||
|
||
abstract class P5Dependant { | ||
protected constructor(private readonly _p5: P5Lib) { | ||
} | ||
|
||
protected get p5(): P5Lib { | ||
return this._p5; | ||
} | ||
} | ||
|
||
export { P5Dependant }; | ||
export default P5Dependant; |
Oops, something went wrong.