Skip to content
TheChatArchiveThe Chat Archive
Geminigemini-2.5-pro· GoogleHugging Face LMArena Human Preference 140K

i have stripped the code down, and yet it still black, can you now find culprit? /** *…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with o4-mini-2025-04-16’s answer.
  1. User

    i have stripped the code down, and yet it still black, can you now find culprit? /**

    • NeuroSurfaceSkia — final "Apple-style" blob */ import React, { useEffect } from 'react'; import { View, StyleSheet } from 'react-native'; import { Canvas, Path, Skia, Group, vec, RadialGradient, BlurMask, Paint, Image, } from '@shopify/react-native-skia'; import Animated, { useSharedValue, withTiming, withRepeat, useDerivedValue, } from 'react-native-reanimated';

    import { Spacing, getClarityGradient, getClarityColor } from '@/constants/Colors'; import { CognitionLevel } from '@/types';

    // ---------- tiny 512×512 monochrome noise bitmap, cached once ---------- // const createNoiseBitmap = () => { ... }; // const noiseBmp = createNoiseBitmap();

    // ---------- organic path ------------------------------------------------ const makeBlobPath = (R: number, t: number, clarity: CognitionLevel) => { 'worklet'; const pts = 48; const ampl = Math.min(0.08, Math.max(0.05, 0.18 - clarity * 0.02)); const p: [number, number][] = []; for (let i = 0; i < pts; ++i) { const a = (i / pts) * Math.PI * 2; const n = Math.sin(a * 3 + t * 2) * 0.6 + Math.sin(a * 7 + t) * 0.4; const r = R * (1 + ampl * n); p.push([Math.cos(a) * r, Math.sin(a) * r]); } const path = Skia.Path.Make(); for (let i = 0; i < pts; ++i) { const p0 = p[(i - 1 + pts) % pts], p1 = p[i], p2 = p[(i + 1) % pts], p3 = p[(i + 2) % pts]; if (i === 0) path.moveTo(...p1); path.cubicTo( p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6, p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6, ...p2 ); } path.close(); return path; };

    // ---------- component --------------------------------------------------- export default function NeuroSurfaceSkia({ clarity, size = 300 }: { clarity: CognitionLevel | null; size?: number; }) { const prog = useSharedValue(0); const level = clarity ?? 3; const speed = {1:8000,2:7000,3:6000,4:5000,5:4500}[level]!; useEffect(() => { prog.value = withRepeat(withTiming(1,{duration:speed}), -1, false); }, [level, prog]);

    const σ = 50, pad = σ3; const canvas = size + pad2, R = size*0.35; const baseScale = {1:0.85,2:0.9,3:0.95,4:1,5:1.05}[level]!;

    const transform = useDerivedValue(()=>{ const s = baseScale + 0.04Math.sin(prog.valueMath.PI*2); return [ { translateX:canvas/2 }, { translateY:canvas/2 }, { scale:s } ]; }, [prog, baseScale, canvas]);

    const blobPath = useDerivedValue(()=>{ 'worklet'; return makeBlobPath(R, prog.valueMath.PI2, level); }, [prog, level, R]);

    return ( <View style={{ width: size, height: size, alignItems:'center',justifyContent:'center' }}> <Canvas style={{ width: canvas, height: canvas, margin: -pad, backgroundColor: 'white' }}>

          {/* ── STEP A ── simple solid fill ── */}
          
          <Path path={blobPath}>
            <Paint color={Skia.Color('#00FF00')} />
          </Path>
          
    
          {/* ── STEP B ── core radial gradient only ── */}
          {/*
          <Path path={blobPath}>
            <RadialGradient
              c={vec(0,0)} r={R}
              colors={[
                Skia.Color('#A8E6CF'),
                Skia.Color('#C6F6D5'),
                Skia.Color('#F7F7FF'),
              ]}
              positions={[0, 0.6, 1]}
            />
          </Path>
          */}
    
          {/* ── STEP C ── full pipeline ── */}
          {/*
          <Group blendMode="screen">
            <Path path={blobPath}>
              <RadialGradient
                c={vec(0,0)} r={R}
                colors={[
                  Skia.Color('rgba(198,246,213,0.8)'),
                  Skia.Color('rgba(240,253,244,0)'),
                ]}
              />
              <BlurMask blur={σ} style="outer" />
            </Path>
          </Group>
          <Path path={blobPath}>
            <RadialGradient
              c={vec(0,0)} r={R}
              colors={[
                Skia.Color('#A8E6CF'),
                Skia.Color('#C6F6D5'),
                Skia.Color('#F7F7FF'),
              ]}
              positions={[0,0.6,1]}
            />
          </Path>
          <Path path={blobPath}>
            <Paint style="stroke" strokeWidth={1.2} color="rgba(255,255,255,0.18)" />
            <BlurMask blur={6} style="solid" />
          </Path>
          */}
    
        </Group>
      </Canvas>
    </View>
    

    ); }

    /* ---------------- styles ---------------- */ // const styles = StyleSheet.create({ ... });

  2. Gemini Assistant

    Of course. After stripping down the code, the culprit becomes much clearer and is a very common point of confusion when first using React Native Skia.

    The issue is the use of Skia.Color().

    The Culprit:

    The JSX components like <Paint>, <Path>, <RadialGradient>, etc., are designed to accept color values as strings. The library's renderer then parses these strings internally to create the actual Skia color objects.

    When you write this:

    <Paint color={Skia.Color('#00FF00')} />
    

    You are not passing a string. You are calling the Skia.Color() utility function, which returns a low-level representation of the color (a Float32Array like [0, 1, 0, 1]). The <Paint> component's color prop does not know how to handle this pre-processed array and defaults to black.

    The Fix:

    You must remove the Skia.Color() wrapper and pass the color strings directly to the props.

    Here is the corrected code for all three of your test steps:

    export default function NeuroSurfaceSkia({ clarity, size = 300 }: {
      // ... (rest of the setup code is correct)
    }) {
      // ...
    
      return (
        <View style={{ width: size, height: size, alignItems:'center',justifyContent:'center' }}>
          <Canvas style={{ width: canvas, height: canvas, margin: -pad, backgroundColor: 'white' }}>
            <Group transform={transform}>
    
              {/* ── STEP A ── simple solid fill (CORRECTED) ── */}
              <Path path={blobPath}>
                {/* Just pass the string directly */}
                <Paint color="#00FF00" /> 
              </Path>
              
              {/* ── STEP B ── core radial gradient only (CORRECTED) ── */}
              {/*
              <Path path={blobPath}>
                <RadialGradient
                  c={vec(0,0)} r={R}
                  colors={[ // Pass strings directly in the array
                    '#A8E6CF',
                    '#C6F6D5',
                    '#F7F7FF',
                  ]}
                  positions={[0, 0.6, 1]}
                />
              </Path>
              */}
    
              {/* ── STEP C ── full pipeline (CORRECTED) ── */}
              {/*
              <Group blendMode="screen">
                <Path path={blobPath}>
                  <RadialGradient
                    c={vec(0,0)} r={R}
                    colors={[ // Pass strings directly
                      'rgba(198,246,213,0.8)',
                      'rgba(240,253,244,0)',
                    ]}
                  />
                  <BlurMask blur={σ} style="outer" />
                </Path>
              </Group>
              <Path path={blobPath}>
                <RadialGradient
                  c={vec(0,0)} r={R}
                  colors={[ // Pass strings directly
                    '#A8E6CF',
                    '#C6F6D5',
                    '#F7F7FF',
                  ]}
                  positions={[0,0.6,1]}
                />
              </Path>
              <Path path={blobPath}>
                <Paint style="stroke" strokeWidth={1.2} color="rgba(255,255,255,0.18)" />
                <BlurMask blur={6} style="solid" />
              </Path>
              */}
    
            </Group>
          </Canvas>
        </View>
      );
    }
    

    Key Takeaway

    In React Native Skia, when using the declarative JSX syntax, always pass colors as strings to props like color or colors.

    The Skia.Color() utility is meant for more advanced, imperative use cases, such as manipulating color data within a custom shader or a drawing worklet, not for direct use in JSX props.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.