Color not getting set

If you run the following code in Main, you’ll get a blue horizontal line centered in the graphical window. But if you uncomment the line “stroke(scolor)” and comment out the “stroke(0,0,255)” no line appears anymore, even though “scolor = color(0,0,255)” on the previous line. It appears that a color variable assumes the opacity to be 0% while setting color directly in stroke() assumes the opacity to 100%. I would’ve thought the two would work similarly. A documentation problem, or a bug?

Here’s a couple more observations; assume the original code. Set strokeWidth() to 1, and no line appears–it only shows up when the width is >= 2 – why?

Lastly, set background(40, 40, 40) (or any not-quite-black color). If you look closely at the upper right corner of the graphical area, you can see a pale outline from the source window of the tab that creates new tabs.

As an aside, I’d like to thank Simeon and CrazyEd for their assistance in my previous message. I got that program working with their help.

  • Bob

P.S. If one buys the dark-editor theme, can you toggle between them, or does dark overwrite light?

-- Use this function to perform your initial setup
function setup()
--    print("Hello World!")

-- This function gets called once every frame
function draw()

    -- global gfx values
    -- compute reference line positions and colors
    local sheight = HEIGHT / 2
    local scolor = color(0, 0, 255)
    -- draw reference lines
    stroke(0, 0, 255)
--    stroke(scolor)            
    line(0, sheight, WIDTH, sheight)


Setting a variable to the function fill or stroke does nothing. The only thing stroke returns is the current color if it has no parameters. Try using vec3(). You can’t get the alpha, but it will do. Try it out! Hope that help.

color() has 4 parms scolor = color(0,0,255,255). Stroke as you say must have a default. But, passing it a color table with a missing alpha must not trigger the default.

as for strokeWidth(1) it must be used with noSmooth()

Even on strokeWidth(2) both lines are half blended to the background with smooth()

As for the pale outline of the tab, not seeing it. Rotate the iPad by 180, I think it is screen burn (or retena burn :slight_smile: )

You can switch from dark to light editor

@lpad41001. The documentation available through the editor shows color() to take 3 or 4 arguments, no indication that opacity is required or what its default is; meanwhile, stroke() takes <= 4 args, no default for opacity listed there either. For strokeWidth(), why must it be used with noSmooth()? The line is horizontal so there’s no aliasing needing to be smoothed. Where is this behavior documented? As for the tab afterimage, now that I look at it closer, it does seem to fade away in 30-60 seconds, so it’s something with the Ipad’s phosphors. And thanks for the note about the editor theme, if I couldn’t switch I wouldn’t get it.

@starblue color can take three arguments, however the alpha is being set to 0 by default. That seems a bit wrong to me — I’ll make it set the alpha to 255 for color(r, g, b) in the next update.