Jump to content
Sign in to follow this  

how plot a circle in Array?

Recommended Posts

Hi, this is for a math experts!

If you have an array[64][64] empty (the size is hiphotetics..., can be any size)

All position is initialy empty or zero.

How to plot this circles in this array (center is a red dot).


a] plot a full circle in array
b] plot a half circle in array
c] plot a inclinade half circle

Someone have any idea?

#include <Array.au3>

Global $iSize = 32
Global $aArray[$iSize][$iSize]
Global $aCenter[2] = [Floor($iSize / 2), Floor($iSize / 2)]

plot_circle($aCenter[0], $aCenter[1], $aCenter[0])


Func plot_circle($iXX, $iYY, $iRadius, $iMode = 0)
    Switch $iMode
        Case 0 ; full circle
        Case 1 ; half circle
        Case 2 ; inclinade half circle

EndFunc   ;==>plot_circle

Br, Luigi

Edited by Luigi

Visit my repository

Share this post

Link to post
Share on other sites

Why on hell do you want to "draw" into an array?

Anyhow, here we go:

#include <Array.au3>

Global Const $fPi = ACos(-1), $fD2R = $fPi / 180
Global $aGfxArray[21][21]

DrawEllipseToArray($aGfxArray, 10) ;full ellipse
_ArrayDisplay($aGfxArray, "full ellipse")

Global $aGfxArray[21][21]
DrawEllipseToArray($aGfxArray, 10, 90, 270) ;half ellipse
_ArrayDisplay($aGfxArray, "half ellipse")

Global $aGfxArray[21][21]
DrawEllipseToArray($aGfxArray, 10, 90 - 45, 270 - 45) ;inclinade half ellipse
_ArrayDisplay($aGfxArray, "inclinade half ellipse")

Func DrawEllipseToArray(ByRef $aArray, $iRadius, $iStartAngle = 0, $iEndRadius = 359, $iColor = 0xFF00FF00, $iColor_Center = 0xFFFF0000)
    Local $d, $iW2 = Int(UBound($aArray, 2) / 2), $iH2 = Int(UBound($aArray, 1) / 2), $iX, $iY
    For $d = $iStartAngle To $iEndRadius
        $iX = Round($iW2 + Sin($d * $fD2R) * $iRadius, 0)
        $iY = Round($iH2 + Cos($d * $fD2R) * $iRadius, 0)
        $aArray[$iY][$iX] = $iColor
    $aArray[$iH2][$iW2] = $iColor_Center


Pay attention to the function DrawEllipseToArray - it has no error checks!

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...