Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5904

Re: Rotating a Colour-Filled Square

From Sebastian Barthel <naitsabes@freenet.de>
Newsgroups comp.sys.acorn.programmer
Subject Re: Rotating a Colour-Filled Square
Date 2019-11-13 23:35 +0000
Organization solani.org
Message-ID <qqi40d$e0m$1@solani.org> (permalink)
References <5811cae024basura@invalid.addr.uk> <qqfdpr$n4t$1@solani.org> <58124834ffbasura@invalid.addr.uk> <58125f40fdbasura@invalid.addr.uk>

Show all headers | View raw


Am Wed, 13 Nov 2019 17:05:44 +0000 schrieb Richard Ashbery:

> I forgot about the FILL statement which I can also use in my original
> code but what I'm really after is a method to overlay the existing
> square with other successively smaller squares in alternating colours.
> Its easier to see it illustrated...
> 
> http://www.riscosbasic.uk/problems/square.zip


This doesn't seems as easy as it should be ...
I tried it with the biggest square plotted first. Then the second on top 
of it. But, from this second square on to the last and most little square 
the FILL command didn't work anymore in the expected way. I think, the 
FILL will only fill if there is an unpainted background colour. It 
doesn't work on top of an already painted structure.

So - if one wants to use the FILL - the sqares have to be painted the 
other way round; from the little one in the centre to the outmost an 
biggest one.

If there is a space filled with background colour between the line of the 
new-drawn outermost square an the already painted an filled inner square 
the FILL command works in the expected way.

To find a point where the FILL can start in a defined way, I sorted the X-
values and used the one on the left side (XMIN). The y-value wich belongs 
to this (XMINY) is corrected by a minimal absolute amount, wich sets the 
start of the FILL in a region inside the square.

All this doesn't work if this starting point is located outside of the 
square or if the inner square overlaps with the bigger one.

You can try this by setting the maximum square length (F) (F as in 
"factor", because it's the zooming factor for the calculated length) from 
500 to e.g. 800. Or You can change the STEP to a lesser value (30).

To ease the finding of a good combination of all the factors involved 
there is a little CIRCLE drawn at (XMIN,XMINY) wich should be removed, 
with a REM command, once a good combination has been found.


The ANGLE is (re)calcuated in a "fancy" form with a SIN to give a fine 
rotating effect. This could be exchanged by an addition of a fix value to 
increase the ANGLE for every square - ANGLE=ANGLE+25 ; this should give 
the effect You initially wanted to plot (without additional animations).

It's a little bit "flickery", but gives a fine little demo ... :)
I hope You enjoy it.




 REM BBC BASIC Code , rotating squares - filled with fancy colours

 ON ERROR PRINT "ERROR IN ";ERL : END

 MODE 1280,1024,8

 CLS : ORIGIN 1024,1024

 S=RAD(0.5)

 FOR R=0 TO 2*PI STEP S

 ANGLE=R

 FOR F=50 TO 500 STEP 75


 GCOL ( F MOD 7 )

 X0=SIN(ANGLE)*F : Y0=COS(ANGLE)*F

 X1=SIN(ANGLE+1.571)*F : Y1=COS(ANGLE+1.571)*F

 X2=SIN(ANGLE+3.141)*F : Y2=COS(ANGLE+3.141)*F

 X3=SIN(ANGLE+4.712)*F : Y3=COS(ANGLE+4.712)*F

 POINT X0,Y0

 DRAW X1,Y1 : DRAW X2,Y2 : DRAW X3,Y3 : DRAW X0,Y0


 XMIN=X0 : XMINY=Y0

 IF XMIN > X1 THEN XMIN=X1 : XMINY=Y1

 IF XMIN > X2 THEN XMIN=X2 : XMINY=Y2

 IF XMIN > X3 THEN XMIN=X3 : XMINY=Y3


 IF XMINY < 0 THEN XMINY=XMINY+4 ELSE XMINY=XMINY-4

 FILL XMIN+15,XMINY

 GCOL 200,200,200 : CIRCLE XMIN+15,XMINY,3


 ANGLE=ANGLE+RAD( SIN(ANGLE)*7)


 NEXT F

 FOR I=0 TO 2500 : NEXT I : WAIT : CLS

 NEXT R

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-12 14:05 +0000
  Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-12 23:04 +0000
    Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-14 16:24 +0000
      Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-14 19:29 +0000
        Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-15 21:26 +0000
        Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-15 22:23 +0000
          Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-15 22:31 +0000
            Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-16 14:05 +0000
              Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-16 19:47 +0000
                Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-18 20:02 +0000
          Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-16 00:39 +0000
            Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-16 12:21 +0000
              Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-17 10:04 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-17 13:50 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-17 14:19 +0000
                Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-17 14:21 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-17 15:34 +0000
                Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-17 16:25 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-18 16:17 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-18 16:55 +0000
          Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-16 11:48 +0000
            Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-16 14:21 +0000
              Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-18 20:04 +0000
                Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-19 14:48 +0000
                Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-19 20:26 +0000
                Re: Rotating a Colour-Filled Square Brian Jordan <brian.jordan9@btinternet.com> - 2019-11-19 20:39 +0000
                Re: Rotating a Colour-Filled Square Dave <dave@triffid.co.uk> - 2019-11-20 07:50 +0000
                Re: Rotating a Colour-Filled Square Alan Adams <alan@adamshome.org.uk> - 2019-11-20 11:26 +0000
            Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-16 19:27 +0000
              Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-16 23:37 +0000
      Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-14 20:47 +0000
    Re: Rotating a Colour-Filled Square druck <news@druck.org.uk> - 2019-11-14 20:44 +0000
      Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-15 13:35 +0000
        Re: Rotating a Colour-Filled Square Steve Fryatt <news@stevefryatt.org.uk> - 2019-11-16 00:32 +0000
    Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-13 12:54 +0000
      Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-13 17:05 +0000
        Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-13 23:35 +0000
          Re: Rotating a Colour-Filled Square Sebastian Barthel <naitsabes@freenet.de> - 2019-11-14 12:20 +0000
          Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-14 14:09 +0000
  Re: Rotating a Colour-Filled Square Richard Ashbery <basura@invalid.addr.uk> - 2019-11-14 15:21 +0000
  Re: Rotating a Colour-Filled Square news@sprow.co.uk - 2019-11-14 05:00 -0800

csiph-web