Author Topic: Copper Star  (Read 3599 times)

0 Members and 1 Guest are viewing this topic.

Aaron

  • Guest
Copper Star
« on: March 07, 2014, 03:27:34 AM »
Hello,

rotates a star from pure copper.

Code: [Select]
include "gp.inc"
OpenWindow 640, 480, 1

SetSmoothMode 2
ClsColor ARGB(255,0,0,0)

sys d=40, c=10000
single ys=.15, a

while KeyDown(27)=0
ClsColor ARGB(255,0,0,0)

For x=-90, 90
For y=-90, 90
    Setpixel 300+sin(rad(a))*(x+y),250+ys*(y-x)*c/(x*x+y*y+d), 0xFFFFC0C0
Next
Next

a +=8
if a >=360 then a=-a
Redraw
wend
CloseWindow

Aaron

  • Guest
Re: Copper Star
« Reply #1 on: March 07, 2014, 07:53:33 AM »
Particles all over.

Code: [Select]
include "gp.inc"
OpenWindow 640,480,1

fo = LoadFont "verdana",24,1
string z= "HELLO AND WELCOME IN THE SUPER PROGRAMMING!", letter

sys x3DSterne[800]
sys y3DSterne[800]
sys z3DSterne[800]

sys fokus=160, xp, yp, i, tl, x
tl = len(z)
single y[44]
single angle[44]

For i=1 to tl
   angle[i] = 360-i*(360/tl)
   y[i] = 240
Next

For i=1 to 800
x3DSterne[i] = Rnd (1,440)
   y3DSterne[i] = Rnd (1,380)
   z3DSterne[i] = Rnd (1,500)
Next

While KeyDown(27)=0
ClsColor ARGB(25,0,0,0)
For i=1 to 800
   xp = (x3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 5
   yp = (y3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 5
   DrawPoint (xp,yp, 2, ARGB(255,255,255,255))

   xp = (-x3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 630
   yp = (-y3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 470
   DrawPoint(xp,yp, 2, ARGB(255,255,255,255))

   xp = (-x3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 630
   yp = ( y3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 8
   DrawPoint(xp,yp, 2, ARGB(255,255,255,255))

   xp = ( x3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 5
   yp = (-y3DSterne[i] * Fokus) / (z3DSterne[i] + Fokus) + 470
   DrawPoint xp,yp, 2, ARGB(255,255,255,255)

   z3DSterne[i] = z3DSterne[i] -1
   iF z3DSterne[i] <=0
      z3DSterne[i] = 500
   End iF
Next

For x=1 to tl
   angle[x] +=1
   if angle[x] = 360 then angle[x] =0
   letter = mid(z, x ,1)
   y[x] += sin(rad(angle(x)*4))
   DrawText fo,2+x*14, y(x), letter, 0xFFFF0000
   y[x] += cos(rad(angle(x)*2))
   DrawText fo,2+x*14, y(x), letter, 0xFF00FF00
Next

Sync
Wend
CloseWindow()

I get the feeling, I am not welcome here!

JRS

  • Guest
Re: Copper Star
« Reply #2 on: March 07, 2014, 09:05:00 AM »
Quote
I get the feeling, I am not welcome here!

What do you mean? You just got back. I'm happy you're here if that means anything.

Any chance you can fix the reverse coordinates for the fern example and convert the BBC graph demo? I want to try and add the animation to it that David Burnard did for his example.
« Last Edit: March 07, 2014, 09:19:46 AM by John »

Charles Pegge

  • Guest
Re: Copper Star
« Reply #3 on: March 07, 2014, 10:52:17 AM »

It's just a quiet day. Looking across several Basic forums, there's not much activity at present.

To Flip y, it is probably sufficient to subtract y from the window ysize and use this value for the y coordinate.

JRS

  • Guest
Re: Copper Star
« Reply #4 on: March 07, 2014, 11:25:38 AM »
Charles,

Code: [Select]
xy[2] = 500 - newy

This change creates a blank screen.


Aaron

  • Guest
Re: Copper Star
« Reply #5 on: March 07, 2014, 11:34:31 AM »
Quote
xy[2] = 500 - newy
  LOL!

Code: [Select]
SetPixel xy[1]*40+275, -xy[2]*40+450, ARGB(255,0,210,55)
SetPixel  -xy[1]*40+275 : change the fern side to left.

.
« Last Edit: March 07, 2014, 11:45:08 AM by Peter »

Charles Pegge

  • Guest
Re: Copper Star
« Reply #6 on: March 07, 2014, 11:41:03 AM »

Try tweaking some of the other values. You may find some useful mutations. - New botanical varieties.

Aaron

  • Guest
Re: Copper Star
« Reply #7 on: March 07, 2014, 11:47:24 AM »
I know, I am natural scientist.

JRS

  • Guest
Re: Copper Star
« Reply #8 on: March 07, 2014, 12:17:07 PM »
This worked for me. Thanks for the help straighting this out. (literally)



Code: [Select]
' ScriptBasic GFX - Fern

IMPORT gfx.inc

s = gfx::Window(640,500,"ScriptBasic GFX Fern")
RANDOMIZE(gfx::Time())

SPLITA STRING(3,"0") BY "" TO xy

Sub Fern
r = RND() % 100
IF r <= 10 THEN
   a = 0
   b = 0
   c = 0
   d = 0.16
   e = 0
   f = 0
ELSE IF r > 1 AND r <=86 THEN
   a = 0.85
   b = 0.04
   c = -.04
   d = 0.85
   e = 0
   f = 1.60
ELSE IF r > 86 AND r <=93 THEN
   a = 0.2
   b = -.26
   c = 0.23
   d = 0.22
   e = 0
   f = 0.16
ELSE
   a = -.15
   b = 0.28
   c = 0.26
   d = 0.24
   e = 0
   f = 0.44
END IF

newx = ((a * xy[1]) + (b * xy[2]) + e)
newy = ((c * xy[1]) + (d * xy[2]) + f)
xy[1] = newx
xy[2] = newy

gfx::pixelRGBA s, INT(xy[1]*40+300), INT(-xy[2]*40+450), 0, 210, 55, 255

END SUB

ts = gfx::Time()
FOR w=1 TO 100000
    Fern
NEXT
te = gfx::Time()
gfx::stringColor s, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff
gfx::Update
WHILE gfx::KeyName(1) <> "+escape"
WEND
gfx::Close

Aaron

  • Guest
Re: Copper Star
« Reply #9 on: March 07, 2014, 02:32:31 PM »
John,

BBC Graph demo.

I got a LOL result. The joke is, BBC screen has its centre in the middle.
All lines go back to 0,0 (centre), but we don't have 0,0 in the center.

It's something for OpenGl ! 

Code: [Select]
include "sw.inc"
Declare Function MoveToEx Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpPoint As Long) As Long
Declare Function LineTo   Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Window 800,600,1
hdc = GetHandleDC()

sys depth=12, c=4000, xscale=20, yscale=5, x ,y
sys xlow =-10, xhigh=10, ylow=-10, yhigh=10

For x=xlow, xhigh
    MoveToEx hdc,xscale*(x+ylow),yscale*(ylow-x)+c/(x*x+ylow*ylow+depth),0
For y=ylow, yhigh   
    LineTo hdc,400-xscale*(x+y),200-yscale*(y-x)+c/(x*x+y*y+depth)   
Next
Next

For y=ylow, yhigh
    MoveToEx hdc,xscale*(xlow+y),(yscale*xlow)+c/(xlow*xlow+y*y+depth),0
For x=xlow, xhigh
    LineTo hdc,400-xscale*(x+y),200-yscale*(y-x)+c/(x*x+y*y+depth)   
Next
Next

WaitKey
CloseWindow


JRS

  • Guest
Re: Copper Star
« Reply #10 on: March 07, 2014, 03:43:04 PM »
LOL!

I'm glad that worked for you. (almost) I don't have a MOVE function and the reason I asked if you could convert it to standard line draw functionality.

Does the attached look like what you are getting? I'm using the last sw.inc/dll I think you posted.



.
« Last Edit: March 07, 2014, 05:33:45 PM by John »

Aaron

  • Guest
Re: Copper Star
« Reply #11 on: March 08, 2014, 04:21:28 AM »
Yes, it as funny as yours.  ;D