Skip to main content
Inspiring
February 13, 2025
Answered

How can I implement LiveEffect with rasterization?

  • February 13, 2025
  • 1 reply
  • 272 views

Hello! I am currently doing research on implementing LiveEffectPlugin in Deno (https://deno.com/) and I am strongly seeking information on LiveEffect with rasterization.

 

The LiveEffect built into Illustrator implements things like “rasterize”, “blur”, and “drop shadow” that involve rasterization processing, but I am having trouble finding examples of implementing such effects. (Even after searching through the SDK documentation, open source projects on GitHub, and other references)

 

Does anyone know how to do this?

 

The GoLiveEffect method of the plugin has been implemented so far, but the set pixels are not reflected on the screen. (To make it easier to understand the result, I have made the bonding box red.)

```

ASErr HelloWorldPlugin::GoLiveEffect(AILiveEffectGoMessage *message)

{

    ASErr error = kNoErr;

    PluginParams params;

    this->getDictionaryValues(message->parameters, params);

    

    try {

        AIArtHandle art = message->art;

   

        AIArtSet artSet;

        error = sAIArtSet->NewArtSet(&artSet); CHKERR;

        error = sAIArtSet->AddArtToArtSet(artSet, art); CHKERR;

 

        AIRasterizeSettings settings;

        settings.type = kRasterizeARGB;

        settings.resolution = 300.0;

        settings.antialiasing = 4;

        settings.options = kRasterizeOptionsNone;

        settings.preserveSpotColors = false;

       

        AIRealRect bounds;

        error = sAIRasterize->ComputeArtBounds(artSet, &bounds, false); CHKERR;

 

        AIArtHandle rasterArt;

        AIRasterRecord rasterRecord;

       

        error = sAIRasterize->Rasterize(artSet, &settings, &bounds,

                                      kPlaceAbove, art, &rasterArt, NULL); CHKERR;

        error = sAIRaster->GetRasterInfo(rasterArt, &rasterRecord); CHKERR;

        

        std::cout << rasterRecord.bounds.top << " "

            << rasterRecord.bounds.right << " "

            << rasterRecord.bounds.bottom << " "

            << rasterRecord.bounds.left << std::endl;

 

        ai::uint32 width = rasterRecord.bounds.right - rasterRecord.bounds.left;

        ai::uint32 height = rasterRecord.bounds.bottom - rasterRecord.bounds.top;

        

        AISlice artSlice = {0, 0, static_cast<ai::int32>(width), static_cast<ai::int32>(height), 0, 4};

        AISlice workSlice = artSlice;

        

        // !! THIS IS NOT WORKING (No any appearance changed) !! //

        AITile workTile;

        error = sAIRaster->GetRasterTile(rasterArt, &artSlice, &workTile, &workSlice); CHKERR;

        

        for(ai::uint32 i = 0; i < width * height * 4; i += 4) {

           static_cast<ai::uint8*>(workTile.data)[i] = 255;     // Red

           static_cast<ai::uint8*>(workTile.data)[i+1] = 0;     // Green

           static_cast<ai::uint8*>(workTile.data)[i+2] = 0;     // Blue

           static_cast<ai::uint8*>(workTile.data)[i+3] = 255;   // Alpha

        }

 

        error = sAIRaster->SetRasterTile(rasterArt, &artSlice, &workTile, &workSlice);

        delete[] static_cast<ai::uint8*>(workTile.data);

        message->art = rasterArt;

        // !! THIS IS NOT WORKING (No any appearance changed) !! //

        

        sAIArtSet->DisposeArtSet(&artSet);

    } catch (...) {

        

    }

    

    return error;

}

```

 

Regards

Correct answer hanak1a

I apologize, but I have forgotten the details. However, I will leave a link to the relevant process for the plugin that works.

https://github.com/hanakla/illustrator-webgpu-plugin/blob/main/pkgs/plugin/Source/AiDenoPlugin.cpp#L207

1 reply

hanak1aAuthor
Inspiring
March 17, 2025

Sorry this problem solved!

Participant
March 31, 2025

How did you solve it?

 

Many thanks

hanak1aAuthorCorrect answer
Inspiring
July 5, 2025

I apologize, but I have forgotten the details. However, I will leave a link to the relevant process for the plugin that works.

https://github.com/hanakla/illustrator-webgpu-plugin/blob/main/pkgs/plugin/Source/AiDenoPlugin.cpp#L207