C
C#•2mo ago
Dark0z7

So im a bit new to the C# Language but i have a project for drawing sth using drawline/drawellipse

so i need help adding the side fins like between those that are 90 degrees turned
No description
68 Replies
Dark0z7
Dark0z7•2mo ago
Dark0z7
Dark0z7•2mo ago
thats the code for the entire thing for now
Buddy
Buddy•2mo ago
Please use $paste
MODiX
MODiX•2mo ago
If your code is too long, you can post to https://paste.mod.gg/ and copy the link into chat for others to see your shared code!
Buddy
Buddy•2mo ago
On some devices you need to download a file to see the code
Dark0z7
Dark0z7•2mo ago
BlazeBin - mwkfxkepvkzw
A tool for sharing your source code with the world!
Dark0z7
Dark0z7•2mo ago
No description
Dark0z7
Dark0z7•2mo ago
this is the end result and i wanna make a gpu for the project im really bad at Drawing in C# ignore that i could use for cycle to make the pins on the pcie connector i just had nothing to do and wanted to play a bit ik a way but i have to use an arc and draw.Line but its difficult to me any ideas ? i can use arc but i find it difficult to make it with the right coordinates
Dark0z7
Dark0z7•2mo ago
is there a way to curve it 😭
No description
Pobiega
Pobiega•2mo ago
what exactly are you trying to draw? and also, instead of doing this with just straight up procedurally drawing each thing "by hand", why not use methods and some math? like, the two fans could just be DrawFan(x,y); twice with different values for the position etc
Dark0z7
Dark0z7•2mo ago
Graphics card i have to choose from a list
Pobiega
Pobiega•2mo ago
yeah I get that, but you are on a bout an arc and have pasted the exact same picture three times without the thing that you are trying to draw
Dark0z7
Dark0z7•2mo ago
mb
Dark0z7
Dark0z7•2mo ago
No description
Pobiega
Pobiega•2mo ago
okay, the diagonal blades of the fan
Dark0z7
Dark0z7•2mo ago
yeah i mean like how to draw them diagonally
leowest
leowest•2mo ago
Graphics have RotateTransform
Pobiega
Pobiega•2mo ago
it even has TranslateTransform.. omg this makes life so much easier 😄
leowest
leowest•2mo ago
yeah but u have to revert it after u use or it will apply to everything
Pobiega
Pobiega•2mo ago
sure, but thats just gr.ResetTransform(); surely?
leowest
leowest•2mo ago
No description
leowest
leowest•2mo ago
gr.RotateTransform(45.0F);
gr.DrawEllipse(pen, 500, 20, 60, 150);
gr.FillEllipse(brush, 500, 20, 60, 150);
gr.ResetTransform();
gr.RotateTransform(45.0F);
gr.DrawEllipse(pen, 500, 20, 60, 150);
gr.FillEllipse(brush, 500, 20, 60, 150);
gr.ResetTransform();
Pobiega
Pobiega•2mo ago
now apply that in a loop 8 times before resetting the transform..
leowest
leowest•2mo ago
u have to reposition too because rotate makes weird axis not sure if its just inverted or what didnt look into it further ah yeah there is ResetTransform () as well nice catch
Pobiega
Pobiega•2mo ago
No description
Pobiega
Pobiega•2mo ago
looks kinda cool 😄
Dark0z7
Dark0z7•2mo ago
ill try it later thanks ' i think it would look cooler if i make it bigger can u give code for this but make the heigh a bit more
Pobiega
Pobiega•2mo ago
bruh?
Dark0z7
Dark0z7•2mo ago
i may sound very dumb but in this im very confused like first time doing drawing and stuff aah i now read loop it
Pobiega
Pobiega•2mo ago
gr.FillRectangle(_darkGrayBrush, 50, 50, 1000, 450);
gr.DrawRectangle(_blackPen, 50, 50, 1000, 450);

DrawFan(gr, 150, 100);
DrawFan(gr, 600, 100);
gr.FillRectangle(_darkGrayBrush, 50, 50, 1000, 450);
gr.DrawRectangle(_blackPen, 50, 50, 1000, 450);

DrawFan(gr, 150, 100);
DrawFan(gr, 600, 100);
this is my code right now :p
Pobiega
Pobiega•2mo ago
No description
Pobiega
Pobiega•2mo ago
I leave the implementation of DrawFan as an exercise to the reader but it involves math to figure out how to position all the components relative to the given x/y coord (which is the top left corner of the outermost circle)
Buddy
Buddy•2mo ago
They basically gave you it here tbh
Dark0z7
Dark0z7•2mo ago
ive only studied the different draw figures and the main things like how do i implement it ( i know im dumb af ive never done any of this )
Pobiega
Pobiega•2mo ago
so uh do you know what a method is?
Dark0z7
Dark0z7•2mo ago
nah ive just learned how to create a graphical field / pens/brushes and how to clear the graphic field how to draw figures and the required values and stuff
Pobiega
Pobiega•2mo ago
thats a weird place to start learning C# tbh
Dark0z7
Dark0z7•2mo ago
no we started from the plain start just for the drawing things
Pobiega
Pobiega•2mo ago
and Im saying thats weird as hell the whole point of drawing with code is to not do it manually line by line its to use code to do it all for you. Like the PCIE connector on your card thats 3 lines of code and a loop
Dark0z7
Dark0z7•2mo ago
ik i had to use a loop for () { }
Pobiega
Pobiega•2mo ago
so why did you manually write 119 lines for it :p
Dark0z7
Dark0z7•2mo ago
didnt have what to do in my free time literally ;d the entire drawing thing is my project for the end of the school year and idk why my teacher made us do it based on drawing if it was a calculator or sth like this it would be much more simpler
Pobiega
Pobiega•2mo ago
I mean, if you apply coding to the drawing, thats fine too Im specifically against the "lets draw a thing by manually drawing each individual line" since you have two identical fans, we make our own method for drawing a fan then you implement that method ONCE and can now draw any number of fans you want
Dark0z7
Dark0z7•2mo ago
i dont know how to make a new drawing method like for example gr.drawcircle or sth like that instead of using the regular shapes
Pobiega
Pobiega•2mo ago
you dont look at my code again its not gr.DrawFan(...); its DrawFan(gr, ...) ive just added a new method to the form class
Pobiega
Pobiega•2mo ago
No description
Dark0z7
Dark0z7•2mo ago
ooooooooh i havent studied how to make private voids only protected override void OnPaint(PaintEventArgs e)
Pobiega
Pobiega•2mo ago
there is no such thing as a "private void" thats just a method and parts of the method signature is an access modifier (private here) and a return type (void here) so it goes accessModifier returnType Name(parameters, parameters, parameters...) { yourCodeGoesHere } thats a method
Dark0z7
Dark0z7•2mo ago
now i understand about the method im just so lost in this sphere
Buddy
Buddy•2mo ago
If you do something more than once, it's better to separate that code into it's own function and that goes for all languages
Dark0z7
Dark0z7•2mo ago
i suck at finding coordinates too i mean i will find them but it will take me alot of time any suggestions for better coordinating and knowing actually where to look if u understand me
Pobiega
Pobiega•2mo ago
how about adding some labels to print out the current location of your mouse? that way you can just put it where you want to draw something and check what coords its at.
Dark0z7
Dark0z7•2mo ago
so again after i create the method i type (name of the method)(gr, x,y);
Pobiega
Pobiega•2mo ago
MethodName(...); is how you "call" or "run" or "invoke" a method
Dark0z7
Dark0z7•2mo ago
yeah can u tell me how to make the x change in a loop i forgot about this i mean gr.DrawLine(int x , int y, int x , int y )
Pobiega
Pobiega•2mo ago
If you Google "for loop in C#" I'm sure you will get plenty of examples and explanations
Dark0z7
Dark0z7•2mo ago
and so for my code that i wrote how to loop this i mean for (int i = 1 ; i<=8;i++) { } and i put in the following line that u gave
leowest
leowest•2mo ago
being blunt I would strongly advise u to go thru these https://learn.microsoft.com/en-us/shows/csharp-fundamentals-for-absolute-beginners/ u will eventually need to understand it either way if u plan on using c#
Dark0z7
Dark0z7•2mo ago
@Pobiega can u explain me this only like i mean the coordinates
Dark0z7
Dark0z7•2mo ago
the coordinates work like that in c# right ?
No description
Dark0z7
Dark0z7•2mo ago
thats my problem rn like inverted or some stuff thats why i was so confused
Dark0z7
Dark0z7•2mo ago
did it now i have to fixate them
No description
leowest
leowest•2mo ago
unhappily I dont have the time right now to figure it out, all I can tell is that u would need to figure out the axis or something for the transformed angle so u can use normal coordinates there is TranslateTransform so u could set the x and y from it instead of the ellipse regardless for each item in hte loop u need to calculate the position
Pobiega
Pobiega•2mo ago
What I did was translate to the center, then rotate 45 Deg for each blade Then reset transform But I'm in bed now
Dark0z7
Dark0z7•2mo ago
i have deadline till 4 june to figure it out and make the gpu another way is to stay up to 5 am studying the scale xd
Dark0z7
Dark0z7•2mo ago
chat gpt cooking
No description
Dark0z7
Dark0z7•2mo ago
can i make it with a closedCurve ?
Dark0z7
Dark0z7•2mo ago
i have to loop it and im done i think
No description
No description