Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39556

Re: Picture colors decreasing script.

Path csiph.com!news.swapon.de!aioe.org!news.mb-net.net!open-news-network.org!.POSTED.0.237.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Picture colors decreasing script.
Date Wed, 03 Mar 2021 19:47:03 +0100
Organization PointedEars Software (PES)
Lines 34
Message-ID <5689266.lOV4Wx5bFT@PointedEars.de> (permalink)
References <7fbf64ec-ed11-4ee7-b530-459e5681651en@googlegroups.com> <91fc5c33-11cc-480d-8703-272e7d161849n@googlegroups.com> <5440012.DvuYhMxLoT@PointedEars.de> <52708860-8e17-4136-b79d-f76002425ce2n@googlegroups.com>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 7Bit
Injection-Info gwaiyur.mb-net.net; posting-host="0.237.197.178.dynamic.wless.lssmb00p-cgnat.res.cust.swisscom.ch:178.197.237.0"; logging-data="22207"; mail-complaints-to="abuse@open-news-network.org"
User-Agent KNode/4.14.10
Cancel-Lock sha1:9zNwhv5WDTQ5JT0+5PXAb0LIVkw=
X-User-ID U2FsdGVkX1848slRhtkWrWGbzg+/4pnbEV8XBreW42oCJ/dMs4o7Mg==
Face iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg==
X-Face %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v
Xref csiph.com comp.lang.javascript:39556

Show key headers only | View raw


Michael Haufe (TNO) wrote:

> On Tuesday, March 2, 2021 at 6:42:26 AM UTC-6, Thomas 'PointedEars' Lahn
> wrote:
>> Michael Haufe (TNO) wrote:
>> > Also for readability the following:
>> > 
>> > ```
>> > var a1=imgData.data[i];
>> > var a2=imgData.data[i+1];
>> > var a3=imgData.data[i+2];
>> > var a4=imgData.data[i+3];
>> > ```
>> > 
>> > I think can be replaced with:
>> > 
>> > ```
>> > let {data} = imgData
>> > let [r,g,b,a] = [data[i], data[i+1], data[i+2], data[i+3]]
>> > ```
>> let [r,g,b,a] = data.slice(i, i + 4);
>> 
>> :)
> 
> Yes, that's shorter but when dealing with ImageData in a loop you
> definitely don't want to do this due to the significant performance
> penalty (at least an order of magnitude).

What is the functional difference between your code and mine?

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | <http://PointedEars.de/es-matrix>
<https://github.com/PointedEars> | <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | Please do not cc me./Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Picture colors decreasing script. Kristjan Robam <kristjanrobam01@mail.ee> - 2021-02-28 22:33 -0800
  Re: Picture colors decreasing script. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-01 11:56 -0800
    Re: Picture colors decreasing script. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-02 13:42 +0100
      Re: Picture colors decreasing script. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-03 07:02 -0800
        Re: Picture colors decreasing script. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-03 19:47 +0100
          Re: Picture colors decreasing script. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-03 11:37 -0800
            Re: Picture colors decreasing script. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-03 21:33 +0100
              Re: Picture colors decreasing script. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-03 12:38 -0800
                Re: Picture colors decreasing script. Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-03 21:53 +0100
                Re: Picture colors decreasing script. "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-03 16:36 -0800
                Re: Picture colors decreasing script. Ben Bacarisse <ben.usenet@bsb.me.uk> - 2021-03-04 02:07 +0000
          Re: Picture colors decreasing script. John G Harris <niam@jghnorth.org.uk.invalid> - 2021-03-04 09:40 +0000

csiph-web