Sample

Schnappinger/aoi/artofillusion.procedural.RGBModule

Human rating uses the original dataset scale.

Human3.19
Lines60

Scores

MethodScoreScaleDataset rank
(0–100)
Posnett00–1; higher is more readable
42.5Δ 9.5
Scalabrino0.5360–1; higher is more readable
12.0Δ 21.0
Dorn0.3830–1; higher is more readable
54.1Δ 21.1
Mi0.4980–1; higher is more readable
33.3Δ 0.3
LLOC18Logical lines; fewer is more readable
63.4Δ 30.4
DeepSeek V4 Pro16.670–20; mean of three runs
59.9Δ 26.9
GPT-6.1 Sol170–20; mean of three runs
55.3Δ 22.3
BTTF0.3030–1; higher is more readable
20.8Δ 12.2
Human3.191–4; original rating
33.0

Views

Source code

/* 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 java.awt.*; /** This is a Module which takes three numbers, and uses them as the red, green, and blue components of a color. */ public class RGBModule extends Module { RGBColor color; boolean colorOk; double lastBlur; public RGBModule(Point position) { super("RGB", new IOPort [] {new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.LEFT, new String [] {"Red", "(0)"}), new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.LEFT, new String [] {"Green", "(0)"}), new IOPort(IOPort.NUMBER, IOPort.INPUT, IOPort.LEFT, new String [] {"Blue", "(0)"})}, new IOPort [] {new IOPort(IOPort.COLOR, IOPort.OUTPUT, IOPort.RIGHT, new String [] {"Color"})}, 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 color. */ public void getColor(int which, RGBColor c, double blur) { if (colorOk && blur == lastBlur) { c.copy(color); return; } colorOk = true; lastBlur = blur; float red = (linkFrom[0] == null) ? 0.0f : (float) linkFrom[0].getAverageValue(linkFromIndex[0], blur); float green = (linkFrom[1] == null) ? 0.0f : (float) linkFrom[1].getAverageValue(linkFromIndex[1], blur); float blue = (linkFrom[2] == null) ? 0.0f : (float) linkFrom[2].getAverageValue(linkFromIndex[2], blur); color.setRGB(red, green, blue); 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.2199.891−72.596
Source linesThe number of non-empty source lines.60+24
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.065−7.597

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

Score0.536

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.114.951−1.204
Comment layout frequencyHow frequently the layout switches between lines containing only comments or whitespace and lines containing code.61−1.123
Comment layout (horizontal)How rapidly the visual pattern of comment characters changes from left to right.114.918+1.05
Indentation frequencyHow rapidly indentation changes from line to line.51+1.027
Number layout frequencyHow rapidly the number of numeric values per line changes through the code.51−0.749
Identifier layout (vertical)How rapidly the visual pattern of identifier characters changes from top to bottom.59.698+0.425
Operator visual areaThe share of the code’s visual area occupied by operators such as +, =, and *.0.094+0.027

Intercept 0.07 + feature contributions = -0.478 (log-odds).
Score = sigmoid(-0.478) = 0.383.

Score0.498
Score18
Run 1

The code is generally well-structured and readable. It has a logical organization with clear separation of methods, a flat structure with minimal nesting (only one if statement), and obvious intent from method names and comments. The code length is appropriate for the task, and action granularity is reasonable—though a few lines, like the constructor's IOPort array definitions and getColor's value assignments, contain multiple complex expressions that slightly reduce readability. Reading flow is natural, with clear initialization and calculation steps. Minor deductions are due to dense parameter lists and the somewhat redundant color caching logic, which could benefit from further simplification or comment clarification. Overall, the code is quite readable with only minor improvements needed.

Run 2

The code is highly readable with clear structure and logical organization. It follows standard Java conventions with proper package, imports, and class documentation. The constructor neatly declares input/output ports on separate lines, making the module's interface evident. The methods are concise with clear purposes: init resets caching, getColor calculates color. Nesting is minimal with a flat conditional structure. Action granularity is good—each line performs one logical operation. The caching logic and conditional expressions are understandable, though the ternary operations in getColor could be slightly verbose. Variable names are meaningful (colorOk, lastBlur). Comments are helpful but not excessive. The code demonstrates good separation of concerns and maintains a natural reading flow from initialization to calculation.

Run 3

The code is generally well-structured and readable. It has a clear class layout with fields, constructor, and methods, flat nesting, and good use of comments to explain purpose. The constructor is somewhat verbose due to inline IOPort array construction, which slightly affects readability but is acceptable for a UI-oriented class. The getColor method has a clear flow: cache check, computation, and assignment. However, there is some ambiguity around the caching logic (colorOk and lastBlur) and the long ternary lines for reading inputs reduce line-level clarity. Overall, the code is concise and follows consistent formatting, making it easy to follow for someone familiar with the domain.

Run 1

Code Structure: The class is logically organized into construction, cache invalidation, and color calculation. Nesting: Minimal nesting and an early return keep control flow simple. Clarity of intent: The class documentation, RGB variable names, and comments clearly explain its purpose; colorOk, c, and numeric input indices are less descriptive. Code length: The implementation is concise, though the constructor's inline port definitions and repeated channel expressions are visually dense. Action granularity: Statements generally perform one action per line, but constructor lines combine several object creations. Reading flow: The calculation naturally proceeds from cache checking to channel retrieval and color assignment. Long lines, unconventional brace indentation, and wildcard imports slightly reduce readability.

Run 2

Code Structure: The class is logically organized into construction, cache invalidation, and color calculation. Nesting: Control flow is shallow, with a single conditional and an early return. Clarity of intent: The class documentation, RGB variable names, and comments clearly explain its purpose; abbreviated parameters, implicit array-index mappings, and the name colorOk are less descriptive. Code length: The implementation is concise, though repeated channel expressions and the dense constructor add visual complexity. Action granularity: Most statements perform one action per line, but the constructor packs several nested object and array creations together. Reading flow: Methods follow a natural lifecycle, and getColor reads sequentially from cache checking to channel calculation and output copying. Long lines and unconventional brace indentation slightly hinder scanning.

Run 3

Code Structure: Clearly separated constructor, initialization, and color calculation methods provide logical organization. Nesting: Minimal nesting and an early return keep the main calculation flat. Clarity of intent: The class documentation, RGB variable names, and comments explain the purpose well, although colorOk, c, and numeric input indices require some interpretation. Code length: Compact and appropriate, with only minor repetition in component retrieval. Action granularity: Most lines perform one action, but the constructor packs several nested object and array constructions into dense lines. Reading flow: The progression from port setup to cache invalidation, cache checking, and RGB calculation is natural. Long constructor and ternary-expression lines, plus unconventional brace indentation, slightly reduce readability.