Skip to content

Commit 5dcf239

Browse files
authored
Integrate color function from CP3108 project (#338)
Source: https://github.com/adamwth/cp3108-rune-migration
1 parent 8b8d9ef commit 5dcf239

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

public/externalLibs/graphics/webGLrune.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,27 @@ function hexToColor(hex) {
563563
];
564564
}
565565

566+
/**
567+
* Function to add color to shape by specifying the red, green, blue value.
568+
* Opacity is kept at default value of 1. (Full opacity)
569+
* @param {*} shape The shape to add color to.
570+
* @param {*} r The red value.
571+
* @param {*} g The green value.
572+
* @param {*} b The blue value.
573+
*/
574+
function color(shape, r, g, b) {
575+
var wrapper = new Shape();
576+
wrapper.addS(shape);
577+
var color = [
578+
r,
579+
g,
580+
b,
581+
1
582+
]
583+
wrapper.setColor(color);
584+
return wrapper;
585+
}
586+
566587
function addColorFromHex(shape, hex) {
567588
var wrapper = new Shape();
568589
wrapper.addS(shape);

src/reducers/externalLibraries.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ExternalLibraryName, ExternalLibraryNames } from '../components/assessm
55
*/
66
const TwoDRunesExternals = [
77
'show',
8+
'color',
89
'random_color',
910
'red',
1011
'pink',

0 commit comments

Comments
 (0)