[GAP Forum] Saving graphics
Asst. Prof. Dmitrii (Dima) Pasechnik
dima at ntu.edu.sg
Fri Feb 17 04:48:01 GMT 2012
On 17 February 2012 12:18, (((1/f))) <fadebox at gmail.com> wrote:
> Dear Forum,
>
> One of the exercises ( um, by Stephen Kohl I think ) gives the following
> solution for drawing an Ulam spiral of primes. I am not sure whether the
>
> "SaveAsBitmapPicture"
this needs RCWA package installed and loaded.
And it in turn needs a slew of other packages, such as anluth, which
in turn needs Kant,
and the latter is not even possible to install on some systems...
(fortunately the latter dependence is going away in the new
forthcoming release of GAP)
HTH,
Dmitrii
>
> function requires a special package. Does it? In either case,
> is there a document covering all the "export as graphic" tools
> in GAP?
>
> - Rohit Gupta
> -------------------------------------------------------------
>
> UlamSpiral := function ( size, filename )
>
> local spiral, smallprimes, n, p, r,
> middle, edgelength, edgepos, direction, i, j, zero, one;
>
> smallprimes := Filtered([2..size],IsPrimeInt);
> spiral := NullMat(size,size,GF(2));
>
> if size mod 2 = 0 then middle := [size/2,size/2];
> else middle := [(size + 1)/2,(size + 1)/2]; fi;
>
> zero := Zero(GF(2)); one := One(GF(2));
>
> spiral[middle[1]][middle[2]] := one;
>
> for p in smallprimes do
> i := middle[1]; j := middle[2];
> edgelength := 2; edgepos := 1; direction := 0; r := 1;
> for n in [2..size^2] do
> if direction = 0 then j := j + 1;
> elif direction = 1 then i := i + 1;
> elif direction = 2 then j := j - 1;
> elif direction = 3 then i := i - 1; fi;
> r := r + 1;
> edgepos := edgepos + 1;
> if r = p then
> if n > p then spiral[i][j] := one; fi;
> r := 0;
> fi;
> if edgepos = edgelength then
> direction := (direction + 1) mod 4;
> if direction in [0,2] then edgelength := edgelength + 1; fi;
> edgepos := 1;
> fi;
> od;
> od;
>
> SaveAsBitmapPicture(spiral,filename);
> end;
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum
CONFIDENTIALITY: This email is intended solely for the person(s) named and may be confidential and/or privileged. If you are not the intended recipient, please delete it, notify us and do not copy, use, or disclose its content.
Towards A Sustainable Earth: Print Only When Necessary. Thank you.
More information about the Forum
mailing list