Sample

Schnappinger/aoi/artofillusion.procedural.ColorScaleModule

Human rating uses the original dataset scale.

Human3
Lines61

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
47.5Δ 22.1
Scalabrino0.5220–1; higher is more readable
10.6Δ 14.8
Dorn0.2350–1; higher is more readable
43.2Δ 17.8
Mi0.510–1; higher is more readable
35.3Δ 9.9
LLOC19Logical lines; fewer is more readable
61.6Δ 36.1
DeepSeek V4 Pro160–20; mean of three runs
47.4Δ 21.9
GPT-6.1 Sol16.670–20; mean of three runs
48.0Δ 22.6
BTTF0.2720–1; higher is more readable
19.1Δ 6.3
Human31–4; original rating
25.4

Views

Source code

/* This is a Module which outputs the product of a color and a number. */ /* Copyright (C) 2000 by 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 ColorScaleModule extends Module { RGBColor color; boolean colorOk; double lastBlur; public ColorScaleModule(Point position) { super("\u00D7", new IOPort [] {new IOPort(IOPort.COLOR, IOPort.INPUT, IOPort.TOP, new String [] {"Color", '('+Translate.text("white")+')'}), new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.BOTTOM, new String [] {"Scale", "(1.0)"})}, new IOPort [] {new IOPort(IOPort.COLOR, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Product"})}, 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 product color. */ public void getColor(int which, RGBColor c, double blur) { if (colorOk && blur == lastBlur) { c.copy(color); return; } colorOk = true; lastBlur = blur; if (linkFrom[0] == null) color.setRGB(1.0f, 1.0f, 1.0f); else linkFrom[0].getColor(linkFromIndex[0], color, blur); if (linkFrom[1] != null) color.scale(linkFrom[1].getAverageValue(linkFromIndex[1], blur)); c.copy(color); } }

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.1907.266−62.94
Source linesThe number of non-empty source lines.61+24.4
Byte entropyHow varied the bytes in the source text are. Repeated bytes give a lower value; a more even mixture gives a higher value.5.033−7.55

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

Score0.522

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.143.968−2.433
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.144+1.519
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.62−1.159
Indentation frequencyHow rapidly indentation changes from line to line.53+1.096
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.53−0.795
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.60.648+0.438
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.088+0.083

Intercept 0.07 + feature contributions = -1.181 (log-odds).
Score = sigmoid(-1.181) = 0.235.

Score0.51
Score19
Run 1

The code is generally well-structured with clear separation of concerns: constructor sets up ports, init resets state, getColor computes output. Purpose is evident from comments and naming. Nesting is shallow with only one level in getColor. However, there are minor readability issues: the constructor call is very long with deeply nested array initializations, making it hard to parse at a glance. The caching logic (colorOk/lastBlur) adds conditional complexity. Multiple actions occur per line in the constructor and some method calls chain operations. The mixed use of comments and self-documenting code is reasonable, though inline comments could be more descriptive. The method signature for getColor includes an unused 'which' parameter, adding slight ambiguity. Overall, readable but could benefit from extracting port configuration or simplifying constructor initialization.

Run 2

The code is generally readable with clear structure and intent. The class is well-organized, with logical fields, constructor, and methods. Nesting is reasonably flat, with only one level of conditional nesting in getColor. Purpose is clear from comments and method names (init, getColor). Code length is proportionate to functionality, and action granularity is mostly one action per line. Reading flow is natural. However, readability is slightly reduced by the very long constructor call with heavily nested array initializations for IOPort objects, making the signature difficult to parse at a glance. The mixed use of Unicode escape sequence '\u00D7' also obscures the operator symbol. Some minor inconsistencies exist, like using both explicit 0.0f values and setRGB for default color, but overall the code is maintainable and understandable.

Run 3

The code is generally clear and well-structured. The module has a single, focused purpose with concise methods (init, getColor) and flat nesting. Comments explain non-obvious behavior. However, readability is slightly reduced by the dense constructor, which packs multiple multi-line IOPort array definitions into a single long call. Also, several operations occur within the getColor method (input handling, color scaling, caching), making it somewhat busy. Naming is clear, but import statements are overly broad (artoillusion.*), which obscures dependencies. Overall, the flow is logical and the code is maintainable for experienced readers.

Run 1

Code Structure: Logically organized into construction, cache invalidation, and color calculation. Nesting: Shallow conditionals and an early return keep control flow simple. Clarity of intent: The class name, comments, and operations clearly communicate color scaling, though names such as colorOk and c, plus numeric input indices, require interpretation. Code length: Compact and mostly necessary; the license header adds reading overhead but is separate from the implementation. Action granularity: Most statements perform one action per line, but the constructor compresses several nested object and array creations into dense lines. Reading flow: Calculation proceeds naturally from cache checking to input retrieval, scaling, and output copying. Unusual brace indentation, omitted conditional braces, wildcard imports, and crowded constructor formatting slightly reduce readability.

Run 2

Code Structure: The class is logically organized into construction, cache initialization, and color calculation. Nesting: Control flow is shallow, with a straightforward early return for cached results. Clarity of intent: The class name, comments, and method calls clearly convey color scaling, although names such as colorOk and c and numeric input indices require some interpretation. Code length: The implementation is concise with little unnecessary logic; the license header adds length but not complexity. Action granularity: Most lines perform one action, but the constructor compresses several nested array and port constructions into long lines. Reading flow: Calculation proceeds naturally from cache checking to obtaining a color, applying a scale, and copying the result. Dense constructor formatting, wildcard imports, and inconsistent brace usage slightly reduce readability.

Run 3

Code Structure: The class is logically organized into construction, initialization, and color calculation, with straightforward caching. Nesting: Control flow is shallow, and an early return keeps the main calculation flat. Clarity of intent: The introductory comment and method comments explain the purpose; names generally communicate their roles, though colorOk, c, and numeric link indices require some interpretation. Code length: The implementation is concise without substantial duplication; the lengthy license header does not complicate the logic. Action granularity: Most lines perform one action, but the constructor packs several nested object and array creations into long lines. Reading flow: Methods follow a natural sequence, and getColor proceeds clearly from cache checking to input retrieval, scaling, and output copying. Dense constructor formatting, wildcard imports, and inconsistent brace placement slightly reduce readability.