Showing posts with label Project. Show all posts
Showing posts with label Project. Show all posts

Saturday, June 27, 2026

🪲 Fix in The Works: DRAW statement: Circle Creation: The problem of Asymmetric Pixels

I want to write about a little problem I think I've fixed (in the development version of BASIC Anywhere Machine), and I hope to soon release this fix in a new version of BASIC Anywhere Machine:

🪲 Asymetric pixels in the quadrants or a circle generated with the DRAW statement.

By quadrants, I mean each pie shape created by dividing the top-bottom, and left-right parts of the circle:

By the way, later, keep in mind that from the center coordinate of the circle:

  • travelling directly right, that is at an angle of 0 degrees
  • travelling directly up, that is at an angle of 90 degrees
  • travelling directly left, that is at an angle of 180 degrees
  • travelling directly down, that is at an angle of 270 degrees

Here's a little program using DRAW to create a circle on a small-resolution screen:

d% = 20

SCREEN _NEWIMAGE( d% * 2 + 1, d% * 2 + 1, 17)

FOR A% = 0 TO 359 STEP 1
    COLOR 63
    draw "BM " + d% + "," + d%
    DRAW "TA " + A%
    DRAW "BU" + (d% - 1)
    pset (point(0), point(1)), 61
NEXT A%

The Result:


In each highlighted part of the circle, we find cases where the pixels in the mirror image across the vertical axis, and/or the mirror image across the horizontal axis, do not match.

In the scheme of things, this wouldn't matter in regards to the job of creating circles.  The asymmetry is noticeable at low resolutions, but becomes indistinguishable by the naked eye at high resolutions.

However, this does cause some noticeable problems, even at high resolutions, when using this process to create polygons which ought to have  one or more perfectly horizontal and/or perfectly vertical sides, like this triangle, for example:

d% = 20
SCREEN _NEWIMAGE( d% * 2, d% * 2, 17)
FOR A% = 0 TO 360 STEP 120
    COLOR 63
    draw "BM " + d% + "," + d%
    DRAW "TA " + A%
    DRAW "BU" + (d% - 1)
    NEWX% = POINT(0) : NEWY% = POINT(1)
    IF A% > 0 THEN COLOR 7 : _
                   LINE (NEWX%, NEWY%) TO (LASTX%, LASTY%)
    LASTX% = NEWX% : LASTY% = NEWY%
NEXT A%

The result:


I suspect (without, for lack of interest, researching this thoroughly) that I'm dealing with what might be either a floating point issue, and/or the following, and/or some other related issue(s):

From Google AI's answer to "Using javascript, why would the process of creating a circle of a certain radius not result in symmetric pixels between the quadrants ?":

When you write JavaScript to create a raster (pixel-based) circle, quadrants often lack symmetry because of integer rounding and the discrete nature of pixel grids. Circles rely on continuous math, but monitors have a fixed resolution, creating several common issues: [1, 2, 3]
    • Off-Center Origins: If your radius is an even number (e.g., \(r = 10\)), there is no single middle pixel, forcing the circle to round up or down on the grid. This shifts the center, making left/right or up/down sizes unequal. [1]
    • Coordinate Truncation: Converting float coordinates to whole pixels (using Math.round(), Math.floor(), or Math.ceil()) can bias where lines fall on the grid, stretching or shrinking one quadrant over another. [1]
    • Aspect Ratio: If the canvas CSS scales the element unevenly (e.g., non-square pixels or mismatched width and height settings), what should be a symmetrical equation acts like an oval, shifting pixel densities per quadrant. [1]
    • Algorithm Bias: Algorithms like the Midpoint Circle or Bresenham’s often use directional bias (preferring to step horizontally, vertically, or diagonally) to optimize speed. This "step" decision breaks quadrant reflection. [1]

What I've decided to do (I wanted to solve this on my own without looking for already existing solutions):

Modify BAM's implementation of DRAW such that whatever angle is used to draw (using the TA command to set the angle and/or whatever angles needed to perform commands like U,D,R,L = Up,Down,Right,Left) convert that angle to the equivalent between 0 and 90 degree, figure out the X and Y coordinates for the destination pixel, and then negate the value of X and/or Y (if applicable) to get the symmetric point for the originally intended angle.

For your interest, here's the relevant javascript code to figure out the destination pixel:

  function AngleStep(a) {
       var xstep = 0;
       var ystep = 0;
       var tota = (+draw_angle + +a) % 360;
       var af = tota;
       if (tota > 90 && tota < 180) {af = 180 - tota;}
       else if (tota > 180 && tota < 270) {af = tota - 180;}
       else if (tota > 270) {af = 360 - tota;}
       af = af * Math.PI / 180;
       if (tota % 180 === 0) { xstep = n; }
       else if (tota % 90 === 0)  { ystep = n; }
       else {xstep = n * Math.cos(af); ystep = n * Math.sin(af);}
       xstep=Math.round(xstep); ystep=Math.round(ystep);
       if ((tota % 360 > 90) && (tota % 360 < 270)) { xstep = -xstep;  }
       if ((tota % 360 < 180)) { ystep = -ystep;  }
       Step(xstep,ystep);
     }

  • a is the angle if the pen movement
  • tota is the calculated angle of movement
    • a would be, for example:
      • 0 degrees if the drawing command is Right
      • 90 degrees if the drawing command is Up
      • 180 degrees if the drawing command is Left
      • 270 degrees if the drawing command is Down
    • draw_angle would be an angular offset applied with a TA command; for example, an offset of 5 degrees would result in:
      • 5 degrees if the drawing command is Right
      • 95 degrees if the drawing command is Up
      • 185 degrees if the drawing command is Left
      • 275 degrees if the drawing command is Down
  • af is the tota angle transposed to the first quadrant (between 0 and 90 degrees)
  • n is the distance (the number of pixels) travelled from the current pen position to the destination pen position
  • xstep and ystep are the relative destination coordinates of the pen based on wherever the pen is currently located when the DRAW statement is performed)
Let's say that the "tota" angle is 125 degrees, then the "af" angle will be 55 degrees.  When the function figures out the values of xstep and ystep at 55 degrees: ystep does not change (the value of ystep is the same at 55 degrees and 125 degrees), however xstep is switched to the negative value (for example: if xstep is 100 pixels to the right of the starting pen position when the angle is 55 degrees, then xstep is -100 to the left of the starting pen position when the angle is 125 degrees.)

With this modified implementation of DRAW, the same BASIC programs now result in this circle and this triangle:





WOOHOO !

If you want to try the BASIC programs above, before the next release of BAM:



Thursday, April 30, 2026

📚 A BAM Use-Case: Giving a New Lease on Life to Old BASIC Programs

One BAM's top goals is to make it fairly easy to port old BASIC programs so that they can be shared via the web for running in any web browser.

Is there a better/easier way to keep old gems around for posterity?

Anyway, I just  discovered this website by Michael Coorlim via which he shares his refactors and adaptations of type-in listings from the 80's books and magazines.  Some of these programs (ones that are not machine-specific) were refactored and adapted for  BASIC Anywhere Machine in order to share the running programs.

The list of programs are in the link provided above, with mention of BASIC Anywhere Machine on the About page.

For folk like me who grew up in the age of the home computer revolution, Michael Coorlim's efforts are really cool.

Saturday, April 26, 2025

🚧 In the Works: "Code Insertion" buttons

Try this in the 🔗 development version of BASIC Anywhere Machine.

Who likes looking up statement/function statements (or code blocks) to whenever does not remember the precise syntax?  These buttons (very much a work in progress) will insert template code.












Thursday, October 19, 2023

🎉 BAM Advertising Artwork by The Joyful Programmer

The Joyful Programmer surprised me with a gift of advertising artwork for BAM.

Although he initially quickly created these three works of art as just a funny and silly story, shared with the the BAM Discord community, on how I "lured him into BAM", the images are so good that The Joyful Programmer took some extra time to add some polish for BAM advertising use.

I really love these three works of art, and I just cannot wait until an advertising plan/opportunity to share them:












Tuesday, September 19, 2023

🚧 In the works: faster CIRCLE

To compare the difference between the current "production" implementation of CIRCLE and the "development" implementation of CIRCLE, try running the "Flower Wheel" program:

(Both versions of BAM show the "Flower Wheel" program in the IDE at startup.)

This will be PHASE 1 of improving the performance of CIRCLE.

Improving the performance of CIRCLE will involve incremental steps, with the internals handling CIRCLE with new code in some circumstances, and handling CIRCLE with the old code in other circumstances.

Phase 1
  • The old code gets triggered when any of the following optional parameters are specified: start angle, end angle, aspect
  • Otherwise, the new and faster code gets triggered

Phase 2

The old code will get triggered when the aspect parameter is specified
Otherwise, new and faster code will get triggered

Phase 3

New code will handle everything, and the old code will be entirely gone.


Sunday, September 10, 2023

Trying to smooth out BAM-related communications

Communicating anything and processing (of the cognitive kind) anything, these things do not come by easily for me.  I find these things exhausting.

Using the right tool for the job helps me immensely.  However, the right tool for me is often times only the right tool for a subset of tasks.

Since I started the BASIC Anywhere Machine project in December 2020, I have found myself in a continuous struggle of refactoring workflow and choice of "tools" to try and reduce cognitive and sensory overload.

Over the course of that time, I've taken a lot of flack over communications when, really, I have no idea how to communicate anything.

So here's the plan:

  • I'll be using this blog for all writing/sharing.
  • I'll be using forums to
    • Share links to blog items for much-better-suited discussions in those forums
    • Share any link to a blog item with only the forum(s) that have a scope matching the blog item

Blogger will be central

Blogger (i.e. this blog) will be my go to communication platform for writing and sharing.  It is for me the best tool for the job of writing.  I rely heavily on formatting features to help organize my thoughts.  I cannot stand markup as it is too distracting.

I had thought that Reddit would be good as a primary communication platform, but it seems to require an app on mobile devices, and requires an account for Windows XP (as reported by one individual.)

The forums


I generally really like it, for many reasons I haven't quite yet figured out.  However, I have figured out that I really appreciate how a post in Reddit can easily be shared via "cross-posts" to other communities on Reddit.  I like this idea: "cross-pollination" of communities.

For every blog item, there will be a matching post in this Reddit.


I find discord a bit overwhelming (everything is a shiny object), but the GotBASIC channel has got my attention something silly.  I know of nothing else that does the job of "celebrating BASIC" as well.  So whatever challenges I have with Discord, that is totally worth it.

I'm pretty sure every blog item will have a matching post in the "bam" sub-channel in GotBASIC.


Although this also screams "celebrating BASIC", and I find it much less overwhelming than discord, it is a really big bucket that makes it challenging to focus on a particular context.  I do love to reminisce on all things BASIC, and this group is stellar for being quite active: it is a very large community, so there is always very good stuff to find every day.

Here, I'll only post links to BAM programs for running and for viewing source code.

If somebody shares a program in this group and I port that program to BAM, I'll share that program as a comment to the OP in the Facebook Group.


Ditto (BASIC Programming Language Facebook Group)


Although a small and not very active community it is a nice focus on "Retro Programming".  I do find it a little bit challenging to communicate there because formatting is done with markdown, which I cannot stand because I rely heavily on WYSIWYG formatting to organize my writing/thoughts and markup really painfully distracts me.

There, I'll only post about programs or BAM enhancements that support the scope of "retro programming".


That is pretty much a dormant forum except for occasional posts be two or three of us.  Although the WYSIWYG editor is nice, the advertisements are a little bit annoying.

I post there as I post to RetroCoders because it is worth trying to give anything good for BASIC some kind of pulse.


This is a great community.  When created BAM, the original intent was to create a sidekick for QB64 for porting QB64 programs to the web.  Despite lack of interest in BAM in huge interest in QBJS (for porting QB64 programs to the web), the community is very helpful in explaining to me how the QB64 BASIC works for when I'm attempting to create compatible statements/functions, and/or provide workaround code.

Although the community is generally very welcoming of BAM-related posts, there isn't much point in my sharing anything BAM-related in the forum unless it is to provide context when I'm trying to understand how QB64 works.










Monday, August 7, 2023

About me and why creating BAM is wildly interesting to me

Prologue:

From "Administrator", some guy running a forum I have no interest in (because of him and how he is), some guy who seemingly relishes every opportunity to demean/berate/bully/attack me and the things I find interesting, he writes about me:

and main question is what he made...what ?

he use two open source projects packed it and B.A.M was born !

really this is developer ?
also he never made any program by himself in BAM from the ground
and tell us ...i made this example .
and so on and on...

Ouch.  Why he's attacking me behind my back when I've done nothing to him bewilders me something silly.  Self-confidence issues?  Who knows?  Me, that just gives me an idea about something to write about.

About Me

I'm a career (since 1995) software developer and systems analyst, now a self-employed consultant.  I'm an agile programming and documentation disciple, and I've been involved in all aspects of the software development life-cycle.

Working with Gupta Team Developer (aka Gupta SQLWindows) has been my bread and butter since 1995 and to this day.  Most of my experience is with Oracle back-end, but I'm also experienced with Gupta SQLBase back-ends.

I've also got heavy-duty experience using wikis as single-source information for documentation and all things software-development life-cycle, and as context-sensitive help engines. 

I'm at my happiest enhancing/supporting complex systems for government agencies (focused on project management related to new construction and major renovations, facilities management, contract management, tender management, financial administration, etc.), doing Gupta Team Developer programming.

At home, I enjoy hobby programming.  Being a "Chromebooks" only household, I find myself much happier living in a web browser than running traditional software.  TiddlyWiki "programming" is, to me, the most enjoyable and fascinating experience at home.

Enter BASIC Anywhere Machine

All that said, BASIC has always been the one tugging at my heartstrings.  Hence BASIC Anywhere Machine: I get to do a kind of programming that is ridiculously enjoyable, with the goal of helping to keep BASIC relevant today, and supporting that BASIC with software development life-cycle things we might not normally see with any programming language's IDE, let alone BASIC.

When you really look at BASIC Anywhere Machine, you'll see a TiddlyWiki instance that looks nothing like TiddlyWiki.  Other than using a TiddlyWiki Codemirror Plugin, all you see is my programming with what I call "TW Script" (TiddlyWiki widgets, transclusion, filtering, etc.), along with HTML and CSS.

The BASIC interpreter is wwwBASIC, which I've embedded in BAM and significantly enhanced.  All of those enhancements requiring javascript programming, and I heavily dislike javascript (I appreciate the awesome work done with it, and the awesome folk talented in it, but I cannot stand looking javascript in the eyeballs.)  I will suffer javascript, though, for the mission: BAM.

Busy enhancing/debugging BAM, I have only been able to write a few of my own BASIC programs in it.  Much of my BASIC programming has been getting other folk's BASIC programs working in BAM, in order to test and improve BASIC Anywhere Machine.  You'll find mostly ported and/or modded programs in my published programs, but you'll find some in there that are original programs by me.  (For every program, the source code is displayed under the console window.)


Oops, I've got to cut it short there.  Must make my lunch before getting back to work !

Sunday, July 24, 2022

🆕 Discussion forums to support a sought community

I have created three Google Groups, all embedded in the BASIC Anywhere Machine website's related pages, to support BASIC Anywhere Machine users who are interested in joining: 

  • How To
    • A place to have conversations about BASIC Anywhere Machine focused on anything "how to..."
  • Feature Requests
    • A place to request new features (or changes to existing features, and discuss these
  • Bug Reports
    • A place to report and discuss bugs (and bug resolution), of any kind (including documentation.)

Thursday, March 31, 2022

📚 BASIC Anywhere Machine Documentation Set (Planned)

Just a summary of the types of documentation I am, or will be, putting together with TiddlyWiki instances.  These are types of documentation I'd expect to find, in general, for any kind of software development project.

Started and ongoing:


Planned (created but empty TiddlyWiki instances):

  • User Guide (i.e. how to use BASIC Anywhere Machine)
  • Technical Reference (i.e. the architecture of BASIC Anywhere Machine, as in how it is constructed and how it operates under the hood)
  • Project Reference (i.e. everything we need regarding management of the project: vision/goals, artifacts, tasks/todos, status, plans ...)
  • Documentation Guide (i.e. everything we need to know to develop and maintain every kind of documentation for the project and the product.)

Monday, February 28, 2022

BASIC Anywhere Machine version of "Spheres"





Thursday, February 3, 2022

Tuesday, December 21, 2021

One of the Project Missions: Enhancing wwwBasic

I've added three new string functions to the version of wwwBasic embedded in BASIC Anywhere Machine: NOW$, TIME$, and DATE$.  (See the screenshot below.) 

Try it out:  BASIC Anywhere Machine

Keep track of progress and get information at the project website.

Make sure to keep an eye on the evolving BASIC Anywhere Machine Programmer's Reference.






Friday, December 3, 2021

Project introduction: TiddlyWiki for BASIC Programming

 

I made the following demonstration video after announcing "An all-in-one-file and portable BASIC language programming IDE + .BAS programs" in both the TiddlyWiki Google Group and the TiddlyTalk Discourse Forum:


🖥 Circular Sinusoidal Waves with DRAW and SIN

Run the program View the source code