floral (fig graphics)

floral

 

#### license: creative commons cc0 1.0 (public domain) 
#### http://creativecommons.org/publicdomain/zero/1.0/ 

proginf "floral 2017 mn"

function rgbcolour r g b c
python
    figcgapal[c] = (r, g, b)
    fig
    fig

function qline c d e f g
    ## draw 4 lines, points go 2x2
    ## (cheap but avoids gaps)
    now line c d e f g
    d2 d plus 1
    f2 f plus 1
    now line c d2 e f2 g
    c2 c plus 1
    e2 e plus 1
    now line c2 d2 e2 f2 g
    now line c2 d e2 f g
    fig

while 
    rf randint 35 105 ## radius
    sf rf divby 2 int ## range of radius change
    xmin rf plus sf
    xmax xmin times -1 plus 800
    ymin rf plus sf
    ymax ymin times -1 plus 600
    pc randint 5 15      ## petal count
    xc randint xmin xmax ## horiz location
    yc randint ymin ymax ##  vert location
    while
        cr randint 32 248
        cg randint 32 248
        cb randint 32 248
        #fewer greens and dingy colors
        greenish cr plus cb minus cg times -1
        ifless greenish 0
            ifmore cr 160 
                break
                fig
            ifmore cg 160 
                break
                fig
            ifmore cb 160 
                break
                fig
            fig
        wend
    now display
    for p -3.14159 3.14159 0.00076698974609375 # 3.14159 / 2**12
        r p times pc sin times sf plus rf plus 7
        x p cos times r plus xc int
        y p sin times r plus yc int
        now line x y xc yc 15
        next
    for p -3.14159 3.14159 0.00076698974609375 # 3.14159 / 2**12
        r p times pc sin times sf plus rf
        x p cos times r plus xc int
        y p sin times r plus yc int
        now rgbcolour cr cg cb 14 qline x y xc yc 14
        next
    now display
    wend

now lineinput

 

 

Advertisements

15 thoughts on “floral (fig graphics)

    1. fig graphics are modest. theyre deliberately based on pairing the term with the graphics commands.

      the only reason it can do 24bit colour now is that ive used inline python to tap into figs palette. i would create a command for it, but i almost think its better not to.

      fig is how it is because it sticks to < 100 commands. you can fit a cheat sheet for the entire language on a single page. i made a wall poster of the language.

      Liked by 1 person

    1. ive thought about how to implement that so many times.

      on the one hand, i could do it– but id probably have to add a pass to the compiler.

      and id have to figure out what to do about a circular or recursive import.

      and id have to add a statement to the language. and fig itself (all 1500 ploc) doesnt require other scripts (just libs) so im not sure whether fig ought to have its own import or not. it can of course, import python (and thus, import any compiled fig program.)

      Liked by 1 person

  1. hum i think just a change in fig workflow on imports

    if import external script,

    file 1 = file 1.append(import)

    meaning just take in the lines and include it in the main file and execute the file normally

    i am copying the idea where an assembler removes any external files references by merging them into one file.

    just a quick idea

    Liked by 1 person

    1. yes ive thought about includes too. which leads me to think about circular references. do i drop them after a certain reference count? do i add an error message? do i really want to have includes on top of import, when its possible that someone will prefer the python way in any case?

      i imagine someone possibly spending two (or more) years using fig, then going through and converting includes in fig to imports with python.

      so the logic behind these decisions is usually something like:

      “is this something fig really needs? or is this the sort of feature that python already does perfectly enough?” …if a typical fig user needed includes, that would be considered. (like i said, ive thought about it.)

      Liked by 1 person

    1. if youre going to make a dedicated graphics library:

      python
      from figfx import *
      fig

      you can write that library in fig, or python. or any other type of library python allows.

      but if you write it in fig, youll have to compile it to a .fig.py script before you can import it. all of this works using figs existing features.

      Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s