# Ants with Alpha or Shaders with Strokes

**URL:** <https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529>\
**Category:** Custom Shader Effects\
**Created:** [February 28, 2019, 3:17pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529 "2019-02-28T15:17:09Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul041](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@paul041](https://forums.solar2d.com/u/paul041)\
**Post date:** [February 28, 2019, 3:17pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/1 "2019-02-28T15:17:09Z")

</div>

Hi,

Sorry, I guess this is kind of two questions…

\*\* Marching Ants Effect

The ‘Marching Ants’ effect as defined here gives a black/white effect.

[https://docs.coronalabs.com/guide/graphics/effects.html#generator.marchingants](https://docs.coronalabs.com/guide/graphics/effects.html#generator.marchingants)

The effect I would like to achieve is a white/alpha effect.

The link referred to on this post, is dead - [https://forums.coronalabs.com/topic/62537-marching-ants-configurability/](https://forums.coronalabs.com/topic/62537-marching-ants-configurability/)

I assume it’s supposed to point to the link above, but there’s no configurability documented there?

\*\* Shaders on strokes

I’ve come up with this (likely terrible) shader -&nbsp;[https://f25j6.app.goo.gl/LyEM](https://f25j6.app.goo.gl/LyEM)&nbsp;- black/alpha for testing

I don’t know a lot about shaders - and I’m having a hell of a time getting it to apply to a newRoundedRect stroke.

```
local ants = {} ants.category = "generator" ants.name = "antspantz" ants.isTimeDependent = true ants.fragment = [[P\_COLOR vec4 FragmentKernel( P\_UV vec2 texCoord ){ &nbsp; vec4 CoronaVertexUserData = vec4(0,0,0,0); &nbsp; P\_COLOR vec4 ret = vec4(0, 0, 0, &nbsp; &nbsp; sin((CoronaTotalTime\*5.)+(texCoord.x\*50.)+(texCoord.y\*50.)) &nbsp; ); &nbsp; return CoronaColorScale(ret); }]] graphics.defineEffect( ants ) -- display.setDefault("background", .7, .7, .7) obj = display.newRoundedRect( 200, 200, 320, 320, 20 ) obj.fill = { 1,0,0,1 } obj.stroke = { 0,1,1,1 } obj.strokeWidth = 20 obj.stroke.effect = "generator.custom.antspantz"

```

produces different results in the simulator every time you run it ?!

change that last line to fill instead of stroke and it works - so I guess strokes are broken?&nbsp; ☹

---

<div class="post-metadata">

**Author:** ![davebollinger](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@davebollinger](https://forums.solar2d.com/u/davebollinger)\
**Post date:** [March 1, 2019, 3:02pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/2 "2019-03-01T15:02:49Z")

</div>

are you aware that the [source](https://github.com/coronalabs/corona/blob/master/librtt/Display/Shader/kernel_generator_marchingAnts_gl.lua) is available?&nbsp; i think if you simply replace the constant “1.0” alpha value of the returned color with the variable “gray” then it’ll effectively be a strokecolor-or-transparent effect (which seems like what you’re after).

---

<div class="post-metadata">

**Author:** ![paul041](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@paul041](https://forums.solar2d.com/u/paul041)\
**Post date:** [March 4, 2019, 1:26am UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/3 "2019-03-04T01:26:35Z")

</div>

Ahh, I was not aware, that will be useful thanks!

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [March 4, 2019, 7:59pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/4 "2019-03-04T19:59:35Z")

</div>

FYI:&nbsp;[https://forums.coronalabs.com/topic/62537-marching-ants-configurability/](https://forums.coronalabs.com/topic/62537-marching-ants-configurability/)&nbsp;seems to work for me. It may have been a temporary outage.

Rob

---

<div class="post-metadata">

**Author:** ![paul041](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@paul041](https://forums.solar2d.com/u/paul041)\
**Post date:** [March 12, 2019, 6:51am UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/5 "2019-03-12T06:51:36Z")

</div>

> [@rob](#):
>
> FYI:&nbsp;[https://forums.coronalabs.com/topic/62537-marching-ants-configurability/](https://forums.coronalabs.com/topic/62537-marching-ants-configurability/)&nbsp;seems to work for me. It may have been a temporary outage.
> 
> Rob

Hi Rob, yes that page works - but the link referred to on that page, doesn’t.

i.e. how is the generator effect configurable?

---

<div class="post-metadata">

**Author:** ![davebollinger](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/d/e79b87/32.png) [@davebollinger](https://forums.solar2d.com/u/davebollinger)\
**Post date:** [March 1, 2019, 3:02pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/6 "2019-03-01T15:02:49Z")

</div>

are you aware that the [source](https://github.com/coronalabs/corona/blob/master/librtt/Display/Shader/kernel_generator_marchingAnts_gl.lua) is available?&nbsp; i think if you simply replace the constant “1.0” alpha value of the returned color with the variable “gray” then it’ll effectively be a strokecolor-or-transparent effect (which seems like what you’re after).

---

<div class="post-metadata">

**Author:** ![paul041](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@paul041](https://forums.solar2d.com/u/paul041)\
**Post date:** [March 4, 2019, 1:26am UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/7 "2019-03-04T01:26:35Z")

</div>

Ahh, I was not aware, that will be useful thanks!

---

<div class="post-metadata">

**Author:** ![rob](https://forums.solar2d.com/user_avatar/forums.solar2d.com/rob/32/4_2.png) [@rob](https://forums.solar2d.com/u/rob)\
**Post date:** [March 4, 2019, 7:59pm UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/8 "2019-03-04T19:59:35Z")

</div>

FYI:&nbsp;[https://forums.coronalabs.com/topic/62537-marching-ants-configurability/](https://forums.coronalabs.com/topic/62537-marching-ants-configurability/)&nbsp;seems to work for me. It may have been a temporary outage.

Rob

---

<div class="post-metadata">

**Author:** ![paul041](https://forums.solar2d.com/letter_avatar_proxy/v4/letter/p/ebca7d/32.png) [@paul041](https://forums.solar2d.com/u/paul041)\
**Post date:** [March 12, 2019, 6:51am UTC](https://forums.solar2d.com/t/ants-with-alpha-or-shaders-with-strokes/349529/9 "2019-03-12T06:51:36Z")

</div>

> [@rob](#):
>
> FYI:&nbsp;[https://forums.coronalabs.com/topic/62537-marching-ants-configurability/](https://forums.coronalabs.com/topic/62537-marching-ants-configurability/)&nbsp;seems to work for me. It may have been a temporary outage.
> 
> Rob

Hi Rob, yes that page works - but the link referred to on that page, doesn’t.

i.e. how is the generator effect configurable?
