Sample

Schnappinger/aoi/artofillusion.procedural.ColorDarkenModule

Human rating uses the original dataset scale.

Human2.01
Lines80

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
43.8Δ 37.9
Scalabrino0.4140–1; higher is more readable
4.5Δ 1.5
Dorn0.1040–1; higher is more readable
34.0Δ 28.1
Mi0.2630–1; higher is more readable
17.2Δ 11.2
LLOC27Logical lines; fewer is more readable
51.5Δ 45.5
DeepSeek V4 Pro16.670–20; mean of three runs
59.9Δ 54.0
GPT-6.1 Sol160–20; mean of three runs
38.9Δ 33.0
BTTF0.3190–1; higher is more readable
23.8Δ 17.8
Human2.011–4; original rating
5.9

Views

Source code

/* This is a Module which outputs the darker of two colors. */ /* Copyright (C) 2001 by David M. Turner <novalis@novalis.org> and Peter Eastman This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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 General Public License for more details. */ package artofillusion.procedural; import artofillusion.*; import artofillusion.math.*; import artofillusion.ui.*; import java.awt.*; public class ColorDarkenModule extends Module { RGBColor color; boolean colorOk; double lastBlur; public ColorDarkenModule(Point position) { super(Translate.text("menu.darkerModule"), new IOPort [] {new IOPort(IOPort.COLOR, IOPort.INPUT, IOPort.TOP, new String [] {"Color 1", '('+Translate.text("white")+')'}), new IOPort(IOPort.COLOR, IOPort.INPUT, IOPort.BOTTOM, new String [] {"Color 2", '('+Translate.text("white")+')'})}, new IOPort [] {new IOPort(IOPort.COLOR, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Darker"})}, position); color = new RGBColor(0.0f, 0.0f, 0.0f); } /* New point, so the color will need to be recalculated. */ public void init(PointInfo p) { colorOk = false; } /* Calculate the darker color. */ public void getColor(int which, RGBColor c, double blur) { if (colorOk && blur == lastBlur) { c.copy(color); return; } float brightness1, brightness2; colorOk = true; lastBlur = blur; if (linkFrom[0] == null) { color.setRGB(1.0f, 1.0f, 1.0f); brightness1 = 1.0f; } else { linkFrom[0].getColor(linkFromIndex[0], color, blur); brightness1 = color.getBrightness(); } if (linkFrom[1] == null) { c.setRGB(1.0f, 1.0f, 1.0f); brightness2 = 1.0f; } else { linkFrom[1].getColor(linkFromIndex[1], c, blur); brightness2 = c.getBrightness(); } if (brightness1 < brightness2) c.copy(color); else color.copy(c); } }

Loading feature diagnosis…

Source regions

Feature contributions

Feature contributions

FeatureValueContribution
(log-odds)
Halstead volumeHow much symbolic information the code contains. It combines the total number of operators and values with the number of distinct ones.2377.724−78.465
Source linesThe number of non-empty source lines.80+32
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.4.957−7.435

Intercept 8.87 + feature contributions = -45.03 (log-odds).
Score = sigmoid(-45.03) = 0.

Score0.414

Feature contributions

FeatureValueContribution
(log-odds)
Identifier layout (horizontal)How rapidly the visual pattern of identifier characters changes from left to right. It measures spatial frequency, not the meaning of the names.172.988−3.662
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.172.988+1.987
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.80−1.796
Indentation frequencyHow rapidly indentation changes from line to line.72+1.753
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.72−1.231
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.78.839+0.692
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.094+0.033

Intercept 0.07 + feature contributions = -2.154 (log-odds).
Score = sigmoid(-2.154) = 0.104.

Score0.263
Score27
Run 1

The code is generally well-structured and readable. It has clear separation of concerns, with a constructor for initialization, an init method for state reset, and a getColor method for the core logic. The nesting depth is acceptable, with only two levels of conditionals. Variable names are descriptive (brightness1, brightness2, colorOk, lastBlur). Comments explain the non-obvious parts like the caching mechanism. The code length is appropriate for the functionality. However, there are minor readability issues: the constructor has very long parameter lists with nested array declarations that make it dense, and the getColor method mixes concerns by both computing colors and handling caching. The action granularity is mostly one action per line, though some lines are quite long. The reading flow is natural for experienced Java developers but could be improved with better formatting of the constructor parameters and perhaps extracting the caching logic. Overall, it's solid procedural code with clear intent but slightly dense in places.

Run 2

The code is well-structured and readable. It has clear separation of concerns with a constructor, initialization method, and color calculation method. Nesting is shallow — the deepest level is just two blocks. Intent is evident from method names and comments, and the module's purpose is documented. Action granularity is appropriate: most lines perform a single logical operation. The main readability drawback is the constructor call with nested IOPort array definitions, which is visually dense and harder to parse. Additionally, the getColor method uses a cached `color` and an output parameter `c` in a way that requires careful reading to track which color object holds what. Minor naming ambiguity (e.g., `color` as both field and parameter) also slightly reduces clarity. Overall, the code is concise, logically organized, and maintains a natural reading flow.

Run 3

The code is well-structured with clear separation of concerns: constructor, initialization, and color calculation. The method names and comments clearly convey intent. Nesting is minimal—only one level deep in conditionals. Each logical action is generally on its own line, improving readability. The reading flow is natural, moving from input validation through computation to output. However, the getColor method is somewhat lengthy and handles multiple responsibilities (caching, default handling for two inputs, brightness comparison), which slightly reduces clarity. The blurred equality check (blur == lastBlur) for floating-point values is a potential bug but doesn't affect readability score. The constructor call is quite long with deeply nested array initializations, which hampers readability at that specific point. Overall, the code is clear and maintainable with good naming conventions and logical organization.

Run 1

Code Structure: Clearly separated constructor, initialization, and color calculation, though constructor configuration is densely formatted. Nesting: Shallow conditionals and an early return keep complexity low. Clarity of intent: The class name, comments, and brightness comparison clearly communicate the purpose; names such as c and colorOk, plus using color and c as both working storage and outputs, require some interpretation. Code length: Compact and mostly necessary, with minor duplication in handling missing inputs. Action granularity: Most statements perform one action per line, but constructor lines contain multiple nested object constructions, and brightness variables share a declaration. Reading flow: Calculation proceeds naturally from cache checking through input retrieval to selecting the darker color. Unusual brace indentation and long constructor lines slightly disrupt scanning.

Run 2

Code Structure: The class is logically divided into construction, cache invalidation, and color calculation, though getColor combines caching, input retrieval, and selection. Nesting: Shallow conditionals and an early return keep complexity low. Clarity of intent: Comments, brightness variables, and method names explain the purpose; colorOk, c, and mutable copying between the cached color and output require closer attention. Code length: The implementation is reasonably concise, with some repetitive input-handling logic. Action granularity: Most lines perform one action, but the constructor packs several nested object and array creations into long lines. Reading flow: The progression from cache check to input brightness calculation to darker-color selection is natural. Unusual brace indentation, dense constructor formatting, and implicit cache/output synchronization slightly reduce readability.

Run 3

Code Structure: The class is logically organized into construction, cache invalidation, and color calculation, though getColor combines caching, input retrieval, and selection. Nesting: Shallow conditionals and an early return keep control flow easy to follow. Clarity of intent: The class name, comments, and brightness variables clearly convey the purpose; names such as c and colorOk are less descriptive, and using color and c as both working storage and output requires attention. Code length: The implementation is compact, although input-handling branches repeat similar logic. Action granularity: Most statements perform one action per line, but the constructor packs several nested object and array constructions into long lines. Reading flow: Execution proceeds naturally from cache checking to retrieving inputs and choosing the darker color. Consistent but unusual brace indentation and the dense constructor slightly hinder scanning.