Author Topic: How to get color at specified point? (extensions)  (Read 577 times)

April 30, 2019, 01:20:17 PM
Read 577 times

markymark

  • Sr. Newbie

  • Offline
  • **

  • 4
What is the function I call to get the color at a specific point? Something like color = getColor(x,y).
« Last Edit: April 30, 2019, 06:16:25 PM by markymark »

April 30, 2019, 02:03:21 PM
Reply #1

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Welcome to the forum!

Is this a question about writing an extension?  I can't answer that directly, but this page on the Inkscape website tells a lot about writing extensions:  https://inkscape.org/develop/extensions/  Or someone else might know.
  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

April 30, 2019, 06:14:12 PM
Reply #2

markymark

  • Sr. Newbie

  • Offline
  • **

  • 4
yes extensions. I can't seem to find what I'm looking for at the page you provided. Essentially I'm looking for a way to use the dropper tool but in code.

April 30, 2019, 07:56:27 PM
Reply #3

brynn

  • Administrator

  • Offline
  • ******

  • 3,941
  • Gender
    Female

    Female
    • Inkscape Community
Moini might know.  She'll be along before too long.  If not, or if she doesn't know, we can put you in contact with developers (who tend not to visit forums).  Or at least more advanced users.

  • Inkscape version 0.92.3
  • Windows 7 Pro, 64-bit
Inkscape Tutorials (and manuals)                      Inkscape Community Gallery                        Inkscape for Cutting Design                     



"Be ashamed to die until you have won some victory for humanity" - Horace Mann                       

May 01, 2019, 10:05:37 AM
Reply #4

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
There is no such function call available. You would have to:

- Export to PNG in a suitable resolution
- Examine the corresponding pixel in the PNG in, e.g., imagemagick or PIL/pillow

May 01, 2019, 03:59:52 PM
Reply #5

Lazur

  • IC Mentor

  • Offline
  • ******
  • Inkscape Filters Wizard

  • 1,154
  • Gender
    Male

    Male
Thinking out loud.

Extensions can modify specified colours of an object. You may apply a colormatrix on a raster image, edit steps of gradients -with a colormatrix- so guessing if it was about an object inside a selected area using that may work instead.

On the other hand, there is the tiled clones option and the spray and scatter tool which actually generates data based on underlying pixels.
Probably if you compiled your own version of inkscape you could modify some of those to add in new features?

May 01, 2019, 09:53:22 PM
Reply #6

markymark

  • Sr. Newbie

  • Offline
  • **

  • 4
Basically I was following this tutorial  http://goinkscape.com/low-poly-art-tutorial-using-inkscape/. The second part of the tutorial "2. COLOR THE POLYGONS", requires going through each individual triangle and using the dropper tool to get the color of the raster image under it. I was hoping to automate this process with an extension but it seems like the function I need doesn't exist at the moment.

Is there an easy way to export to png and use imagemagick via python functions?

May 02, 2019, 08:43:38 AM
Reply #7

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
Ah. This is what I would do:

- use the spray tool to spray copies of a circle with unset fill, set to use the background color for the fill of the sprayed objects, onto the image you want to trace
- use the Delaunay method on the circles, in the mode of 'using the color of the objects'

Done.

This took me about 2 minutes to do:




May 02, 2019, 08:44:44 AM
Reply #8

Moini

  • IC Mentor

  • Offline
  • ******

  • 1,568
    • VektorRascheln
(Spray tool settings can be refined, too.)

May 02, 2019, 11:14:07 AM
Reply #9

markymark

  • Sr. Newbie

  • Offline
  • **

  • 4