Rebrand as TPSchedule and refine clear liquid glass dock

This commit is contained in:
Codex
2026-10-13 22:08:20 +08:00
parent 50fcc70e8e
commit 204e945b2e
45 changed files with 1155 additions and 103 deletions
@@ -58,4 +58,63 @@ void main() {
sourcePicture.dispose();
},
);
test(
'glass rim reflects nearby backdrop light outside its transmitted ray',
() async {
const width = 160, height = 100;
final program = await ui.FragmentProgram.fromAsset(
'shaders/liquid_glass.frag',
);
Future<ByteData> draw(bool brightEdge) async {
final sourceRecorder = ui.PictureRecorder();
final sourceCanvas = ui.Canvas(sourceRecorder);
sourceCanvas.drawRect(
const ui.Rect.fromLTWH(0, 0, 160, 100),
ui.Paint()..color = const ui.Color(0xFF28465A),
);
if (brightEdge) {
sourceCanvas.drawRect(
const ui.Rect.fromLTWH(0, 0, 5, 100),
ui.Paint()..color = const ui.Color(0xFF28E65A),
);
}
final sourcePicture = sourceRecorder.endRecording();
final source = await sourcePicture.toImage(width, height);
final shader = program.fragmentShader()
..setFloat(0, width.toDouble())
..setFloat(1, height.toDouble())
..setFloat(2, 0)
..setFloat(3, 0)
..setFloat(4, width.toDouble())
..setFloat(5, height.toDouble())
..setFloat(6, 1)
..setImageSampler(0, source);
final recorder = ui.PictureRecorder();
ui.Canvas(recorder).drawRect(
const ui.Rect.fromLTWH(0, 0, 160, 100),
ui.Paint()..shader = shader,
);
final picture = recorder.endRecording();
final image = await picture.toImage(width, height);
final data = (await image.toByteData())!;
image.dispose();
picture.dispose();
shader.dispose();
source.dispose();
sourcePicture.dispose();
return data;
}
final plain = await draw(false), reflected = await draw(true);
final rimGreen = (50 * width + 8) * 4 + 1;
final centreGreen = (50 * width + 80) * 4 + 1;
expect(
reflected.getUint8(rimGreen) - plain.getUint8(rimGreen),
greaterThan(2),
);
expect(reflected.getUint8(centreGreen), plain.getUint8(centreGreen));
expect(reflected.getUint8(rimGreen + 2), 255);
},
);
}