Git Product home page Git Product logo

Comments (2)

lainz avatar lainz commented on July 22, 2024

Hi, is not that easy I think, at least you must iterate each color in the XML of the svg image, and apply a function into it to make it darker or lighter.

from bgracontrols.

circular17 avatar circular17 commented on July 22, 2024

I can see 4 ways to do it:

  • iterate through the XML (not practical indeed)
  • iterate through the SVG elements (I've just added an IterateElements method to do that). Here is a sample callback function:
procedure TForm1.ChangeFill(AElement: TSVGElement; AData: pointer;
  var ARecursive: boolean);
begin
  if AElement is TSVGDefine then
    ARecursive:= false
  else
  begin
   if not AElement.isFillNone then AElement.fillColor := CSSSkyBlue;
   if not AElement.isStrokeNone then AElement.strokeColor := CSSOrange;
  end;
end; 

// used like this:
svg.IterateElements(@ChangeFill, nil, true);
  • to use the currentColor variable in the SVG and to define it at the top level when drawing the SVG (I've just added a Color property to TBGRASVG class)
  • render the SVG in a temporary image and apply a filter to change its color (as done in TBGRASVGTheme)

from bgracontrols.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.