backspaces / agentscript

An Agent Based Modeling system (ABM)
http://backspaces.github.io/agentscript/
GNU General Public License v3.0
107 stars 14 forks source link

patchesColor doesn't do what I thought with a function that returns a color string #29

Closed bennlich closed 3 years ago

bennlich commented 3 years ago

In drawOptions, this works:

{
    patchesColor: p => Color.typedColor('red')
}

But this does not:

{
    patchesColor: p => 'red'
}

Though it did lead to this beautiful image:

Screenshot from 2021-02-19 15-41-06

backspaces commented 3 years ago

Good catch! Patches use pixels, believe it or not! I try to convert everything to typedColors but this is a leak.

backspaces commented 3 years ago

OK, a quick note: The way to color all the patches the same color is:

    {
        patchesColor: 'red' 
    }

i.e. there is no dependency on "p".

Basically it is treated as "clear the canvas with this color"

The form (with the great colors!) should work, let me poke around.

backspaces commented 3 years ago

OK I think I found the problem. Damn there are a lot of color formats in JS!

It is less efficient to set each patch's color, that's thousands of operations, one per patch. God do I need to document this stuff.

backspaces commented 3 years ago

OK, committed the fix.