Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions examples/common/Component.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type {
INode,
INodeWritableProps,
Expand Down
19 changes: 19 additions & 0 deletions examples/common/ExampleSettings.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { Dimensions, RendererMain } from '@lightningjs/renderer';

export interface ExampleSettings {
Expand Down
19 changes: 19 additions & 0 deletions examples/common/LocalStorage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// Retreive state from local storage (if localStorage is available)
// and set the state of the app accordingly.
export function loadStorage<T>(testName: string): Partial<T> | null {
Expand Down
19 changes: 19 additions & 0 deletions examples/common/LoremIpsum.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export function getLoremIpsum(numCharacters?: number) {
if (numCharacters === undefined) {
return loremIpsum;
Expand Down
19 changes: 19 additions & 0 deletions examples/common/PageContainer.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { INode, ITextNode, RendererMain } from '@lightningjs/renderer';
import { Component } from './Component.js';
import { loadStorage, saveStorage } from '../common/LocalStorage.js';
Expand Down
19 changes: 19 additions & 0 deletions examples/common/paginateTestRows.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Comcast Cable Communications Management, LLC.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import type { INode } from '@lightningjs/renderer';
import { PageContainer } from './PageContainer.js';
import { assertTruthy } from '@lightningjs/renderer/utils';
Expand Down
2 changes: 1 addition & 1 deletion exports/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
*
* @packageDocumentation
*/
export { assertTruthy, mergeColorAlpha } from '../src/utils.js';
export { assertTruthy, mergeColorAlpha, deg2Rad } from '../src/utils.js';
export { EventEmitter } from '../src/common/EventEmitter.js';
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
* limitations under the License.
*/

// import { Colors } from '../../../Colors.js';
// import type { Renderer } from '../../../Renderer.js';
import { intersectBound, type Bound, type Rect } from '../../../lib/utils.js';
import {
TextRenderer,
Expand Down
37 changes: 10 additions & 27 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,6 @@
* limitations under the License.
*/

export const boltProperties = [
'x',
'y',
'z',
'w',
'h',
'color',
'alpha',
'parentId',
'textureId',
'rtt',
'scale',
'rotation',
];

export const pipelineEvents = {
created: 1,
updated: 2,
deleted: 4,
attached: 8,
detached: 16,
onscreen: 32,
offscreen: 64,
progress: 128,
finished: 256,
};

export function createWebGLContext(
canvas: HTMLCanvasElement | OffscreenCanvas,
): WebGLRenderingContext | null {
Expand Down Expand Up @@ -200,3 +173,13 @@ export function mergeColorAlphaPremultiplied(
export function hasOwn(obj: object, prop: string | number | symbol): boolean {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

/**
* Converts degrees to radians
*
* @param degrees
* @returns
*/
export function deg2Rad(degrees: number): number {
return (degrees * Math.PI) / 180;
}