Author Topic: Rellenar figuras creadas con Geometry  (Read 6698 times)

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Rellenar figuras creadas con Geometry
« on: 2008 December 16 06:33:38 »
Bueno, mientras no empiezo las vacas parece que podré dedicar un ratillo a esto... en fins, pues que estoy jugando con Geometry, concretamente drawPie, y me interesaba rellenar la figura que acabo de crear. Así luego le hago un blur al conjunto y lo uso de máscara para hacer cositas malas.... Sin embargo no veo cómo rellenar figuras. No he probado bmp.fill porque supongo que eso me plancha el bitmap entero. He visto que drawPolygon tiene un parámetro FillRule pero lo he probado y no observo diferencias. Así pues, ¿existe alguna herramienta en plan bucket fill? ¿O tengo que hacerlo yo a manopla dibujando muchas líneas en lugar de hacer un drawPie?
--
 David Serrano

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Rellenar figuras creadas con Geometry
« Reply #1 on: 2008 December 16 07:40:35 »
Hombre, por fin alguien que quiere dibujar :)

Es muy sencillo. Tienes que usar Graphcs y definir brush y pen. Aquí tienes un ejemplo con un pie de esos:

Code: [Select]
#include <pjsr/UndoFlag.jsh>

#define RADIUS       100
#define BKG_COLOR    0 // black
#define DRAW_COLOR   ARGBColor( 255, 127, 0 )
#define START_ANGLE  45
#define SPAN_ANGLE   90

function MakePie( r, a1, a2, color )
{
   // Working bitmap
   var bmp = new Bitmap( 2*r + 1, 2*r + 1 );

   // Fill with transparent color
   bmp.fill( 0 );

   // Create a graphics context for our working bitmap
   var g = new Graphics( bmp );

   // We want high-quality antialiased graphics
   g.antialiasing = true;

   // Define working objects
   g.pen = new Pen( color );
   g.brush = new Brush( color );

   // Draw a pie
   g.drawPie( r, r, r, Math.rad( a1 ), Math.rad( a2 ) );

   g.end(); // don't forget this!!!

   return bmp;
}

// 32-bit AARRGGBB color value from color components
function ARGBColor( red, green, blue, opacity )
{
   var color = (red << 16) | (green << 8) | blue;
   if ( opacity == null )
      color |= 0xff000000; // opaque
   else
      color |= opacity << 24;
   return color;
}

var pie = MakePie( RADIUS, START_ANGLE, SPAN_ANGLE, DRAW_COLOR );

var window = new ImageWindow( pie.width, pie.height, 3, 8, false, true );
var view = window.mainView;
view.beginProcess( UndoFlag_NoSwapFile ); // do not generate swap files
view.image.fill( BKG_COLOR );
view.image.blend( pie );
view.endProcess();

window.show();
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Rellenar figuras creadas con Geometry
« Reply #2 on: 2008 December 16 07:57:59 »
Quote from: "Juan Conejero"
Code: [Select]

   g.brush = new Brush( color );


Vaya, pues mira que era sencillo. Muchas gracias!
--
 David Serrano

Offline Simon Hicks

  • PixInsight Old Hand
  • ****
  • Posts: 333
Rellenar figuras creadas con Geometry
« Reply #3 on: 2008 December 16 11:14:18 »
Hi Guys,

Maybe I have misunderstood this thread....I have to trust Google Translate  :roll: ....but it seems to be about the ability to paint or draw in PI. I have wanted this feature for a while....especially useful to create odd masks maybe to just select that awful star with the big rings round it....but none of the other large features....etc, etc.

It would be great to have a pen feature where you could select say a black pen of varying size and feathering so I could just paint a blob on a mask where I want it.

If this is easy to do then it might make a popular feature......and don't talk to me about scripts or programming...I am useless...its all Greek to me!  :(

Cheers
              Simon

Offline David Serrano

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 503
Rellenar figuras creadas con Geometry
« Reply #4 on: 2008 December 16 14:12:35 »
Quote from: "simonhicks"
If this is easy to do then it might make a popular feature......and don't talk to me about scripts or programming...I am useless...its all Greek to me!  :(


Sorry. You can draw, but only from the javascript interface.
--
 David Serrano

Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Rellenar figuras creadas con Geometry
« Reply #5 on: 2008 December 17 01:24:12 »
Quote
Sorry. You can draw, but only from the javascript interface.


True. However I have several drawing tools planned. They will include both bitmap and vector oriented dynamic drawing tools (similar in their usage to CloneStamp, but obviously much richer).

There are other priorities though, so don't expect to see this implemented very soon. But these tools are definitely in the to-do list and I think they will make PixInsight a much more competing platform, with respect to other applications out there.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/

Offline Simon Hicks

  • PixInsight Old Hand
  • ****
  • Posts: 333
Rellenar figuras creadas con Geometry
« Reply #6 on: 2008 December 17 02:34:55 »
Cool....I will be patient.  8)