• Re: tcl CSS flexbox engine

    From Conor Williams@21:1/5 to All on Thu Oct 14 16:09:28 2021
    you are talking about floating parts in from Postscript
    and making them appear on the canvas for editing etc...
    a reverse of:
    % canvas .can123
    % .can123 postscript

    interesting...interesting... I will make a start on it in 1 month... (after looking around for an equivalent...)
    my friend... thanks
    /c:202115102308:03
    On Saturday, November 7, 2020 at 9:16:55 PM UTC, pd wrote:
    Hello,

    I'd like to know if there's some kind of flexbox engine in pure tcl or as a C/C++ library.

    What I'm looking for is a way to draw html elements in a tcl canvas, but I'm not really interested in parsing html because I don't care about html elements.

    I'm only interested in an easy way to paint in a canvas, so I think the CSS flexbox model, also known as the box model, should be a great way to paint in a canvas, this will make a canvas just a CSS render engine. It should handle basic box types like
    div or span and maybe some basic text ones.

    Defining a canvas screen as an html layout should be easy and I suppose it should be render engine available since html is in common use today. But a canvas able to read and paint SVG is also a great solution to the same problem.

    I know actual canvas could generate a postscript representation of the canvas by using "postscript" command but I cannot find an import-postcript command or something like that.

    I think something like:

    canvas html read html-file-or-string ; to write canvas content from html canvas html write html-file-or-sring ; to write canvas content to html

    should be great (same for svg just replacling html for svg)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to Conor Williams on Thu Oct 14 16:58:30 2021
    NOTE:

    the Tk engine seems to use encapsulated postscript (edit --forimages).. (which might
    i quickly add -- works perfectly and with ghostview displays the image)
    PART1:
    % set filename "file122.png"
    % set img [image create photo img -file $filename]
    % canvas .con
    % .con create image 0 0 -anchor nw -image $img
    % pack .con

    % set fd [open file2.ps "rw"]
    illegal access mode "rw"
    % set fd [open file2.ps ]
    couldn't open "file2.ps": no such file or directory
    % set fd [open "file2.ps" a]
    file6
    % puts $fd $b
    % close $fd

    # ghostview file2.ps
    yyy shows the image...

    PART 2:
    %------------------------ sample non encapsulated postscript ------------------ ----------------
    % postscript pentagram use ghostview-----------
    128 128 moveto
    256 0 rlineto 72 rotate
    256 0 rlineto 72 rotate
    256 0 rlineto 72 rotate
    256 0 rlineto 72 rotate
    256 0 rlineto 72 rotate
    stroke
    %=======
    PART3:
    drawing a line on a canvas:
    % canvas .myCanvas -background red -width 100 -height 100
    .myCanvas
    % pack .myCanvas
    % .myCanvas create line 10 10 50 50 30 100 -arrow both -fill yellow
    2
    % .myCanvas postscript
    .
    .
    .
    %%Page: 1 1
    save
    306.0 396.0 translate
    0.5408 0.5408 scale
    -51 -51 translate
    0 102 moveto 102 102 lineto 102 0 lineto 0 0 lineto closepath clip newpath gsave
    13.4347495785238 88.5652504214762 moveto
    37.8237716096484 64.1762283903516 43.9407382802766 36.8518457006916 31.8040188596896 6.51004714922395 curveto
    0 setlinecap
    1 setlinejoin
    1 setlinewidth
    [] 0 setdash
    1.000 1.000 0.000 setrgbcolor AdjustColor
    stroke
    10 92 moveto
    14.5961940777126 82.4526442404192 lineto
    15.5059807680758 85.7869124507377 lineto
    16.2130875492623 86.4940192319242 lineto
    19.5473557595808 87.4038059222874 lineto
    10 92 lineto
    fill
    30 2 moveto
    36.9648750490067 9.98545662762776 lineto
    33.5418164598207 9.50824994776821 lineto
    32.6133397689355 9.87964062412232 lineto
    30.4636812594281 12.5859341434592 lineto
    30 2 lineto
    fill
    grestore
    restore showpage

    %%Trailer
    end
    %%EOF

    ---- along with loads of functions....
    PAT4 & CONCLUSION:
    so yeah... it is very dooable...

    Kind Regards/c:20211510~2am


    On Thursday, October 14, 2021 at 11:09:30 PM UTC, Conor Williams wrote:
    you are talking about floating parts in from Postscript
    and making them appear on the canvas for editing etc...
    a reverse of:
    % canvas .can123
    % .can123 postscript

    interesting...interesting... I will make a start on it in 1 month... (after looking around for an equivalent...)
    my friend... thanks
    /c:202115102308:03
    On Saturday, November 7, 2020 at 9:16:55 PM UTC, pd wrote:
    Hello,

    I'd like to know if there's some kind of flexbox engine in pure tcl or as a C/C++ library.

    What I'm looking for is a way to draw html elements in a tcl canvas, but I'm not really interested in parsing html because I don't care about html elements.

    I'm only interested in an easy way to paint in a canvas, so I think the CSS flexbox model, also known as the box model, should be a great way to paint in a canvas, this will make a canvas just a CSS render engine. It should handle basic box types
    like div or span and maybe some basic text ones.

    Defining a canvas screen as an html layout should be easy and I suppose it should be render engine available since html is in common use today. But a canvas able to read and paint SVG is also a great solution to the same problem.

    I know actual canvas could generate a postscript representation of the canvas by using "postscript" command but I cannot find an import-postcript command or something like that.

    I think something like:

    canvas html read html-file-or-string ; to write canvas content from html canvas html write html-file-or-sring ; to write canvas content to html

    should be great (same for svg just replacling html for svg)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to All on Thu Oct 14 17:38:39 2021
    ######### ######## ######## ######## #########
    # display postscript image in Tcl kinda...
    # Creator -- conor.williams@gmail.com
    ######### ######## ######## ######## #########
    set filename "1.png"
    set img [image create photo img -file $filename]
    canvas .con
    .con create image 0 0 -anchor nw -image $img
    pack .con

    update
    set fd [open "file2.ps" w]
    puts $fd [.con postscript]
    close $fd
    exec ghostscript file2.ps
    ########
    #EOF
    #######

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Uwe Klein@21:1/5 to All on Fri Oct 15 13:09:45 2021
    Am 15.10.21 um 12:18 schrieb Conor Williams:
    having had the night to dream of it...
    it's a big ask... in that what is required is a full postscript (special
    full blown printing language like Fortran) parser...
    -- i have managed to get a java equivalent though... and with jacl
    i could get that going...
    i will keep at it...
    & top of the mornin' to you all..
    Kind Regards
    /c:20211510~10:20)2

    ps to tk-canvas is needed if you want to manipulate
    the tk-canvas code afterwards, right?

    embed a window that renders ps via gs ?

    Uwe

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to Conor Williams on Fri Oct 15 03:18:52 2021
    having had the night to dream of it...
    it's a big ask... in that what is required is a full postscript (special
    full blown printing language like Fortran) parser...
    -- i have managed to get a java equivalent though... and with jacl
    i could get that going...
    i will keep at it...
    & top of the mornin' to you all..
    Kind Regards
    /c:20211510~10:20)2


    On Friday, October 15, 2021 at 12:38:41 AM UTC, Conor Williams wrote:
    ######### ######## ######## ######## #########
    # display postscript image in Tcl kinda...
    # Creator -- conor.w...@gmail.com
    ######### ######## ######## ######## #########
    set filename "1.png"
    set img [image create photo img -file $filename]
    canvas .con
    .con create image 0 0 -anchor nw -image $img
    pack .con

    update
    set fd [open "file2.ps" w]
    puts $fd [.con postscript]
    close $fd
    exec ghostscript file2.ps
    ########
    #EOF
    #######

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Uwe Klein@21:1/5 to All on Fri Oct 15 13:16:50 2021
    Am 15.10.21 um 13:09 schrieb Uwe Klein:
    Am 15.10.21 um 12:18 schrieb Conor Williams:
    having had the night to dream of it...
    it's a big ask... in that what is required is a full postscript (special
    full blown printing language like Fortran) parser...
    -- i have managed to get a java equivalent though... and with jacl
    i could get that going...
    i will keep at it...
    & top of the mornin' to you all..
    Kind Regards
    /c:20211510~10:20)2

    ps to tk-canvas is needed if you want to manipulate
    the tk-canvas code afterwards, right?

    embed a window that renders ps via gs ?

    Uwe

    apropos:
    http://www.calvina.de/pstoedit/

    targets:
    ...
    Java 1 or Java 2 applet
    Idraw format (in fact a special form of EPS that idraw can read)
    ** Tcl/Tk
    HPGL
    AI (Adobe Illustrator) (based on ps2ai.ps - not a real pstoedit driver -
    see notes below and manual)
    .....

    Uwe

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Conor Williams@21:1/5 to All on Fri Oct 15 05:27:03 2021
    ######### ######## ######## ######## #########
    # display postscript image in Tcl
    # utilises external convertor (pstopnm) -- leaves dir))
    # Creator -- conor.williams@gmail.com
    ######### ######## ######## ######## #########
    proc rest1234 {filename} {
    set dir1 "$filename.[exec date +%N]"
    exec mkdir "$dir1"
    exec cp "$filename" "$dir1"
    ##some debug
    puts [exec ls "$dir1"]
    puts [exec pwd]
    ##########
    update
    rest123456 "working..."
    update
    catch {exec pstopnm "$dir1/$filename"}
    update
    set convfilenamebase [regsub ".ps$" "$dir1/$filename" "" ]
    set convfilename2 [regsub ".ps$" "$dir1/$filename" "001.ppm" ]

    rest123456 [concat "$filename" " >>>> " " Page1:" $convfilename2]
    update
    puts "Displaying: $convfilename2"
    update

    set img [image create photo img -file $convfilename2]
    canvas .con
    .con create image 0 0 -anchor nw -image $img
    pack .con

    update
    }
    proc rest123456 {thetext} {
    catch {
    destroy .frame1.filename
    destroy .frame1.text2
    destroy .frame1
    destroy .but10}

    catch {frame .frame3
    pack .frame3 -side top
    label .frame3.filename
    pack .frame3.filename}
    .frame3.filename configure -text $thetext
    update
    }

    frame .frame1
    pack .frame1 -side top
    label .frame1.filename -text "ps filename:"
    pack .frame1.filename -side left
    text .frame1.text2 -height 1 -width 30
    pack .frame1.text2 -side right
    button .but10
    .but10 configure -text "press me" -command {rest1234 [.frame1.text2 get -displaychars 1.0 1.100]}
    pack .but10
    update

    ########
    #EOF/c:202115101319:23
    #######

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Uwe Klein@21:1/5 to All on Fri Oct 15 16:23:41 2021
    Am 15.10.21 um 14:27 schrieb Conor Williams:
    ######### ######## ######## ######## #########
    # display postscript image in Tcl
    # utilises external convertor (pstopnm) -- leaves dir))
    # Creator -- conor.williams@gmail.com

    if you accept traversing via some rasterimage format
    the whole netpbm package is your friend.
    http://netpbm.sourceforge.net/

    but that loses you the vectored drawing information :-(

    Uwe

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)