figplus, a new python-based toy for coders who like graphics

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
nosystemdthanks
Posts: 703
Joined: Thu 03 May 2018, 16:13
Contact:

figplus, a new python-based toy for coders who like graphics

#1 Post by nosystemdthanks »

using fig to remaster puppy/debian/void/tinycore/refracta since 2016.

fig is a low-syntax, qb-and-python-inspired educational language developed primarily in 2015. it has gained minor tweaks (basically all backwards-compatible) since then.

two things python has that fig does not: case-sensitivity and mandatory indentation. instead of unindenting, you can just use the fig command (compare with fi in bash.)

Code: Select all

while
    p = "enter a number: " prints lineinput val
    ifless(p, 5)
        break
        fig
    wend
the indents are optional, the ( ) are optional, the "," is optional. you can also use : ; |

fig has fewer than 100 commands and each command has a minimal, fixed number of parameters.

you can design functions with fixed parameter counts:

Code: Select all

function abs p # public domain
    ifless p 0
        now = p times -1 ; return now
        fig
    fig
if you prefer the semantic merit, you can use "next" instead of fig for unindenting. it pairs with the for command.

most lines in fig start with a variable:

variable = "hello world" print



each command follows to the right of the previous, like in english.

this(like((talks(in real life(nobody)))))

programmers().do().this().however()



having fewer commands is part of the concept of fig, but a few years in https://codeinfig.neocities.org/fig/sp.fig.html i decided to make an extended version of it:

https://codeinfig.neocities.org/figplus/

adding commands for things such as hybrid dictionary/list support (ordered dictionary) which i call a "codex" and turning the 24bit rgb hack (fig only has 16 colours) into a native feature.

fig is not abandoned, and is still more important than figplus, but it is a bit more limited in what it does by default.



one thing that i did with figplus immediately is use it to remove all blue from blueish pixels in an image.

Code: Select all

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

filepath = "pic.jpg"

imgsize codimgsize filepath

width codget imgsize "w"
height codget imgsize "h"
now winsize width height

pic imgset 0 0 filepath
now display

cx2 width minus 1
cy2 height minus 1

for cy 0 cy2 1
    for cx 0 cx2 1

        now codrgbget cx cy
        r codget now "r"
        g codget now "g"
        b codget now "b"
	
        ifmore b r
            ifmore b g
                now rgbset 15 r g 0
                now pset cx cy 15
                fig
            fig 

        next
        now display
    next

now display lineinput


this can also be used to reduce the number of colours in a photo by removing the two ifmore checks, and then changing 4 lines:

Code: Select all

        r codget now "r"
        g codget now "g"
        b codget now "b"
	
                now rgbset 15 r g 0
to this:

Code: Select all

        r codget now "r" divby 64 int times 64
        g codget now "g" divby 64 int times 64
        b codget now "b" divby 64 int times 64
	
        now rgbset 15 r g b
Image



of course you can find better posterisation routines-- and if theyre implemented in python (or if you use the shell command to script mtpaint) you can include them in your figplus program.

whats cool though is that you can play with the code and customise it.



i like to think that figplus is to python what puppy is to larger distros: a very customisable, very simplified, very beginner-friendly programming language with a surprising amount of power in fewer commands.

im posting this now as my "fig system" was mentioned elsewhere on the forum, and in the event anybody was curious, i thought id post about something new here.

fig and figplus work entirely independent of each other.

each is a single python 2 script. download and chmod 755.

graphics (optional, but the point of the thread) require the pygame library. http://murga-linux.com/puppy/viewtopic. ... 656#929656
Attachments
pic8.png
(104.57 KiB) Downloaded 205 times
[color=green]The freedom to NOT run the software, to be free to avoid vendor lock-in through appropriate modularization/encapsulation and minimized dependencies; meaning any free software can be replaced with a user’s preferred alternatives.[/color]

Post Reply