Asymptote: 2.88 Released
Building against specific static libraries is supported again. An ambiguity in statistics.h was resolved. The output of dvisvgm is optimized by default. PDF 1.5 output is now generated.
To define an array of functions: While functions do have a type (e.g., pair(real)), the syntax does not support something like pair(real)[]. Instead, you have to create a type alias using typedef: typedef pair PairFromReal(real); Basically, it's like you are declaring a function named PairFromReal, but because you use the keyword typedef, you get a type alias rather than a new function. At this point, you can do something like this (untested!): PairFromReal[] pQ=new PairFromReal[3]; pQ[0] = new pair(real...
To define an array of functions: While functions do have a type (e.g., pair(real)), the syntax does not support something like pair(real)[]. Instead, you have to create a type alias using typedef: typedef pair PairFromReal(real); Basically, it's like you are declaring a function named PairFromReal, but because you use the keyword typedef, you get a type alias rather than a new function. At this point, you can do something like this (untested!): PairFromReal[] pQ=new PairFromReal[3]; pQ[0] = new pair(real...
Thanks, I suspected something like that. Of course if I label pairs as pQ00 pQ10 etc and avoid arrays everything works. However, I would like to have functions defined as arrays, like pQ[1][0] (t) etc. How would you do that? (my problem is that I never had any training in programming languages...) Thanks Maurizio PS: I am the "mauvia" which was mentioned in a footnote in your nice manual.
You are trying to insert an object of type pair(real) into the array pQ, which contains only objects of type pair. If you replace pQ[2] with pQ, then you have two objects named pQ. This is allowed as long as all the objects named pQhave different signatures. (A non-function type like pair[] has a different signature from any function type. But if you tried to define a pair[] and an int and call them both pQ, then the first one you defined would be hidden by the second, since these are both non-functions...
Dear fellow users: I do not understand why the following code does not work. It will give an error at the line where the function is defined. Is it not possible to define a function pQ2 ? Of course it works if I just write pQ where you see pQ[2]..... Thanks Maurizio pair[] pQ=new pair[3]; pQ[0]=(0,0); pQ[1]=(1,1); pair pQ[2](real t){return (1-t)*pQ[0]+t*pQ[1];} path segment=graph(pQ[2],0,1); draw(segment);
Right ! It was my first attempts and didn't know what I was doing. Thx for your answer and the information about the colorspaces.
Asymptote: 2.87 Released
Templated imports were implemented. An incorrect dvisvgm optimization is avoided. SVG gradient shading offsets were fixed. Integer are now implicitly formatted with full precision. Inferred assignment of void type is prohibited. An LSP segmentation fault was fixed. Repeated stripping of file extensions is avoided. The --output-directory option of latexmk is supported. The OSMesa compatibility profile is used for offscreen rendering. The fitscreen toggle is fixed. The context menu in Xasy is now only...
Colors can look different in different colorspaces: rgb is intended for screens, whereas cmyk is intended for print. You didn't post your 3D example but be aware that by default the lighting affects colors in 3D. So if you are looking at an unlighted side of an object, it may appear very dark. Try rotating it.
Yes, we'll add it to our TODO list.
The Alberta asymptote server at http://asymptote.ualberta.ca/ allows the download of the output files resulting from the use of the server. Newer browsers resist downloads unless they are from a secure address (https://). Any chance of an upgrade here?
You should encourage Mint to update their Asymptote package. Or simply install TeXLive from the official source; that will get you a version of Asymptote that is at most 1 year old.
Yes and no, I am a (relatively) new Linux user, coming to Linux at the end of Windows 7. I switched to Mint because of that. Installing Asymptote outside the Mint software manager is not that easy for newbie. So, as for LaTeX, Sagemath, etc ..., I use the official distribution version, usually much older than the current one. Usually the Mint maintainers make them compatible, (obviously not here!). I tried to install a more recent "deb" package but the dependencies are not satisfied. Installing from...
TeX is a 2D program. Asymptote lifts TeX font shapes to 3D but you will have to specify the color with an Asymptote pen, not using TeX.
Your problem is that you are using an obsolete verion of Asymptote that is over 2 years old. The current version 2.86 works fine with NVIDIA 545.29.06. I expect the 2.87 release will be made today.
I am using : System: Kernel: 6.5.0-18-generic x86_64 bits: 64 compiler: N/A Desktop: Cinnamon 6.0.4 tk: GTK 3.24.33 wm: muffin vt: 7 dm: LightDM 1.30.0 Distro: Linux Mint 21.3 Virginia base: Ubuntu 22.04 jammy and the software Asymptote 3D installed with the Software manager (Asymptote version 2.78 +ds-2). I use as MWE the following example downloaded from the web: https://asymptote.sourceforge.io/gallery/3Dgraphs/ https://asymptote.sourceforge.io/gallery/3Dgraphs/Viviani.asy The recommended NVIDIA...
An working example in 2D : import fontsize; unitsize(50); defaultpen(fontsize(20pt)+3); usepackage("xcolor"); dot((0, 1), 2bp + red); label("$(a + b)^3 = \mathcolor[RGB]{237, 128, 4}{a^3} + \mathcolor[RGB]{0, 112, 192}{3a^2b} + \mathcolor[RGB]{84, 178, 68}{3ab^2} + \mathcolor[RGB]{249, 61, 95}{b^3}$", (0, 0)); A not working example in 3D : import three; import fontsize; unitsize(50); defaultpen(fontsize(20pt)+3); usepackage("xcolor"); dot((0, 1, 0), 2bp + red); label("$(a + b)^3 = \mathcolor[RGB]{237,...
An working example in 2D : import fontsize; unitsize(50); defaultpen(fontsize(20pt)+3); usepackage("xcolor"); dot((0, 1), 2bp + red); label("$(a + b)^3 = \mathcolor[RGB]{237, 128, 4}{a^3} + \mathcolor[RGB]{0, 112, 192}{3a^2b} + \mathcolor[RGB]{84, 178, 68}{3ab^2} + \mathcolor[RGB]{249, 61, 95}{b^3}$", (0, 0)); A not working example in 3D : import three; import fontsize; unitsize(50); defaultpen(fontsize(20pt)+3); usepackage("xcolor"); dot((0, 1, 0), 2bp + red); label("$(a + b)^3 = \mathcolor[RGB]{237,...
oops : (2) doesn't work! You need the save(); at the beginning of the loops. I was too fast.
oops : (2) doesn't work! You need the save(); at the beginning of the loops.
I solved my problem : (1) animation anim; anim.global = false; (2) Technically only one save is needed: the first one. the next restores should restore the first save. It works but the more pictures you add the more time it takes to shipout the following picture. from 3s for the firsts to 1min after 25 pictures and 2min after40 pictures. the game is not worth the effort. Moreover the memory used is bigger. Maybe something to improve. (3) not resolved yet. I found an other way round: make my own shipout...
Some context : asy -version : 2.85 Linux RAM = 16 Gib Swap = 4 GiB Did I forgot the asy file ? So here it is : import solids; import animation; animation anim; settings.outformat = "webm"; unitsize(30); int a = 3, b = 2, n = 10; // I would like n = 20 or 50 transform3 s = rotate(120, (1, 1, 1)); transform3 t = reflect(O, X + Y, Z); transform3[] sigma3 = {identity4, t, s, s * t, s * s, s * s * t}; transform3[] rotations = {identity4, s, s * s}; pen[] surfacepen0 = {RGB(237, 128, 45), RGB(237, 128,...
Hello, In Asymptote WebGL, pressing Ctrl+C will copy the current projection. But in Asymptote web application http://asymptote.ualberta.ca/ the Ctrl+C event seems to be disabled. I wonder if there is a shortcut to copy the current projection in Asymptote web application. Thanks
I'm having troubles making animation. I have an animation of ~70 pictures each about 70Ko. When I run asy -f mpg myanimation.asy, my memory consumption grow up to 14Go !!!! First times I had to make a hard reset. How is it possible when the final result is only 650Ko ? Any clue ? Cyrille
Here's the file on github: https://github.com/vectorgraphics/asymptote/blob/template/examples/interpolate1.asy
Here's the text of interpolate1.asy: // Lagrange and Hermite interpolation in Asymptote // Author: Olivier Guibé import interpolate; import graph; // Test 1: The Runge effect in the Lagrange interpolation of 1/(x^2+1). unitsize(2cm); real f(real x) {return(1/(x^2+1));} real df(real x) {return(-2*x/(x^2+1)^2);} real a=-5, b=5; int n=15; real[] x,y,dy; x=a+(b-a)*sequence(n+1)/n; y=map(f,x); dy=map(df,x); for(int i=0; i <= n; ++i) dot((x[i],y[i]),5bp+blue); horner h=diffdiv(x,y); fhorner p=fhorner(h);...
I have a table I wish to interpolate as part of an intermediate calculation of a function I want to draw. The documentation is not clear on whether this can be done or not. It refers to an example Interpolate1.asy which I can't find. Can anyone help me out on this problem.
Hello I have installed Asymptote 2.86 Web App at the Windows 10 default directory. C:\Program Files\Asymptote. I want to read in data from a CSV file. What is the input file directory path? The lack on discussion on the Internet on the location of this path suggests that is this is well known - except to me. The following working example 'creates' a file. After execution, I cannot find the file on the C drive. file f = output("pathcode.dat"); write(f, 'apples'); close(f); /// presumably this means...
I have used Asymptote quite a bit and am now learning the Julia programming language. I feel that Julia is very similar to Asymptote programming especially in that both use multiple dispatch in defining functions. I would like to hear what any of you more familiar with Julia than I am think of this.
Hello, I don't understand why the first code doesn't give the same result as the second. Code_1 (bad result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); draw(c,P=orthographic(15,100,0)); Code_2 (good result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); currentprojection = orthographic(15,100,0); draw(c);
Hello, I don't understand why the first code doesn't give the same result as the second. Code_1 (bad result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); draw(c,P = orthographic(15,100,0)); Code_2 (good result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); currentprojection = orthographic(15,100,0); draw(c);
Hello, I don't understand why the first code doesn't give the same result as the second. Code_1 (bad result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); draw(c,P=orthographic(15,100,0)); Code_2 (good result). size(0,25mm); settings.render = 0; settings.prc = false; import solids; revolution c = cylinder(O,10,15,axis=X); currentprojection=orthographic(15,100,0); draw(c);
Thanks for the educational response, which completely answers my remaining question. For what it's worth, unless I am mistaken, in my testing, when I invoked Line 2, I always had Line 1 commented out. However, I was (still) invoking the line following Line 1, which is draw(q1, blue+1); draw(q2, red+1); So, either the above line caused 2D-3D output to be combined, or the problem is caused purely by my (obselete) use of Asymptote version 2.62. In any event, based on your response, with the 2D solution...
Using asy version 2.86, try running asy -config "" -k -V test where test.asy contains import graph; import three; // used for the unsuccessful surface attempt unitsize(1cm,1cm); limits((-2,0),(2,8)); xaxis("$x$",xmin=-2, xmax=2,axis=BottomTop(extend=true), ticks=LeftTicks(beginlabel=true,N=4,n=2,begin=true,end=true, extend=true,pTick=gray,ptick=lightgray),above=true); yaxis("$y$",ymin=0, ymax=8,axis=LeftRight(extend=true), ticks=RightTicks(beginlabel=true,N=4,n=2,begin=true,end=true, extend=true,pTick=gray,ptick=lightgray),above=true);...
It just occurred to me that I have underestimated the power of the evenodd approach. In unusual shading situations, you can manually identify a specific region to be shaded, and configure the path-1 ^^ path-2 specification appropriately for that specific region. So, the evenodd approach does generalize well.
At the very end of this document is a minimum working example that I saved as mwe.tex. The preamble of mwe.tex loads the hyperref package, so that the corresponding error may be generated. My compile procedure is pdflatex mwe asy mwe-1.asy pdflatex mwe I am running Asymptote version 2.62 under TeX Live 2019/Debian, on Linux Mint 20.3 Una. I need to tell Asymptote to shade the region between two functions. mwe.tex contains one line commented as Line 1, and a second line commented as Line 2. The shading...
It is the entire TeX file, but ... the error has now gone! I am embarrassed. I have no other observation than that there has been a restart of Windows between this morning, when I got the error, and now, in late evening, when I rerun. I am sorry to have been to bother. Ch
pdflatex doesn't do any rendering. Can you post the complete TeX file? Make sure you are running the 64 bit version of asy (e.g. the one that comes with TeXLive 2023), not the 32-bit version.
Sorry for that. The file is here includes as an attachment. A multiplication was missing e.g.
I get a bunch of errors, like no matching variable of name 'dx1x2' and similar. Maybe there are some characters missing in your post. Maurizio Il mercoledì 17 gennaio 2024, 11:33:51 CET, gustaf gustaf4711@users.sourceforge.net ha scritto: Hi, The scene is simple: two straight cylinders of different diameter and colour. They are L=1000 long.The scene is rendered either by asy or by pdflatex. Asis both asy and pdflatex run without problem. When L=10000 then asy runs but pdflatex returns with an "out...
Hi, The scene is simple: two straight cylinders of different diameter and colour. They are L=1000 long.The scene is rendered either by asy or by pdflatex. Asis both asy and pdflatex run without problem. When L=10000 then asy runs but pdflatex returns with an "out of memory" message. Is there a way to make pdflatex run, as asy does, without an "out of memory"? Regards, Christer Gustafsson Below is the small example. LaTeX runs with -f pdf -prc if EXIST tmp-.asy call F:\sys\Asymptote\asy.bat -f pdf...
I am trying to extend my ticks as in the example loggrid.asy. Using my attached code and not extending the ticks my output is shown in CBT36K_Filters-1.eps. If I uncomment the the code for the xaxis and yaxis for extending the ticks (and commenting the old xaxis and yaxis) the resulting output is shown in CBT36K_Filters-2.eps with the error message - yaxis("$y$",LeftRight,RightTicks(begin=false,end=false,extend=true,ptick=thin)); ^ ./CBT36K_Filters.asy: 141.13: use of variable 'LeftRight' is ambiguous...
If the attachment does not work, the link is also available at https://www.dropbox.com/scl/fi/uk5dvi0rrd2w729p137ev/asy-build-win32-msvc.zip?rlkey=ams7ko9s4cyzeuql8snclouqd&dl=0 Also, you may need to install the msvc redist if the build does not work. Otherwise, this binary is only for 64 bit systems and does not have 32 bit support.
Hi everyone, I am a seasonal developer of Asymptote who used to work full-time on the project in the past. My core works include GUI (xasy), OpenGL Shader infrastructure + PBR material models, LSP and image-based lighting mode. Recently, I have been working on an experimental build for windows that does not use Cygwin. This build depends only on the MSVC runtime + other linked libraries. Every feature (except for GNU libsigsegv) should be enabled ,though be warned this is not an official build and...
As before, with this line I get the pdf file but I also get the shipout failed error message. Maybe I should not worry too much about this error since I still get the pdf file. I am using ghostscript 10.02.1. I have attached the screen output in a text file.
Adding the line shipout(scale(1.0) * currentpicture.fit()); at the end of your example should produce the attached pdf file. If it doesn't, please add -vvvto your command line and post the screen output. What version of ghostscript are you using?
Thanks. Why does the shipout command disable the default OpenGL window and generate the shipout failed error?
The -V option (the default on Windows) display an interactive OpenGL window for 3D scenes, to allow you to adjust the camera viewpoint. Once you are ready to export the image, just press the ekey. Or disable the interactive OpenGL window with the -noVoption. By the way, settings.render=16 will generate 16 pixels per bp in each direction, which is likely excessive and will generate large files.
To keep things simple I use the following MWE: //file test.asy size(200,0); import three; currentprojection=orthographic(4,3,2); draw((0,0,0) -- (1,1,1), black+linewidth(1), arrow = Arrow3(DefaultHead2())); If I run it from the command line using asy -f pdf -render 16 test asymptote uses the OpenGL renderer to generate a window where the image can be moved using the mouse. After I close this window there is no pdf file saved. Next I add the following line at the end of the file: shipout(scale(1.0)...
Thanks; I've correct the path in the git repository to https://asymptote.sourceforge.io/gallery/3Dwebgl/vectorfieldsphere.html
Hi! I notice in the last sentense of graph3 as illustrated in the examples vectorfield3.asy and vectorfieldsphere.asy. but the file path vectorfieldsphere.asy doesn't exist: https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.asy and https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.html The file can be found on GitHub https://github.com/vectorgraphics/asymptote/blob/master/examples/vectorfieldsphere.asy
Hi! I notice in the last sentense of graph3 as illustrated in the examples vectorfield3.asy and vectorfieldsphere.asy. but the file path vectorfieldsphere.asy doesn't exist: https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.asy and https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.html
Hi! I notice that last sentense of graph3 as illustrated in the examples vectorfield3.asy and vectorfieldsphere.asy. but the file path vectorfieldsphere.asy doesn't exist: https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.asy and https://asymptote.sourceforge.io/gallery/3Dgraphs/vectorfieldsphere.html
Hi! I notice that last sentense of graph3 as illustrated in the examples vectorfield3.asy and vectorfieldsphere.asy. but the file path vectorfieldsphere.asy doesn't exist
It seems that updating to the latest version of Ghostscript (10.02.1) does not allow Asymptote to produce any pdf or png files. There is a config.asy file in .asy directory with the paths for Adobe Acrobat and ImageMagick. I am running Asymptote version 2.86 on Windows 10.
It seems that updating to the latest version of Ghostscript does not allow Asymptote to produce any pdf or png files. There is a config.asy file in .asy directory with the paths for Adobe and ImageMagick.
Thanks for the feedback ; its a bit embarrassing but I just realised I was using an outdated version of Ghostscript. For some reason when I type (Windows 10, 64-bit), asy -outformat="png" -render=16 test2_contour the program generates an image but does not save it. The same is the case if I use the -f jpg option to save it as a jpeg file.
Also, since you are working under MacOS, please be aware that MacOS doesn't support OpenGL SSBOs, which are required for implementing 3D transparency. So you need to remove +opacity(0.8) from your code. If you need transparency, you'll have to wait for the upcoming Vulkan port (currently in the vulkan branch and soon to be released) or work on another platform.
The image is best viewed with 3D graphics software like OpenGL. If you want to flatten the image to a 2D format, you will need to render it. You can increase settings.render to improve the resolution of the image. Don't use settings.render=0. I've attached the output of your example with the (hardcoded) settings settings.outformat = "png"; settings.render = 16; BTW, it's better not to hardcode these settings and specify them on the command line instead.
I am running Asymptote version 2.86 on MacOS 10.15.7 I have followed the Asymptote Tutorial and in particular pages 56-58 which deal with rendering. I want to show objects behind the surface with a different shading. Up to now the best solution I have found is as follows: settings.outformat = "pdf"; //settings.prc = false; //settings.render = 4; size(200,0); import three; import graph3; texpreamble("\usepackage{physics}"); //size(500,0); //settings.outformat = "pdf"; currentprojection=orthographic(4,3,2);...
The second label is in fact shifted by (3,5) PostScript (rather than user) units. Applying a shift to truesize objects such as labels moves them in PostScript coordinates. If you want to use units of exactly 1cm, you could do this: import graph; import geometry; import math; settings.tex="pdflatex"; picture pic; unitsize(pic,1cm,1cm); Label goldfish = graphic("fish.png","width=6cm, bb=0 0 469 275"); label(pic,goldfish,shift(3,5)*(0,0)); //Shifts label label(pic,shift(3cm,5cm)*goldfish,(0,0)); add(pic,grid(10,10));...
The second label is in fact shifted by (3,5) PostScript (rather than user) units. Applying a shift to truesize objects such as labels moves them in PostScript coordinates. If you want to use units of exactly 1cm, you could do this: import graph; import geometry; import math; settings.tex="pdflatex"; picture pic; unitsize(pic,1cm,1cm); Label goldfish = graphic("fish.png","width=6cm, bb=0 0 469 275"); label(pic,goldfish,shift(3,5)*(0,0)); //Shifts label label(pic,shift(3cm,5cm)*goldfish,(0,0)); //Does...
I am trying to apply the shift transformation to a label (a png image). Rotate and scale work when applied to the image but shift does nothing. I have attached code that demonstrates this problem along with the image I am using. I am looking for a solution that treats paths and labels (images) in the same manner. Any help would be appreciated.
I am trying to apply the shift transformation to a label (a png image). Rotate and scale work when applied to the image but shift does nothing. I have attached code that demonstrates this problem along with the image I am using. I am looking for a solution that treats paths and labels (images) in the same manner. Any help would be appreciated.
asy --help and the documentation already mention the render setting (but be aware that -render=0 does not in general handle hidden surface removal or lighting effects correctly). I've updated that example to use Spline interpolation.
Thank you , it is working. It would be also nice to mention this in --help output. Also another question: how to achieve smooth lines like in Gravity_well_plot.svg ?
SVG only supports 2D images, not 3D. So 3D images normally need to be rendered if OpenGL is enabled (make sure you have OpenGL enabled; check the output of asy --version to be sure). Asymptote includes an experimental facility using -render=0or settings.render=0 to approxximately flatten 3D images to 2D, which works ok in this case.
SVG only supports 2D images, not 3D. So 3D images normally need to be rendered if OpenGL (make sure you have OpenGL enabled; check the output of asy --version to be sure) Asymptote includes an experimental facility using -render=0or settings.render=0 to approxximately flatten 3D images to 2D, which works ok in this case.
Trying to reproduce this https://commons.wikimedia.org/wiki/File:Gravity_well_plot.svg but main image is always raster - tried eps, pdf and svg. Same result when using dvisvgm directly on dvi file produced with asy -k Software used Asymptote version 2.87-11 compiled from git dvisvgm 3.1.1 from Clear Linux bundle pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021 - CLR Linux)