October 29, 2020, 02:43:31 AM

### Author Topic: Text Rotation Fun!  (Read 515 times)

#### bplus

• Full Member
• Posts: 146
##### Text Rotation Fun!
« on: November 05, 2019, 02:48:40 AM »
Plasma updated:
Code: [Select]
`' Text Rotation fun 2.bas SmallBASIC 0.12.13 (B+=MGA) 2019-11-04'text rotation fun.bas for SmallBASIC 0.12.11 (B+=MGA) 2017-02-02' more spectacular plasma color please'global variablesmessage = "SmallBASIC is fun!"secWide = txtw(message) + 2secHigh = txth(message) + 2dim sect(secWide, secHigh) 'array to store message pointscolor rgb(200, 200, 200),0 : clsrect 0, 0, secWide, secHigh, 9? messageloadSect 0, 0 'load array'debug checks'for y = 0 to secHigh'  for x = 0 to secWide'    if sect(x, y) then pset x + 200, y + 200'  next'next'input "OK ";okdim plasma(5, 3)clsgosub resetPlasmacx = xmax/2 : cy = ymax/2while 1  cls  dpi = 0  yaxis cx, cy/4, a, 4  dpi = 1  xaxis cx, 3*cy/4, a, 7  dpi = 2  rotate cx/2, cy, a, 3  dpi = 3  rotate 3*cx/2, cy, a -90, 4.5  dpi = 4  rotate cx, cy/2, -4*a + 90, 4  dpi = 5  rotate cx, 3*cy/2, 2*a + 180, 6.5  showpage  delay 10  a = a + 1  if a = 360 then a = 0wendpauseendlabel resetPlasmafor i = 0 to 5  plasma(i, 0) = rnd ^ 2  plasma(i, 1) = rnd ^ 2  plasma(i, 2) = rnd ^ 2  plasma(i, 3) = 1nextreturnsub dp(i)  plasma(i, 3) = plasma(i, 3) + .1  color rgb(128 + 127*sin(plasma(i,0)*plasma(i,3)), 128 + 127*sin(plasma(i, 1)*plasma(i, 3)), 128 + 127*sin(plasma(i, 2)*plasma(i, 3)))end sub loadSect(xstart, ystart)  local x, y, p, black  'these are all global  black = rgb(100 ,100, 100)  for y = 0 to secHigh    for x = 0 to secWide      p = POINT(xstart + x, ystart + y)      if p < black then sect(x, y) = 1 '<== data from screen points    next  nextendsub rotate(cx, cy, angle, scale) 'and scale  local cax, cay, ra, cc, d, anew, ax,ay  cax = secWide/2 : cay = secHigh/2  'array center  for y = 0 to secHigh    for x = 0 to secWide      cc = sect(x,y)      if (x-cax) <> 0  and cc <> 0 then        d = ((x-cax)^2+(y-cay)^2)^.5        anew = atan((y-cay)/(x-cax))        if x-cax <  0 and y-cay  < 0 then anew = anew + pi+rad(angle)  '-x,-y        if x-cax <  0 and y-cay >= 0 then anew = anew + pi+rad(angle) '-x,+y        if x-cax >= 0 and y-cay  < 0 then anew = anew + rad(angle)    '+x,-y        if x-cax >= 0 and y-cay >= 0 then anew = anew + rad(angle)   '+x,+y        ax = d*cos(anew):ay=d*sin(anew)        dp dpi        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled      end if    next  nextendsub yaxis(cx, cy, angle, scale)   local cax, cay, cc, ax,ay  cax = secWide/2 : cay = secHigh/2  'array center  for y = 0 to secHigh    for x = 0 to secWide      cc = sect(x,y)      if cc <> 0 then        ax = (x - cax)*cos(rad(angle)):ay= (y - cay)        dp dpi        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled      end if    next  next endsub xaxis(cx, cy, angle, scale)   local cax, cay, cc, ax,ay  cax = secWide/2 : cay = secHigh/2  'array center  for y = 0 to secHigh    for x = 0 to secWide      cc = sect(x,y)      if cc <> 0 then        ax = (x - cax) :ay = (y - cay) * sin( rad(angle))        dp dpi        rect int(cx+ax*scale),int(cy+ay*scale) step scale+1, scale+1 filled      end if    next  next end  `