zoonel

Newbies
  • Content count

    2
  • Joined

  • Last visited

Community Reputation

0

About zoonel

  1. Borders N' Shapes

    The plugin crashes paint.net: pyrochild_plugins_2009-11-30 Paint.NET v3.5.1 (Final Release build 3.51.3610.35022) new project-> select the tool : ok new project-> make a selection -> select the tool: crash If there is a selection it crashes, must be some bounds limits
  2. CellMaker Rev

    Hi, this is a modified version of the Cellmaker plugin by Ego Eram Reputo. Use Effects->Render->CellMaker Rev CellMakerRev.zip I needed to see the center of borders, so i quickly learned how to write a plugin (thanks to codelab;)). Reading the original post and answers i used the MadJik's coding approach for efficiency. Here is what it does: + entire/not entire cells option + choose start grid reference + move grid + show borders centers + a lot faster then the original plugin - it has the same flaw of the original plugin: Hidden Content: The plugin checks only if the 4 corners are visible to draw a cell. So this may happen. A picture to show the possibilities Hidden Content: And the source Code in codelab Hidden Content: // CellMaker Rev v1.0 // (CellMaker plugin (by Ego Eram Reputo) modified by MadJik remodified by X). // // Makes a grid of cells inside a given selection. // The selection may be more than one area. // Cell walls drawn in Primary color. // #region UICode int Amount1=12; // [2,255] Cell Width int Amount2=12; // [2,255] Cell Height int Amount3=0; // [0,2] Corners: Hard, Soft, Rounded bool Amount4 = false; // [0,1] Draw borders centers bool Amount5 = true; // [0,1] Draw only entire Cells bool Amount6 = true; // [0,1] Draw grid from top left of selection int Amount7=0; // [-128,128] Move Horizontaly int Amount8=0; // [-128,128] Move Verticaly #endregion void Render(Surface dst, Surface src, Rectangle rect) { // Other variables PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds); Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt(); ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor; ColorBgra Pix; int Top, Top2, Bottom, Bottom2, Left, Left2, Right, Right2, CellWidth, W2, CellHeight, H2; bool IsLeft, IsTop, IsIncluded ; bool L2T2,LT2,RT2,L2T=false,LT,RT,L2B,LB,RB; CellWidth = (int) Amount1 + 1 ; CellHeight = (int) Amount2 + 1; W2 = (int)(Amount1/2) + 1; H2 = (int)(Amount2/2) + 1; //!! c# doesnt do the proper negative modulo //int XOffset = -selection.Left % CellWidth; //int YOffset = -selection.Top % CellHeight; int XOffset = (CellWidth - (selection.Left + Amount7 ) % CellWidth) % CellWidth; int YOffset = (CellHeight - (selection.Top + Amount8 ) % CellHeight) % CellHeight; // Clear the canvas in the case of changed parameters for(int y = rect.Top; y < rect.Bottom; y++) for (int x = rect.Left; x < rect.Right; x++) dst[x,y] = src[x,y]; // Loop through all the cells in the selection for(int y = rect.Top; y < rect.Bottom; y++) { Top = (int)( y / CellHeight ) * CellHeight ; if(Amount6) { Top -= YOffset ; if(y >= Top + CellHeight) Top += CellHeight; } Bottom = Top + CellHeight; Top2 = Top - CellHeight ; //Bottom2 = Bottom + CellHeight; IsTop = y==Top; for (int x = rect.Left; x < rect.Right; x++) { IsIncluded = !Amount5; // Find the values for each of the cell vertices Left = (int)( x / CellWidth ) * CellWidth; if(Amount6) { Left -= XOffset; if(x >= Left + CellWidth) Left += CellWidth; } Right = Left + CellWidth; Left2 = Left - CellWidth; //Right2 = Right + CellWidth; IsLeft = x==Left; Pix = src[x,y]; // Test if the Cell is included in the selection // Extra checks for borders and angles // Try to minimize IsVisible calls if(Amount5) { if(selectionRegion.IsVisible(Left,Top)) { RT = selectionRegion.IsVisible(Right, Top); LB = selectionRegion.IsVisible(Left, Bottom); RB = selectionRegion.IsVisible(Right, Bottom); IsIncluded = RT && LB && RB ; if(!IsIncluded && IsLeft) { L2T = selectionRegion.IsVisible(Left2,Top); L2B = selectionRegion.IsVisible(Left2, Bottom); IsIncluded = L2T && L2B && LB ; } if(!IsIncluded && IsTop) { LT2 = selectionRegion.IsVisible(Left, Top2); RT2 = selectionRegion.IsVisible(Right, Top2); IsIncluded = RT && LT2 && RT2 ; if(!IsIncluded && IsLeft) { L2T2 = selectionRegion.IsVisible(Left2, Top2); IsIncluded = L2T && L2T2 && LT2 ; } } } } if (IsIncluded) { // tests for the crossings effects switch (Amount3) { case 0: // Easy: just test if we are on the grid, draw PrimaryColor if (IsLeft||IsTop) Pix = PrimaryColor; break; case 1: // Corner level 1, one x or y must be on the grid but not the both! if (IsLeft^IsTop) Pix = PrimaryColor; break; case 2: // Corner level 2, more test to define if we need to draw the pixel! if (IsLeft) { if ((Math.Abs(y - Top)>1)&&(Math.Abs(y - Bottom)>1)) Pix = PrimaryColor; } else if (IsTop) { if ((Math.Abs(x - Left)>1)&&(Math.Abs(x - Right)>1)) Pix = PrimaryColor; } else if (( ( ((y - Top)==1) || ((Bottom - y)==1) ) ) && ( ((x - Left)==1) || ((Right - x)==1) ) ) Pix = PrimaryColor; break; default: break; } // Draw the centers of borders if(Amount4 && !IsLeft && !IsTop && ( ((y == (Top + H2) || y == (Bottom - H2)) && (x==(Left+1) || x==(Right-1))) || ((x == (Left + W2) || x == (Right - W2)) && (y==(Top+1) || y==(Bottom-1))) ) ) Pix = PrimaryColor; } dst[x,y] = Pix; } } } ps: I took the same icon as original plugin, and copy some code from ego eram reputo and MadJik. If this is not allowed i'll delete what's needed. ps2: I still dont quite understand how some functions works. I've seen a lot of for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if(selectionRegion.IsVisible(x,y)) But the plugins only works within selected region, so why do that? Also is there a similar function as selectionRegion.IsVisible(x,y) for segments or areas, because calling IsVisible for a lot pixel is very slow. Thx