Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file draw.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150(**************************************************************************)(* *)(* Copyright (C) Johannes Kanig, Stephane Lescuyer *)(* Jean-Christophe Filliatre, Romain Bardou and Francois Bobot *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)(* *)(**************************************************************************)openPoint_libmoduleS=Spline_libletdraw_texcrtex=Cairo.savecr;Cairo.transformcrtex.Gentex.trans;Dvicairo.draw{Dvicairo.pic=cr;x_origin=0.;y_origin=0.}tex.Gentex.tex;Cairo.restorecr(*;Format.printf "Gentex : %a@." print tex*)moduleMetaPath=structtypepen=Matrix.tletcurve_tocrs=let_,sb,sc,sd=Spline.explodesinCairo.curve_tocrsb.xsb.ysc.xsc.ysd.xsd.yletdraw_pathcr=function|S.Pathp->(matchp.S.plwith|[]->assertfalse|x::_asl->letsa=Spline.left_pointxinCairo.move_tocrsa.xsa.y;List.iter(curve_tocr)l);ifp.S.cyclethenCairo.Path.closecr|S.Point_->failwith"Metapost fail in that case what should I do???"letstrokecrpen=function|S.Path_aspath->(*Format.printf "stroke : %a@." S.print path;*)draw_pathcrpath;Cairo.savecr;(*Matrix.set*)Cairo.transformcrpen;Cairo.strokecr;Cairo.restorecr|S.Pointp->(*Format.printf "stroke : %a@." S.print path;*)Cairo.savecr;Cairo.transformcr(Matrix.translationp);Cairo.transformcrpen;draw_pathcr(Metapath_lib.Approx.fullcircle1.);Cairo.fillcr;Cairo.restorecrletfillcrpath=draw_pathcrpath;Cairo.fillcrendmodulePicture=structopenConcrete_typesexceptionNot_implementedofstringletnot_implementeds=raise(Not_implementeds)letreccolorcr=function|OPAQUE(RGB(r,g,b))->Cairo.set_source_rgbcrrgb|OPAQUE(CMYK_)->not_implemented"cmyk"|OPAQUE(Grayg)->colorcr(OPAQUE(RGB(g,g,g)))|TRANSPARENT(a,RGB(r,g,b))->Cairo.set_source_rgbacrrgba|TRANSPARENT(_,CMYK_)->not_implemented"cmyk"|TRANSPARENT(a,Grayg)->colorcr(TRANSPARENT(a,RGB(g,g,g)))letcolor_optioncr=functionNone->()|Somec->colorcrcletdashcr=function|None|Some(_,[])->()|Some(ofs,l)->Cairo.set_dashcr(Array.of_listl)~ofsletinverseycrheight=Cairo.translatecr0.height;Cairo.scalecr1.(-1.)openPicture_libletrecdraw_auxcr=function|Empty->()|Transform(m,t)->Cairo.savecr;Cairo.transformcrm;(*Format.printf "Transform : %a@." Matrix.print m;*)draw_auxcrt;Cairo.restorecr|OnTopl->List.iter(draw_auxcr)l|Text->Cairo.savecr;Cairo.scalecr1.(-1.);draw_texcrt;Cairo.restorecr|Stroke_path(path,c,pen,d)->Cairo.savecr;color_optioncrc;dashcrd;MetaPath.strokecrpenpath;Cairo.restorecr|Fill_path(path,c)->Cairo.savecr;color_optioncrc;MetaPath.fillcrpath;Cairo.restorecr|Clip(com,p)->Cairo.savecr;MetaPath.draw_pathcrp;Cairo.clipcr;draw_auxcrcom;Cairo.restorecr|ExternalImage(filename,height,m)->Cairo.savecr;Cairo.transformcrm;inverseycrheight;letimg=Cairo.PNG.createfilenameinCairo.set_source_surfacecrimg~x:0.~y:0.;Cairo.paintcr;Cairo.restorecrletdrawcr_widthheightp=Cairo.savecr;inverseycrheight;Cairo.set_line_widthcrdefault_line_size;(* Only elliptical pens use the stroke command *)Cairo.set_line_capcrCairo.ROUND;Cairo.set_line_joincrCairo.JOIN_ROUND;draw_auxcr(contentp);Cairo.restorecrletwhere_cr_t(_x,_y)=not_implemented"where"letmove_t_id_p=not_implemented"move"end