Ghost_ARCHER

Members
  • Content Count

    13
  • Joined

  • Last visited

Community Reputation

0

About Ghost_ARCHER

  • Birthday 01/01/1970
  1. Ok, I get it, thanks. Nowadays ppl get lazier:) I googled it for a while. Or we should use P.N, which makes more sense for me
  2. replace the rgb (I think hsv's v is better) value with the minimum inside a 3*3 or 5*5 or 7*7 box. Run thru the image. Normal medium is used to get rid of spikes. I happened to see the effect of minimum looks like watercolor for me. it in fact do two things, reduces the number of colors in an area, and made the thin line wider, something like using a brush. Yeah, the median, the minimum and the maxium filters belong to the same group. The effect are all blurring. The median is logically more complex than a local minimum or maximum. I would guess an erosion or expansion of morphologic operation would be useful after the first step. I think the watercolor should have something like that to be more real.
  3. sorry for that, I forget to copy the tb link. and the thumbs look same to me. Next time I will use smaller images. What is that? Another control parameter is added to make the interface between water and sky more distinctive. strong effect is x-direction distortion, its power factor y-direction distortion is not significant. This is a game of mathematics !!
  4. I am studying .not now, that is the first reason. I like computer graphics, that is the second reason. I installed it on another computer, and wish sometimes later I will not need to pivate paintshop pro, therefore I support all good free paint programs (paint.net start slow on this one, therefore I use artweaver, as a comparison, some good freeware painter including: paint.net photobie.net --- not tried yet. paintstar artweaver deep paint -- large gimp photoplus Studioline -- large and the huge ms acrylic preview and graphic designer (not tried) pixia graphicgale photoclinic photofiltre As I know, gimp start very slow, then paint.net on this computer, artweaver a little faster but slower than paint.net on the other. The other software nearly same and fast. I hate pixia's interface. I hate ms' huge size. And photoplus seems have lots of svg component. But the company freeware normally not attractive. They will make it candylike and there will be no improvement for years. I like to try and see if there is new function or effect in other software. Like photoclinic, they have a swirl distortion that is much clearer than the one in the artweaver. Last, I once was trying to enter your college:) I am trying to use the lua to create the dialog for the controls. Artweaver dies or ignores all the time. There is suggestion in lua interface -- syntax error notification! No I have to adjust the parameter by hand:) I made the first .net paint program yesterday, seems easier than using the openGL and original C graphics. But I still have problems to totally understand madjik's code. Algorithm part is ok, the beginning loops is hard to understand without any context.
  5. My water reflection effect. Implement with lua script on artweaver, not with .net code yet -- Honestly, I have not install paint.dot on this computer, and still have trouble to write the whole thing from loading to save. I have not apply distortion on y direction. Working on it now, but first want to see if it is necessary. Right now I got 10 control parameters, have not figure out which is more important yet, still need to try to get rid something not important. As I feel, it is one of the fastest filter in lua on artweaver, because it just has one loop thru. Effect with different paramters, which I have not found way or proper name to discribe them. Edit by Rick: Images removed. They're kinda cool but we don't need 20 pages worth of them. Now with y distortion, 11 control parameters weak y distortion factor Edit by Rick: Images removed. They're kinda cool but we don't need 20 pages worth of them.
  6. Wow! You makes it looks very pro. I am coming up with a new idea, a plugin to make gears -- in fact, it should be generally to be a multiple folded center point symmetric, with the target curve represents by bezier curve (therefore we are dealing with points in fact and finally connect them by bezier curve) --- need some restriction to prevent it looks stupid. BTW, I am sorry the vector operation is not flawless -- even it is fast to calculate a 3000 vertex star, the end can't be closed because of the round off error. Only cos and sin can survive. Dim n As Integer = 7 Dim a As Double = 30.0 Dim b As Double = 0.0 Dim R1 As Integer = 250 'CInt(Math.Min(Me.ClientSize.Width, Me.ClientSize.Height) / 2 - 4) Dim R2 As Integer = 200 'CInt(R1 / 2) Dim ray As Integer = 2 Dim x1, y1, x2, y2, xt, yt As Integer Dim x0 As Integer = 300 ' CInt(Me.ClientSize.Width / 2) Dim y0 As Integer = 300 ' CInt(Me.ClientSize.Height / 2) Dim aa As Single = a * Math.PI / 180 Dim bb As Single = b * Math.PI / 180 Dim cc As Single = Math.PI / n xt = x0 + R2 * Math.Cos(bb - cc) yt = x0 + R2 * Math.Sin(bb - cc) Dim i As Integer For i = 0 To n Step 1 x1 = x0 + R1 * Math.Cos(aa + bb + 2 * i * cc) y1 = x0 + R1 * Math.Sin(aa + bb + 2 * i * cc) x2 = x0 + R2 * Math.Cos(bb + (2 * i + 1) * cc) y2 = x0 + R2 * Math.Sin(bb + (2 * i + 1) * cc) If ray = 2 Or ray = 3 Then gr.DrawLine(Pens.Red, x1, y1, x2, y2) gr.DrawLine(Pens.Red, x1, y1, xt, yt) End If If ray = 1 Or ray = 3 Then gr.DrawLine(Pens.Red, x0, y0, x1, y1) gr.DrawLine(Pens.Red, x0, y0, x2, y2) End If xt = x2 yt = y2 Next The bezier curve to draw gear ends with result, might be used somewhere else Private Sub form2_paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim gr As Graphics = e.Graphics Dim n As Integer = 12 Dim i As Integer Dim R1, R2 As Integer Dim x0 As Integer = 150, y0 As Integer = 150 R1 = 100 R2 = 70 Dim s As Integer s = 1 ' local variables Dim A1, A2, A3, A4 As Double Dim x1, y1, x2, y2, x3, y3, x4, y4, R As Integer A1 = Math.PI / n A2 = Math.PI * 0 / 180 x1 = x0 + R1 * Math.Cos(A2) y1 = y0 + R1 * Math.Sin(A2) A3 = A2 + s * Math.PI / 3 x2 = x0 + 2 * R1 * Math.Cos(A3) y2 = y0 + 2 * R1 * Math.Sin(A3) R = R1 For i = 1 To 2 * n 'adjust the reference direction If R = R1 Then R = R2 Else R = R1 End If A3 = i * A1 + A2 x3 = x0 + R * Math.Cos(A3) y3 = y0 + R * Math.Sin(A3) A4 = A3 - s * Math.PI / 3 x4 = x0 + 2 * R * Math.Cos(A4) y4 = y0 + 2 * R * Math.Sin(A4) gr.DrawBezier(Pens.Black, x1, y1, x2, y2, x4, y4, x3, y3) x1 = x3 y1 = y3 x2 = 2 * x3 - x4 y2 = 2 * y3 - y4 'gr.DrawLine(Pens.Black, x0, y0, x1, y1) 'gr.DrawLine(Pens.Black, x1, y1, x2, y2) Next gr.Dispose() End Sub
  7. For me, a simple minimum filter looks like a water color paint very much.
  8. A conceptional star: vb code illustrates Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Drawing.Imaging Imports System.Text 'option strict off Public Class Form1 Inherits System.Windows.Forms.Form #Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Private Sub InitializeComponent() ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(592, 573) Me.Name = "Form1" Me.Text = "Form1" End Sub #End Region Private Sub form1_paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint Dim gr As Graphics = e.Graphics gr.Clear(Color.Azure) Dim n As Integer = 5 Dim a As Double = 0.0 Dim b As Double = 0.0 Dim R1 As Integer = 250 'CInt(Math.Min(Me.ClientSize.Width, Me.ClientSize.Height) / 2 - 4) Dim R2 As Integer = 125 'CInt(R1 / 2) Dim ray As Integer = 3 Dim x1, y1, x2, y2 As Integer Dim x0 As Integer = 300 ' CInt(Me.ClientSize.Width / 2) Dim y0 As Integer = 300 ' CInt(Me.ClientSize.Height / 2) Dim vx1, vy1, vx2, vy2 As Double Dim aa As Double = Math.PI / n Dim sina As Double = Math.Sin(aa) Dim cosa As Double = Math.Cos(aa) Dim sin2a As Double = 2 * cosa * sina Dim cos2a As Double = 1 - 2 * sina * sina aa = Math.PI * a / 180 Dim sinb As Double = Math.Sin(aa) Dim cosb As Double = Math.Cos(aa) aa = Math.PI * b / 180 Dim sinc As Double = Math.Sin(aa) Dim cosc As Double = Math.Cos(aa) vx1 = R1 * cosb vy1 = R1 * sinb vx2 = CInt(R2 * cosa) vy2 = CInt(R2 * sina) Dim vtx, vty As Double vtx = vx2 vty = vy2 vtx = CInt(vx2 * cosc + vy2 * sinc) vty = CInt(-vy2 * sinc + vy2 * cosc) vx2 = vtx vy2 = vty vtx = CInt(vx1 * cosc + vy1 * sinc) vty = CInt(-vx1 * sinc + vy1 * cosc) vx1 = vtx vy1 = vty x1 = x0 + vx1 y1 = x0 + vy1 x2 = x0 + vx2 y2 = x0 + vy2 Dim i As Integer For i = 1 To n Step 1 If ray = 1 Or ray = 3 Then gr.DrawLine(Pens.Red, x0, y0, x1, y1) gr.DrawLine(Pens.Red, x0, y0, x2, y2) End If If ray = 2 Or ray = 3 Then gr.DrawLine(Pens.Red, x1, y1, x2, y2) End If vtx = vx2 vty = vy2 vx2 = CInt(vtx * cos2a + vty * sin2a) vy2 = CInt(-vtx * sin2a + vty * cos2a) x2 = x0 + vx2 y2 = y0 + vy2 If ray = 2 Or ray = 3 Then gr.DrawLine(Pens.Red, x2, y2, x1, y1) End If vtx = vx1 vty = vy1 vx1 = CInt(vtx * cos2a + vty * sin2a) vy1 = CInt(-vtx * sin2a + vty * cos2a) x1 = x0 + vx1 y1 = y0 + vy1 Next End Sub End Class This is a single program. I don't know how to match the interface to paint.net BTW, I just realized when too many rotation applied, the round error will cause R1 gets shorter. Therefore, cos and sin might be better
  9. Yes, only if we drawing a polygon with over 1000 vertex, the difference might be seen, but the polygon will became a circle anyway:) OK, I figured out my Javascript is disabled for this site, but I still can't find out how to attach a file. Do I need a webspace? Following code is wat you posted before. I am not sure it is latest but I think the looping part is a little overlapped with each other, as I noted down in the code. I am not quite sure what you are trying to do in the loop from left to right, from top to bottom. using Polygones.Properties; ..... using System.Windows.Forms; // the revised version on madjik's polygon, by Ghost_Archer. // replace the cos and sin with vector operation, no other changes namespace Polygones { ... { ... public override void Render(...) { ... // I am not sure what the startIndex and length refers to, is that the counter for selections and masks? //////////////////////////////////////////////////////////////////////////// // yet it seems that there are too many loops here. // I guess there will be lots of overlapping pixels inside // i.e., some pixel will be treated more than once if there are overlap /////////////////////////////////////////////////////////////////////////// for (int i = startIndex; i < startIndex + length; ++i) // all these are inside the loop // including the draw polygon part. { Rectangle rect = rois[i]; // Because I have to reset the destination every time // this is reeeeeaaaaallllly slow for (int y = rect.Top; y < rect.Bottom; y++) { for (int x = rect.Left; x < rect.Right; x++) { if (selectionRegion.IsVisible(x, y)) { dstArgs.Surface[x, y] = srcArgs.Surface[x, y]; } } } // including the drawline calls, polygon is drawn several times ........ } public void DrawLine(int x1, int y1, int x2, int y2, Surface dst, ColorBgra LineColor, PdnRegion selectionRegion) { ... } public override EffectConfigDialog CreateConfigDialog() { ... } public Polygones() : base(Strings.Polygones_Name, Resources.Polygones, Keys.None, null, EffectDirectives.None, true) { ... } } }
  10. Now here is a link on the rotation matrix http://mathworld.wolfram.com/RotationMatrix.html I am glad I have nothing wrongly explained. They express vector as a column vector and use right multiplication (matrix on left), I use row vector and left multiply the rotation matrix. Therefore the -sinx location is different. The idea lies in the fact that the new side can be acquired by rotating the last side. Moreover, it might be reasonable to draw the last side by connecting back to the first point. Otherwise, we might have an open at the end. One more idea to create the hollow star: use two circle with Radius R1 and Radius R2, n vertexes, offset by alpha. This can create a holly star. void render(x0,y0,R1,R2,alpha,beta,n) { // alpha, internal offset angle // beta, extenal offet angle // n, vertexes float aa = 2*pi/n; float cosaa2 = cos(aa/2), sinaa = sin(aa/2); float cosaaa = 1 - 2*sinaa2*sinaa2, sinaaa = 2*sinaa2*cosaa2; float cosa = cos(alpha), sina2 = sin(alpha); //alpha in rad float cosb = cos(beta), sinb = sin(beta); // this time we calculate the vertexes by vector from center to the vertex float vx1 = R1, vy1 = 0; float vx2 = R2*cosa2, vy2 = R2*sina2; // note that alpha is applied // apply the offset beta on both v1 and v2 float vxt = vx2, vyt = vy2; vx2 = vxt*cosb - vyt*sinb; vy2 = vxt*sinb + vyt*cosb; vxt = vx1; vyt = vy1; vx1 = vxt*cosb - vyt*sinb; vy1 = vxt*sinb + vyt*cosb; // temperory varible for illustration float x1, y1, x2, y2; x1 = x0 + vx1; y1 = x0 + vy1; x2 = x0 + vx2; y2 = y0 + vy2; // now we loop for (i=1; i { drawline((int)x1, (int)y1, (int)x2, (int)y2); // rotate vector v1 vxt = vx1; vyt = vy1; vx1 = vxt*cosb - vyt*sinb; vy1 = vxt*sinb + vyt*cosb; // draw another line x1 = x0 + vx1; y1 = x0 +vy1; drawline(x2,y2,x1,y1) // rotate vector v2 vxt = vx2; vyt = vy2; vx2 = vxt*cosb - vyt*sinb; vy2 = vxt*sinb + vyt*cosb; x2 = x0 + vx2; y2 = x0 +vy2; } } BTW, the idea to use the variable radius is good, the result is anstonishing. That might be something that vector can't be helpful.
  11. Hi, Madjik: I must agree that the idea lies in the polygon plugin is great. It might need no change if there is no more PII. My computer is not not PII, it runs opengl with no problem, but paint.net seems starting slow on it. Now because nearly every program is written in a way that requires more system resources, I really need a new computer for the tendency. To use the vector operation is just a suggestion. In most of 3D calculation, including optical ray tracing, vector operation is widely applied for the calculation efficiency. For your listed answers. 1. cos and sin might return double, but vector operation can be limited to float. 2. As I remember (it was long ago), cos x = 1 - x^2/2 + x^4/4! - x^6/6! + ....... sin x = x - x^3/3! + x^5/5! - ....... this might be how they are calculated, the math functions loop until the precision is reached. However, this is just my guess from the old knowledge and mathematics, things might change 3. Let me see if I can draw something and put it online, but it might easier to find a website or a book on the vectors and matrix. In optical tracing, refraction and reflection are calculated by vector operation, not the Trigonometric function. In 3D graphics, rotation matrix is a widely used tech to avoid intensive calculation by cos and sin. a 2D rotation matrix A is [cos(a) sin(a)] [-sin(a) cos(a)] a is the angle couterclockwise, in rad a vector means a directional line from one point (x,y) to another point (X,Y) note that it is same for the line from (0,0) to (X-x, Y-y), this means vector can be movable Rotation is implemented by matrix operation: *A for now I can only write a code for the operation in C to show the algorithm, it is not compiled render(x0, y0, n, k, R, offset) // x0, y0 : center cords // n number of vertex // k staris // offset rotation offset // R raduis { double a = 2*pi/n*k; float cosa = cos(a), sina = sin(a); float cosb = cos(offset), sinb = sin(offset); // now we calculate a side without offset. // imagine without offset, the first point is (x0+R, y0) // next point is (x0+R*cosa, y0+R*sina) // the coord difference gives the vector float vx1 = R*(cosa-1), vy1 = R*sina; // now rotate it by offset suppose it is in rad float vx2 = vx1*cosb - vy1*sinb, vy2 = vx1*sinb + vy1*cosb; // this stands for all the parallel lines with same length as the first side // we need to determine its starting point float x1 = x0 + R*cosb, y1 = y0 + R*cosb; // now we loop for (int i=1; i { // the next point can be calculated // two float/double addition here float x2 = x1 + vx2, y2 = y1 + vx2; // now draw the line drawline((int)x1, (int)y1, (int)x2,(int)y2) // update the starting point, rotate the side vector x1 = x2; y1 = y2; vx1 = vx2; vy1 =vy2; // two addition here, four multiplication here vx2 = vx1*cosb - vy1*sinb; vy2 = vx1*sinb + vy1*cosb; } } 4. My computer is PenIV. When I was in school and using opengl, the computer is PenII. The code transplanted from my computer to the school computer gets slow, one reason was the intensive cos and sin call. I'd like to write in C#, but as I said, I am new to it. I have the runtime v2 on this machine, but coding and debug will be slow. If you can help me on it (how to test it and maybe correct some syntax error), I will be glad to work with you. Or you can search the internet for vector and matrix operation or just borrow a book. It is quite easy. Other than use the vector for sides, we also use the vector starting from center and pointing to vertex render(x0, y0, n, k, R, offset) // x0, y0 : center cords // n number of vertex // k staris // offset rotation offset // R raduis { double a = 2*pi/n*k; float cosa = cos(a), sina = sin(a); float cosb = cos(offset), sinb = sin(offset); // now we calculate the vector from center to first vertex float vx1 = R*cosb, vy1 = R*sinb; // the vertex is float x1 = x0 + vx1, y1 = y0 + vy1; float vx2, vy2, x2, y2; // now we loop for (int i=1; i { // rotate the vector -- two add, four multiplication here vx2 = vx1*cosa - vy1*sina; vy2 = vx1*sina + vy1*cosa; //next vertex two more addition here x2 = x0 + vx2, y2 = y0 + vx2; // now draw the line drawline((int)x1, (int)y1, (int)x2,(int)y2) // update the starting point, rotate the side vector x1 = x2; y1 = y2; vx1 = vx2; vy1 =vy2; } } I modified madjik's code, don't know how to upload here or how to test it. Need help!
  12. Hi, I am new here. I am also new to the .net programming, but I can read it. What I want to suggest are: for staris parameter, it need only start from 1 to (int)((double)n/2 - 0.5), because staris = k and staris = n-k is same thing. For the computation efficiency, I think using vector and rotation is a faster way than call cos and sin all the times. For example, center point o, first point A, then vector oA is the Radius*(cos(offset), sin(offset)) where offset is the rotation I think. Calculate the angle AoB by anglestep = 2*pi/n, then create the 2D rotation matrix. The oB can be calculated by applying rotation on oA, which only need 4 double multiplications and 4 double additions (2 for add the o cord). Cos and sin will no longer be called every loop. Probably for today's computer there is no problem, however, I experience a significant slowing down when in one of my openGL projects transplanted to a pentium II computer. And I think this is not harmful.