I played with lines and strokes, but those don’t seem to keep around anything like texture information that would allow for a general solution.
A go at rects and circles:
local CX, CY = display.contentCenterX, display.contentCenterY do -- Rect effect local kernel = { category = "generator", name = "dashes" } kernel.vertexData = { { name = "number\_of\_spots", index = 0, default = 8 }, -- dashes + spaces between { name = "start\_on\_dash", index = 1, default = 1 } -- start on dash on this side? (set to 0 otherwise) } kernel.isTimeDependent = true kernel.fragment = [[#define DASH\_TIME .37 // How many seconds does it take to cover one dash's worth of distance? P\_COLOR vec4 FragmentKernel (P\_UV vec2 uv) { P\_UV float offset = CoronaTotalTime / DASH\_TIME; // How many dashes have we covered? offset += CoronaVertexUserData.y; // Are we starting in one or not? offset += uv.x \* CoronaVertexUserData.x; // Which bin are we in? P\_UV float dash = step(mod(offset, 2.), 1.); // Choose white or black return CoronaColorScale(vec4(dash)); }]] graphics.defineEffect(kernel) end local r = display.newRect(CX, CY, 150, 150) local bottom = display.newRect(r.x, r.y + r.height / 2, r.width + 5, 5) local right = display.newRect(r.x + r.width / 2, r.y, r.height, 5) local top = display.newRect(r.x, r.y - r.height / 2, r.width + 5, 5) local left = display.newRect(r.x - r.width / 2, r.y, r.height, 5) right.rotation = 90 bottom.rotation = 180 left.rotation = 270 for \_, rect in ipairs{ bottom, right, top, left } do rect.fill.effect = "generator.custom.dashes" end do -- Circle effect local kernel = { category = "generator", name = "circle\_dashes" } kernel.vertexData = { { name = "cx", index = 0 }, { name = "cy", index = 1 }, { name = "number\_of\_spots", index = 2, default = 30 }, -- dashes + spaces between (should be even) } kernel.isTimeDependent = true kernel.vertex = [[varying P\_POSITION vec2 v\_Diff; P\_POSITION vec2 VertexKernel (P\_POSITION vec2 pos) { v\_Diff = pos - CoronaVertexUserData.xy; return pos; }]] kernel.fragment = [[varying P\_POSITION vec2 v\_Diff; #define DASH\_TIME .37 // How many seconds does it take to cover one dash's worth of distance? P\_COLOR vec4 FragmentKernel (P\_UV vec2 uv) { P\_UV float offset = CoronaTotalTime / DASH\_TIME; // How many dashes have we covered? P\_UV float pc = atan(v\_Diff.y, v\_Diff.x); // partial circumference / arc length, in [-pi, +pi] offset += CoronaVertexUserData.z \* ((pc / 3.14159 + 1.) / 2.); // remapped to [0, 2], then use to find bin P\_UV float dash = step(mod(offset, 2.), 1.); // Choose white or black return CoronaColorScale(vec4(dash)); } ]] graphics.defineEffect(kernel) end local c = display.newCircle(CX, CY + 250, 90) c.strokeWidth = 5 c.stroke.effect = "generator.custom.circle\_dashes" c.stroke.effect.cx = c.x c.stroke.effect.cy = c.y
While not terribly convenient, it might get you somewhere. The rect technique could be used on any polygonal object too.