Skip to content

New App: Perlin Noise generator#368

Open
rektdeckard wants to merge 1 commit intotronbyt:mainfrom
rektdeckard:tf/perlin-noise
Open

New App: Perlin Noise generator#368
rektdeckard wants to merge 1 commit intotronbyt:mainfrom
rektdeckard:tf/perlin-noise

Conversation

@rektdeckard
Copy link

Adds a new app that renders colorful, customizable Perlin noise.

perlin_noise@2x

@rektdeckard rektdeckard requested a review from tavdog as a code owner February 16, 2026 04:55
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @rektdeckard, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new application that renders dynamic and colorful Perlin noise patterns. It provides users with options to adjust the visual characteristics of the noise, offering a customizable animated background or visual effect. The implementation leverages a Simplex Noise algorithm to create these complex, mathematical visuals.

Highlights

  • New Perlin Noise App: A new application named 'Perlin Noise' has been added, designed to generate animated, customizable noise patterns.
  • Customizable Parameters: The app includes a schema allowing users to customize the hue and scale of the generated Perlin noise.
  • Simplex Noise Algorithm: The core of the application implements a Simplex Noise algorithm for efficient and visually appealing noise generation.
Changelog
  • apps/perlinnoise/manifest.yaml
    • Added a new manifest file for the 'Perlin Noise' app, defining its metadata such as ID, name, summary, description, author, and associated file names.
  • apps/perlinnoise/perlin_noise.star
    • Implemented the full Perlin Noise generation logic, including the Simplex Noise algorithm, gradient calculations, and interpolation functions.
    • Defined a get_schema function to allow user configuration of the noise's color and scale.
    • Included helper functions for color calculation and list flattening to support the rendering process.
    • Set up the main rendering loop using render.Animation to display the animated noise patterns.
Activity
  • No activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new Perlin noise generator app. The implementation of the Perlin noise algorithm is present, but there are several areas for improvement. I've identified a critical bug in color generation that will cause the app to render incorrectly. Additionally, the app lacks input validation which can lead to crashes, and it doesn't support 2x rendering despite being advertised in the pull request description. I've also included suggestions to align with the repository's style guide and improve code maintainability, such as refactoring large data structures and simplifying the rendering logic. Please review the detailed comments for specific suggestions.

h = (val & 0xF0) >> 4
l = val & 0x0F
# print([h, l])
return c + b[h] + b[l]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The color string concatenation is incorrect. The color value from the configuration is a full hex string (e.g., #RRGGBB). Appending two more hex characters results in an invalid color string that will prevent the app from rendering correctly. To modulate a component of the color (e.g., the blue part), you should slice the original string.

return c[:5] + b[h] + b[l]

Comment on lines +203 to +218
def main(config):
color = config.str("color");
if not color:
color = HUE
scale = config.str("scale");
if not scale:
scale = SCALE
scale = int(scale)

return render.Root(
child = render.Animation(
children = flatten([[render.Column([
render.Row([
render.Box(color = color_for_pixel(x, y, t, color, scale), width = 1, height = 1) for x in range(64)]) for y in range(32)])] * FRAMES_PER_VIEW for t in range(FRAMES)])
)
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The main function has several areas for improvement regarding robustness, style, and features:

  • 2x Support: The app lacks 2x support, using hardcoded 64x32 dimensions. The style guide encourages 2x support, and it seems intended based on your PR description. This can be added by using render.get_render_dimensions().
  • Input Validation: The scale configuration is not validated. A non-numeric input will crash the app. This should be handled with a try/except block.
  • Code Simplification: The children list for render.Animation is generated using a complex flatten helper. This can be simplified to a direct list comprehension, making the flatten function and FRAMES_PER_VIEW constant unnecessary.
  • Style: Lines 204 and 207 contain unnecessary semicolons.

Here is a revised main function that addresses these points. You will also need to add canvas to your load statement at the top of the file: load("render.star", "render", "canvas").

def main(config):
	color = config.get("color") or HUE

	scale = SCALE
	scale_str = config.get("scale")
	if scale_str:
		try:
			scale = int(scale_str)
		except ValueError:
			pass # Fallback to default scale

	dims = render.get_render_dimensions()

	return render.Root(
		child = render.Animation(
			children = [render.Column([
				render.Row([
					render.Box(color = color_for_pixel(x, y, t, color, scale), width = 1, height = 1) for x in range(dims.width)]) for y in range(dims.height)]) for t in range(FRAMES)]
		)
	)
References
  1. We encourage app developers to add 2x support for their apps. Please refer to the Pixlet documentation on 2x apps for detailed guidelines. A file with a main() function that doesn't import the "canvas" object from "render.star" is likely an app without 2x support. (link)

summary: Perlin noise for your Tronbyt
desc: Set the vibe with beautiful, complex, colorful animated noise produced with math!
author: rektdeckard
fileName: perlin_noise.star
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The fileName does not match the app's directory name. This violates the repository's file naming conventions.

fileName: perlinnoise.star
References
  1. The Starlark file containing the main() function should have the same base name as its containing directory. (link)

],
)

PERMUTATION = [151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225,140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve readability and maintainability, large constant data structures like PERMUTATION (and GRAD_3) should be moved to a separate file (e.g., perlin_data.star) and loaded using a load() statement. This follows general best practices for this repository.

References
  1. To improve readability and maintainability, move large data structures into a separate file and load them into the main application logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant