A scaling function for ColorSampler#539
Draft
ItsJuls wants to merge 2 commits intoPolyhedralDev:masterfrom
Draft
A scaling function for ColorSampler#539ItsJuls wants to merge 2 commits intoPolyhedralDev:masterfrom
ItsJuls wants to merge 2 commits intoPolyhedralDev:masterfrom
Conversation
solonovamax
requested changes
Dec 11, 2025
Member
solonovamax
left a comment
There was a problem hiding this comment.
the code also probably needs a reformat
Comment on lines
+97
to
+99
| private double lerp(double start, double end, double t) { | ||
| return start + t * (end - start); | ||
| } |
Member
There was a problem hiding this comment.
I am very confident we have a lerp elsewhere, try to use that instead.
Comment on lines
+101
to
+103
| private double cubic(double p0, double p1, double p2, double p3, double t) { | ||
| return 0.5 * ((2 * p1) + (-p0 + p2) * t + (2 * p0 - 5 * p1 + 4 * p2 - p3) * t * t + (-p0 + 3 * p1 - 3 * p2 + p3) * t * t * t); | ||
| } |
Comment on lines
+105
to
+112
| private int getA(int c) { return (c >> 24) & 0xFF; } | ||
| private int getR(int c) { return (c >> 16) & 0xFF; } | ||
| private int getG(int c) { return (c >> 8) & 0xFF; } | ||
| private int getB(int c) { return c & 0xFF; } | ||
|
|
||
| private int argb(int a, int r, int g, int b) { | ||
| return (a << 24) | (r << 16) | (g << 8) | b; | ||
| } |
Comment on lines
+114
to
+116
| private int clamp(double val) { | ||
| return Math.max(0, Math.min(255, (int) val)); | ||
| } |
Member
There was a problem hiding this comment.
I'd be surprised if we don't have that elsewhere
Comment on lines
+82
to
+85
| int a = (int) lerp(lerp(getA(c00), getA(c10), tx), lerp(getA(c01), getA(c11), tx), tz); | ||
| int r = (int) lerp(lerp(getR(c00), getR(c10), tx), lerp(getR(c01), getR(c11), tx), tz); | ||
| int g = (int) lerp(lerp(getG(c00), getG(c10), tx), lerp(getG(c01), getG(c11), tx), tz); | ||
| int b = (int) lerp(lerp(getB(c00), getB(c10), tx), lerp(getB(c01), getB(c11), tx), tz); |
Member
There was a problem hiding this comment.
pretty sure the nested lerps will end up performing a few additional operations which could be factored out
no clue if the JVM will do that for you or not, though
Comment on lines
+37
to
+45
| switch (method) { | ||
| case BILINEAR: | ||
| return applyBilinear(sx, sz); | ||
| case BICUBIC: | ||
| return applyBicubic(sx, sz); | ||
| case NEAREST: | ||
| default: | ||
| return sampler.apply((int) sx, (int) sz); | ||
| } |
Member
There was a problem hiding this comment.
use an enhanced switch with the arrow syntax
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Description
Fixes/Addresses #537 and adds a new ScaleColorSampler.java to the image library addon
Changelog
Checklist
Mandatory checks
ver/prefix)or is a branch that is intended to be merged into a version branch.
CONTRIBUTING.mddocument in the root of the git repository.
Types of changes
Compatibility
Documentation
Testing
Licensing
release it under GPLv3.
released under GPLv3 or a compatible license.