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
68 Replies
thats the code for the entire thing for now
Please use $paste
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!
On some devices you need to download a file to see the code
BlazeBin - mwkfxkepvkzw
A tool for sharing your source code with the world!
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
is there a way to curve it ðŸ˜
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
etcGraphics card
i have to choose from a list
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
mb
okay, the diagonal blades of the fan
yeah
i mean like how to draw them diagonally
Graphics have RotateTransform
it even has TranslateTransform.. omg this makes life so much easier 😄
yeah but u have to revert it after u use or it will apply to everything
sure, but thats just
gr.ResetTransform();
surely?now apply that in a loop 8 times
before resetting the transform..
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
looks kinda cool 😄
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
bruh?
i may sound very dumb but in this im very confused like first time doing drawing and stuff
aah i now read loop it
this is my code right now :p
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)They basically gave you it here tbh
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 )
so uh
do you know what a method is?
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
thats a weird place to start learning C# tbh
no we started from the plain start just for the drawing things
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
ik i had to use a loop
for () {
}
so why did you manually write 119 lines for it :p
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
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
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
you dont
look at my code again
its not
gr.DrawFan(...);
its DrawFan(gr, ...)
ive just added a new method to the form classooooooooh
i havent studied how to make private voids only
protected override void OnPaint(PaintEventArgs e)
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 methodnow i understand about the method
im just so lost in this sphere
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
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
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.
so again
after i create the method
i type (name of the method)(gr, x,y);
MethodName(...);
is how you "call" or "run" or "invoke" a methodyeah
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 )
If you Google "for loop in C#" I'm sure you will get plenty of examples and explanations
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
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#
@Pobiega can u explain me this only like i mean the coordinates
the coordinates work like that in c# right ?
thats my problem rn like inverted or some stuff
thats why i was so confused
did it now i have to fixate them
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
What I did was translate to the center, then rotate 45 Deg for each blade
Then reset transform
But I'm in bed now
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
chat gpt cooking
can i make it with a closedCurve ?
i have to loop it and im done i think