Qbasicnews.com

QbasicNews.Com => Challenges => Topic started by: Rattrapmax6 on March 16, 2005, 12:45:17 AM



Title: PSET Circle!
Post by: Rattrapmax6 on March 16, 2005, 12:45:17 AM
Okay, a simple game that shouldn't take but 5mins of your time.

Object: Make a circle using PSET
RULES:

1. Ten lines or under to be fair... (Can be done in six :wink: )
2. No use of colins " : " <- those
3. Any radius you want if its in the screen
4. Must be round if that makes since..
5. Only one PSET can be used..
6. QB or FB, just note on which, or use the matching Syntax tag.

Get all that? Now try it.. :D .. Good luck!


Title: PSET Circle!
Post by: Diroga on March 16, 2005, 03:36:52 AM
Code:
CLS
SCREEN 13
rad = (3.14159265#) / 180
FOR i = 1 TO 361 STEP .5
oldx = x: oldy = y
x = INT(50 * (COS(rad * i))) + 160
y = INT(50 * (SIN(rad * i))) + 100
PSET (x, y), 15
NEXT


Title: PSET Circle!
Post by: Dr_Davenstein on March 16, 2005, 05:54:52 AM
OK, why not?  :P

Code:

Screen 18, 32
Do While InKey$=""
   Y=(Y+1)Mod 480
   For X = 0 to 639
     If ABS(SQR((320-X)^2 + (240-Y)^2))<= 255 then PSet(X,Y),RGB(0,0,255-ABS(SQR((320-X)^2 + (240-Y)^2)))
   Next
Loop


Title: PSET Circle!
Post by: xteraco on March 16, 2005, 06:14:54 AM
here's mine


Code:

screen 13
dim as integer x, y, xmov, ymov
dim as double angle
x = 25 : y = 25
do : angle = angle + .01
   xmov = x * sin(angle) + y * cos(angle)
   ymov = y * sin(angle) - y * cos(angle)
pset (xmov + 160,ymov + 100),4 : loop


yay, its a circle  :bounce:

ah crap... no colons, well, i guess its back to the drawing board


Title: PSET Circle!
Post by: xteraco on March 16, 2005, 06:20:41 AM
and w/ a little more work (3 minits) i've came up w/ the answer

Code:

screen 13
dim as integer xmov,ymov,angle
do
   angle = angle + 1
   xmov = 25 * sin(angle) + 25 * cos(angle)
   ymov = 25 * sin(angle) - 25 * cos(angle)
   pset (xmov + 160,ymov + 100),4
loop


does that qualify.... i win! :bounce:
uh, make this official freebasic submission


Title: PSET Circle!
Post by: xteraco on March 16, 2005, 06:35:38 AM
ah, and here's my qbasic version

Code:

screen 13
for i = 1 to 360
xmov = 25 * sin(i) + 25 * cos(i)
ymov = 25 * sin(i) - 25 * cos(i)
pset (xmov + 160,ymov + 100),4
next


so, make it official, this is my qbasic submission


Title: PSET Circle!
Post by: Sterling Christensen on March 16, 2005, 06:37:21 AM
Code:
SCREEN 13
PSET STEP(0, 0), 15

Sure the pixel may be square, but it's the best approximation possible of a circle with radius 0.5 pixels. :bounce:


Title: PSET Circle!
Post by: xteraco on March 16, 2005, 06:41:59 AM
well, Sterling beat me :normal:


Title: Re: PSET Circle!
Post by: KiZ on March 16, 2005, 01:13:48 PM
Quote from: "rattrapmax6"
(Can be done in six :wink: )


Six? Six is for noobs :D j/k

Code:
SCREEN 13
FOR i = 1 TO 360
  PSET (SIN(i * 3.14 / 180) * 30 + 160, COS(i * 3.14 / 180) * 30 + 100)
NEXT


Title: PSET Circle!
Post by: Meg on March 16, 2005, 01:38:14 PM
3 lines:
[syntax="QBASIC"]FOR i! = -.5 TO 360 STEP .5
     IF i! = -.5 THEN SCREEN 13 ELSE PSET (160 + COS(i! * 3.14 / 180) * 50, 100 + SIN(i! * 3.14 / 180) * 50), 15
NEXT i![/syntax]


Title: PSET Circle!
Post by: Neo on March 16, 2005, 01:55:51 PM
3 lines, using another algorithm:

[syntax="QBASIC"]FOR I! = -0.5 TO 199.5 STEP .5
   IF I! = -0.5 THEN SCREEN 13 ELSE PSET (((INT(I!) = I!) * 2 + 1) * SQR(10000 - (INT(I!) - 100) ^2) + 160, INT(I!) * 0.75), 15
NEXT I![/syntax]

Doesn't draw the circle completely, in this case it needs some more code to optimize this block, but it draws the outlines which can be connected with line or by enhancing the above code.
Advantage of this x = SQR(r^2-y^2) algorithm is that it's faster and doesn't require large loops.

In these kind of challenges it's impossible to draw a full connected circle, because if you zoom in on the circles made with the COS/SIN algorithm you'll see the same as the algorithm above displays.


Title: PSET Circle!
Post by: Rattrapmax6 on March 16, 2005, 02:11:34 PM
:o Heh, 3 lines, I never thought of stuffing it like that,. oh well,. here was mine:

[syntax="qbasic"]SCREEN 13
FOR a = 1 TO 360
x = 20 * COS(a * 3.14159265# / 180)
y = 20 * SIN(a * 3.14159265# / 180)
PSET (160 + x, 100 - y), a
NEXT[/syntax]

I wasn't planning to have a winner (more just a challange, all under 10 lines won), but Meg deserves to gets the highest points! 3 lines, *walks off scratching head*... :)


Title: PSET Circle!
Post by: Meg on March 16, 2005, 04:47:58 PM
Meh.  My entry doesn't deserve any special mention, really.  In order to cram it into three lines, I had to remove a lot of clarity.  I'd never actually write it like that for a porgram.

The idea for using a loop and a IF THEN ELSE IF ... ELSE line isn't even mine.  I first came across it in the screensaver challenges, I think.  Might have been Relsoft's, or somebody else's idea.

Basically, the first few solutions all do exactly the same thing.. calculate X and Y based on trig functions from an angle converted to radians, then PSET at (x,y).  I'm not sure what Neo's does, but it looks like he's using the formula for a circle to plot the points instead of SIN and COS.

*peace*

Meg.


Title: PSET Circle!
Post by: Rattrapmax6 on March 16, 2005, 06:07:45 PM
Quote from: "Dr_Davenstein"
OK, why not?  :P

Code:

Screen 18, 32
Do While InKey$=""
   Y=(Y+1)Mod 480
   For X = 0 to 639
     If ABS(SQR((320-X)^2 + (240-Y)^2))<= 255 then PSet(X,Y),RGB(0,0,255-ABS(SQR((320-X)^2 + (240-Y)^2)))
   Next
Loop


 :o AHH!!! A BIG BLUE BLOB!!!!  :lol:

Thats pretty cool!! :rotfl:  :wink:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 16, 2005, 06:54:38 PM
heh, its FB...

I think Sterling won.
[/code]


Title: PSET Circle!
Post by: Sterling Christensen on March 16, 2005, 07:00:02 PM
Quote from: "Mitth'raw'nuruodo"
I think Sterling won.

Lol, I was just joking. I don't think my submission counts, it's only valid on a technicality. He would have specified a minimum readius had it occured to him to.


Title: PSET Circle!
Post by: Rattrapmax6 on March 16, 2005, 07:02:12 PM
Quote from: "Mitth'raw'nuruodo"
heh, its FB...

I think Sterling won.
[/code]


Oh yeah, heh, nice try, but I said it had to be round, thats a small square.. :wink:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 16, 2005, 07:04:02 PM
Ah, but it's a point. And isn't a point round?

Just cause the computer gives him a handicap on its res..... :lol:


Title: PSET Circle!
Post by: Diroga on March 17, 2005, 04:33:40 AM
does any one under stand the math behind the circle? just checking


Title: PSET Circle!
Post by: Neo on March 17, 2005, 06:09:02 AM
What a question... of course :P

The math behind an ellipse is very simple.
For an ellipse:
    (x / c) ^ 2 + (y / d) ^ 2 = r ^ 2

For a filled ellipse:
    (x / c) ^ 2 + (y / d) ^ 2 <= r ^ 2

For a negative ellipse:
    (x / c) ^ 2 + (y / d) ^ 2 > r ^ 2


That is the mathematical algebraic description of an ellipse (a circle has c = d = 1). A circle can also be written as a function of polar or parametric variables.
Polar form:
    r = const

Parametric:
    x = cos(tetha) * r
    y = sin(tetha) * r

In both forms tetha ranging from 0 to 2 * PI.

Rotated ellipses are easier to make using the parametric form, although for both the function and parametric form a rotation formula can be used.

;)

~~~~~


Title: PSET Circle!
Post by: KiZ on March 17, 2005, 06:47:38 AM
Quote from: "Diroga"
does any one under stand the math behind the circle? just checking


*frowns at diroga*

Yes, I do.

Quote from: "Neo"
tetha


Dont you mean Theta ;)


Title: PSET Circle!
Post by: xteraco on March 17, 2005, 09:55:07 AM
whats math? :bounce:  no really, i do


Title: PSET Circle!
Post by: Neo on March 17, 2005, 02:22:26 PM
Quote from: "dark_prevail"
Quote from: "Neo"
tetha


Dont you mean Theta ;)

Oooooops :oops: Of course, Theta is English ;) lol I just talked Dutch... tetha... lol


Title: PSET Circle!
Post by: Eurodance on March 17, 2005, 04:27:08 PM
Code:
PSET (100, 100), 15

Isn't it a circle?  :lol:  :D  :lol:  :D  :P


Title: Fu program
Post by: Meg on March 17, 2005, 05:36:44 PM
This obviously isn't an entry for this challenge, but it's a fun program nonetheless. ^_^

*peace*

Meg

[syntax="QBASIC"]
'THIS PROGRAM MAKES USE OF THE CROSSCIRCLE SUB TO DISPLAY CIRCLES WITH LINES
'CUTTING ACROSS THEM AT PRESET NODE POINTS.
'                                                  - Written 03/17/2005 by mb

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'SUB DECLARATIONS
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
DECLARE SUB CrossCircle (x!, y!, r!, c%, n%, o!)

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'CHANGE TO GRAPHICS MODE 320x200
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
SCREEN 13
CLS

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'ROTATE A 10-NODE, 40-RADIUS CIRCLE IN THE CENTER OF THE SCREEN
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
offset! = 0
DO
     offset! = offset! + .01
     CrossCircle 160, 100, 40, 15, 10, offset!
     WAIT &H3DA, 8
     WAIT &H3DA, 8, 8
     CrossCircle 160, 100, 40, 0, 10, offset!
LOOP UNTIL INKEY$ <> ""

SYSTEM

SUB CrossCircle (x!, y!, r!, c%, n%, o!)

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'THIS SUB DRAWS NODES AROUND A CIRCLE AND CONNECTS THEM WITH LINES
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'x! = x-coordinate of circle
'y! = y-coordinate of circle
'r! = radius of circle
'c% = color of circle
'n% = number of nodes in circle
'o! = offset of first node in radians

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'MAKE OUR NODE COORDINATE ARRAYS
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
REDIM nodeX!(1 TO n%)
REDIM nodeY!(1 TO n%)

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'STARTING AT OFFSET o!, CREATE EVENLY SPACED NODES AROUND THE CIRCLE
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
NodeDist! = (2 * 3.14159) / n%
NodeCurr! = o!
FOR i% = 1 TO n%
     nodeX!(i%) = x! + COS(NodeCurr!) * r!
     nodeY!(i%) = y! - SIN(NodeCurr!) * r!
     NodeCurr! = NodeCurr! + NodeDist!
NEXT i%

'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
'CONNECT THE NODES TO EACH OTHER WITH LINES
'@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
FOR i% = 1 TO n% - 1
FOR j% = i% + 1 TO n%
     LINE (nodeX!(i%), nodeY!(i%))-(nodeX!(j%), nodeY!(j%)), c%
NEXT j%, i%

END SUB
[/syntax]


Title: PSET Circle!
Post by: Rattrapmax6 on March 17, 2005, 06:27:58 PM
Quote from: "Diroga"
does any one under stand the math behind the circle? just checking


Knows it here,..  :wink: ... do you?

Quote from: "Meg"
This obviously isn't an entry for this challenge, but it's a fun program nonetheless. ^_^

*peace*

Meg


Wow, thats cool!! :bounce:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 18, 2005, 05:19:07 PM
Wow, that was great!

lol try doing it at 160, 100, 200, 15, 25, offset!!!!! Ha lol :lol:
(FYI that rotates a 200 radius circle at the center of the screen, color 15, AND 25 nodes!) :P

Oh ya I do too (understand the math behind it). I had to learn all that stuff when I learned 3D in QB. :D


Title: PSET Circle!
Post by: Dio on March 18, 2005, 05:49:20 PM
i was messin' around with Diroga's entry just for fun and i made this:
[syntax="qbasic"]CLS
SCREEN 13
rad = (3.14159265#) / 180
c = 16
z = 76
SLEEP
FOR ii = 1 TO 75
z = z - 1
FOR i = 1 TO 361 STEP .5
oldx = x: oldy = y
x = INT(z * (COS(rad * i))) + 160
y = INT(z * (SIN(rad * i))) + 100
c = c + 1: IF c > 31 THEN c = 16
PSET (x, y), c
NEXT
NEXT[/syntax]


Title: PSET Circle!
Post by: Rattrapmax6 on March 18, 2005, 07:59:27 PM
:) Heh, okay, try this one, deff not for the comp, just for the eye:

[syntax="QBasic"]SCREEN 13
FOR a = 1 TO 360
x = a * COS(a * 3.14159265# / 180)
y = 20 * SIN(a * 3.14159265# / 180)
LINE (160, 100)-(160 + x, 100 - y), a
NEXT[/syntax]

 :rotfl:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 25, 2005, 01:27:00 AM
Hey guess what? I was messing around with Dio's entry...hehe...oh no you say? Well, when I mess around with graphics, its more of a change here and see what happends :lol: ....well this was a little better than that...more math...not what I wanted it to do, but it looks cool:

[syntax="qbasic"]
CLS
SCREEN 13
rad = (3.14159265#) / 180
c = 16
z = 76
offset = 0
DO
offset = offset + 1
ci = (ci + 5) MOD 255
c = 16
z = 76
FOR ii = 1 TO 150
z = z - 1
FOR i = 1 TO 361 STEP .5
oldx = x: oldy = y
d = (i + offset) MOD 360
x = INT(z * (COS(rad * d))) + 160
y = INT(z * (SIN(rad * d))) + 100
c = c + 1: IF c > ci THEN c = 16
PSET (x, y), c
NEXT
NEXT
LOOP
[/syntax]


Title: PSET Circle!
Post by: Diroga on March 25, 2005, 01:55:42 AM
VERY NICE. how did you come up wiht that? the patterns are great


Title: PSET Circle!
Post by: Rattrapmax6 on March 26, 2005, 12:45:11 PM
:) Thats cool Mitth,. tho it took me awhile to wait for it to work.. :wink:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 26, 2005, 01:04:13 PM
Accually it was working Rattra, but it was drawing color# 000000  :lol: .

Umm. I was originally trying to rotate Diroga's one by adding an increasing number to the degrees already there each Do loop. But someting happened and it didn't work.

So then I left it there and played with the color max. I then noticed how each number gave a different pattern. So then I just increase that value in the DO:loop.

So that's how I did it. :D


Title: PSET Circle!
Post by: Rattrapmax6 on March 26, 2005, 01:08:19 PM
<-- How you like that PSET circle? its what happens when a single pixel is rocketing around 3D cords at 6600+ FPS and shading with RGB(z!, z!, z!)..

 :rotfl:  :bounce:  :rotfl:  :bounce:  :rotfl:

\/ \/ Click down there \/ \/


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 26, 2005, 01:26:56 PM
Love the avatar!


Title: PSET Circle!
Post by: Rattrapmax6 on March 26, 2005, 01:36:30 PM
:D Made it with FB,... :wink: .... :roll:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 26, 2005, 01:39:09 PM
Oh, I know QB can't handle 500000fps.  :lol:


Title: PSET Circle!
Post by: Rattrapmax6 on March 26, 2005, 01:40:38 PM
:o No, it would fry! oh no!! :rotfl:  :wink:


Title: PSET Circle!
Post by: Mitth'raw'nuruodo on March 26, 2005, 01:43:52 PM
Just like that artoo pic, eh? BOOM!  :lol:


Title: Circle without using cos,sin,sqr,*,/
Post by: Quibbler on May 24, 2005, 09:56:08 AM
Its a little long and includes : But there's no cos,sin,sqr,* or / just + and -. the fisrt line y=180 changes the radius xoff and yoff move it around the screen.

Code:
SCREEN 12
y = 180: xoff = 280: yoff = 200: x = -1
WHILE x < y
x = x + 1: d = d + x + x + 1
IF d > 0 THEN d = d - y - y + 1: y = y - 1
FOR k = 0 TO 7
IF k AND 4 THEN a = -x ELSE a = x
IF k AND 2 THEN b = -y ELSE b = y
IF k AND 1 THEN SWAP a, b
PSET (a + xoff, b + yoff)
NEXT k
WEND


Title: PSET Circle!
Post by: Nathan1993 on August 19, 2005, 03:31:13 PM
Ahh... here is my version. 2 lines!

Code:
'$include: 'rellib.bi'
relcircle VIDEO, 100, 100, 10


I beet you all!


Title: PSET Circle!
Post by: Anonymous on August 19, 2005, 03:55:18 PM
you beet the fuk out of use in spelleng,  two

lol


Title: PSET Circle!
Post by: Neo on August 19, 2005, 04:25:32 PM
Quote from: "Nathan1993"
Ahh... here is my version. 2 lines!
Code:
'$include: 'rellib.bi'
relcircle VIDEO, 100, 100, 10

I beet you all!


If you want to play lame... here's my circle:
Code:

It's too big to display on screen, but it is there.


Title: PSET Circle!
Post by: Rattrapmax6 on August 19, 2005, 04:52:13 PM
Quote from: "Nathan1993"
Ahh... here is my version. 2 lines!

Code:
'$include: 'rellib.bi'
relcircle VIDEO, 100, 100, 10


I beet you all!


*Ahem*... Its a PSET Circle... You seem to have forgot the PSET....

Sorry.... just felt like huge letters...  :P


Title: PSET Circle!
Post by: Dio on August 19, 2005, 04:55:54 PM
holy shit, talk about digging up an old post.


























BUMP


Title: PSET Circle!
Post by: Rattrapmax6 on August 19, 2005, 06:44:52 PM
More like "Talk about being bored",.. this thing had to be about 2,.. 3 pages back... unless he used search, or was reading over past articles of QBE and fond Pete's news article... either way...  :P


Title: PSET Circle!
Post by: Ralph on August 29, 2005, 02:02:37 PM
I vote for Dark_Prevail's solution, but only if married to Meg's, thus:

Code:
FOR i = 0 TO 360
   IF(i = 0 THEN screen 13 ELSE PSET (SIN(3.14*I / 180) * 30 + 160, COS(3.14*i / 180) * 30 + 100)
NEXT


Title: PSET Circle!
Post by: dumbledore on August 29, 2005, 04:04:19 PM
Quote from: "Dr_Davenstein"
OK, why not?  :P

Code:

Screen 18, 32
Do While InKey$=""
   Y=(Y+1)Mod 480
   For X = 0 to 639
     If ABS(SQR((320-X)^2 + (240-Y)^2))<= 255 then PSet(X,Y),RGB(0,0,255-ABS(SQR((320-X)^2 + (240-Y)^2)))
   Next
Loop

how about this?  :lol:
Code:
For I = -1 to 479 * 639
    If I = -1 Then Screen 18, 32 Else If ABS(SQR((320-(I MOD 640))^2 + (240-(I\640))^2))<= 255 then PSet((I MOD 640),(I\640)),RGB(0,0,255-ABS(SQR((320-(I MOD 640))^2 + (240-(I\640))^2)))
Next
Sleep


Title: PSET Circle!
Post by: Dr_Davenstein on August 29, 2005, 06:43:11 PM
Wow, that's the coolest thing I've ever seen!


:rotfl:


Title: PSET Circle!
Post by: Dio on August 29, 2005, 07:50:30 PM
i made something like that. and it took alot more lines of code to do it. (about 900% more. and i was so proud of myself. hmm...)

but yeah, really cool! :)=b


Title: PSET Circle!
Post by: Rattrapmax6 on August 29, 2005, 07:52:17 PM
:lol: I ment to tell ya,.. that was more of a PSET Sphere...  :rotfl: ... but its round, so, who cares...  :lol:


Funny how this lil challenge is still going.....  :roll:  :lol:


Title: PSET Circle!
Post by: Deleter on August 29, 2005, 07:58:51 PM
Quote from: "Rattrapmax6"
Funny how this lil challenge is still going.....  :roll:  :lol:

you never declared a winner, made a voting post of any kind, nor did you seta date. so of course its still going. :D


Title: PSET Circle!
Post by: Dr_Davenstein on August 29, 2005, 08:43:06 PM
Quote from: "Dio"
i made something like that. and it took alot more lines of code to do it. (about 900% more. and i was so proud of myself. hmm...)

but yeah, really cool! :)=b


Did you get the joke though?  :lol:


Title: PSET Circle!
Post by: Rattrapmax6 on August 29, 2005, 08:52:43 PM
Quote from: "Deleter"
Quote from: "Rattrapmax6"
Funny how this lil challenge is still going.....  :roll:  :lol:

you never declared a winner, made a voting post of any kind, nor did you seta date. so of course its still going. :D


Evil plan... but it works well don't it? Muhahahahaha!!!  :rotfl:


Title: PSET Circle!
Post by: dumbledore on August 30, 2005, 02:15:40 AM
ok, here's one i wrote meself:
[syntax="qbasic"]For i = -1 To 639 * 399
    If i = -1 Then Screen 13 Else Pset( i Mod 639, i \ 639 ), -( Int( Sqr( ( 160 - ( i Mod 639 ) ) ^ 2 + ( 100 - ( i \ 639 ) ) ^ 2 ) ) = 50 ) * 15
Next[/syntax]
and in fb
[syntax="freebasic"]For i = -1 To 639 * 399
    If i = -1 Then Screen 13 Else If Pset( i Mod 639, i \ 639 ), -( Int( Sqr( ( 160 - ( i Mod 639 ) ) ^ 2 + ( 100 - ( i \ 639 ) ) ^ 2 ) ) = 50 ) * 15 Else Sleep
Next[/syntax]


Title: PSET Circle!
Post by: Rattrapmax6 on August 30, 2005, 11:29:34 AM
You could have made the FB one 3 lines also..  :lol:

Code:
For i = -1 To 639 * 399
    If i = -1 Then Screen 13 Else if i <> (639 * 399) THEN Pset( i Mod 639, i \ 639 ), -( Int( Sqr( ( 160 - ( i Mod 639 ) ) ^ 2 + ( 100 - ( i \ 639 ) ) ^ 2 ) ) = 50 ) * 15 else sleep
Next


 :P


Title: PSET Circle!
Post by: dumbledore on August 30, 2005, 04:49:13 PM
thx  :lol:


Title: PSET Circle!
Post by: axipher on December 12, 2005, 11:45:43 PM
I know I am digging up this old topic, but I need you PSET Circle making Guru's help, can you make a working circle drawer that you can set limits in like drawing a circle at points (1,1) to (16,16), and the circle not be drawn outside that area???


Title: PSET Circle!
Post by: Deleter on December 13, 2005, 01:21:31 AM
well, you can find the radius within that and then use a normal circle command.
radius in that would equal half the shorter side of your confining box, obviously placed in the middle.


Title: PSET Circle!
Post by: Nemesis on December 13, 2005, 02:33:49 AM
Heh, I remember this topic from a few months back, it was kinda cool
so I mucked around with the original posters code and came up with this...
Code:

'$DYNAMIC
DEFINT A-Z
SCREEN 13
CLS
DIM V(32001)
r# = ATN(1 / 4)
V(0) = 2560
V(1) = 200
DEF SEG = VARSEG(V(0))
DO
 h = (h + 1) MOD 255
 c = h
 z = 75
 FOR ii = 1 TO 150
  z = z - 1
  FOR i = 1 TO 360
   d = i MOD 360
   x = INT(z * (COS(r# * d))) + 159
   y = INT(z * (SIN(r# * d))) + 99
   c = c + 1
   IF c > h THEN c = c - h
   IF c >= 32767 THEN c = -32768
   POKE (4 + (x + (y * 320&))), c
  NEXT
 NEXT
 '
 PUT (0, 0), V(0), PSET
 '
 p& = p& + 1
 LOCATE 1, 1: PRINT p&; "      "
 '
LOOP UNTIL LEN(INKEY$)


Ummm.... sorry this wasn't the real cool one I did (can't find it :(
but, this one still produces some nice patterns.
(I think they repeat after 255 but, it will run a long time.)

Cya,

Nemesis


Title: PSET Circle!
Post by: Xerol on December 13, 2005, 03:56:32 AM
I made mine into a function. The actual functional code is only the 3 lines in the loop:

Code:
screen 12

declare sub psetcircle(x, y, r, c)

for r = 1 to 200 step 1
    psetcircle 320, 240, r, (r mod 15) + 1
next r

sleep


sub psetcircle(x,y,r,c)
    dim o as double
    for o = 0 to 360 step 30/r
        pset(cos(o*3.141592/180)*r+x, sin(o*3.141592/180)*r+y), c
    next o
end sub

(FB)


Title: Breshenham algorithm
Post by: googly on December 13, 2005, 10:29:22 AM
looking at these progs (endless ones all the same) it's like the Bresenham algorithm had never been discovered. Look it up its quick and always using the max screen resolution available.


Title: PSET Circle!
Post by: axipher on December 13, 2005, 12:16:00 PM
I have a copy of the Bresenham algorithm but I can't figure out how to put limits into it, here is the area of the drawing area: (40,2) to (55,17), the circle can range in size from 1 - 24 and color can range from 0 - 255 and having an option to fill or not fill would be nice too.  The circle is base on user input and is drawn relative to the relative position being (x%,y%).


Title: Re: Breshenham algorithm
Post by: Dr_Davenstein on December 13, 2005, 06:41:48 PM
Quote from: "googly"
looking at these progs (endless ones all the same) it's like the Bresenham algorithm had never been discovered. Look it up its quick and always using the max screen resolution available.



Way too easy. The point was to make something unique. ;)


btw: Screen resolution has nothing to do with any Bresenham algo, ya know?  :lol:


Title: PSET Circle!
Post by: axipher on December 13, 2005, 11:16:32 PM
What about my problem... *sniffle* *sniffle*, lol, maybe that's what Z!re meant when he said that I was self-absorbant, but it's not like I am pushing anyone right???


Title: PSET Circle!
Post by: Dr_Davenstein on December 13, 2005, 11:22:44 PM
Give it a try first, and people will be more enthused about helping you. ;)


Title: PSET Circle!
Post by: axipher on December 13, 2005, 11:40:57 PM
Here's my try at it:

http://forum.qbasicnews.com/viewtopic.php?p=128335#128335