Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file geometry.ml
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798(***********************************************************************)(* *)(* Objective Caml *)(* *)(* François Pessaux, projet Cristal, INRIA Rocquencourt *)(* Pierre Weis, projet Cristal, INRIA Rocquencourt *)(* Jun Furuse, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1999-2004, *)(* Institut National de Recherche en Informatique et en Automatique. *)(* Distributed only by permission. *)(* *)(***********************************************************************)(* $Id: geometry.ml,v 1.1 2006/11/28 15:43:28 rousse Exp $*)(* geometry setting *)typesize=|Scaleoffloat|Pixelofint|Guesstypeaspect_opts=|Keep_at_most|Keep_at_least|Dont_keeptyperesize_switch=|Always|Bigger_only|Smaller_onlytypefrom=|TopLeft|BottomRight|Centertypeposition=|AtPixeloffrom*int|AtScaleoffrom*floattypet={geom_width:int;geom_height:int;geom_x:int;geom_y:int;}typespec={spec_width:size;spec_height:size;spec_aspect:aspect_opts;spec_switch:resize_switch;spec_x:int;spec_y:int;}letcomputespecorgworgh=letw,h=matchspec.spec_width,spec.spec_height,spec.spec_aspectwith|Scales,Guess,aspwhenasp<>Dont_keep->truncate(floatorgw*.s),truncate(floatorgh*.s)|Guess,Scales,aspwhenasp<>Dont_keep->truncate(floatorgw*.s),truncate(floatorgh*.s)|Scalesw,Scalesh,_(* asp is ignored *)->truncate(floatorgw*.sw),truncate(floatorgh*.sh)|Pixelw,Guess,aspwhenasp<>Dont_keep->lets=floatw/.floatorgwinw,truncate(floatorgh*.s)|Guess,Pixelh,aspwhenasp<>Dont_keep->lets=floath/.floatorghintruncate(floatorgw*.s),h|Pixelw,Pixelh,_(* asp is ignored *)->w,h|_->raise(Invalid_argument"Geometry.compute")inletscalew=floatw/.floatorgwandscaleh=floath/.floatorghinletscalew',scaleh'=matchspec.spec_aspectwith|Keep_at_most->ifscalew<scalehthenscalew,scalewelsescaleh,scaleh|Keep_at_least->ifscalew<scalehthenscaleh,scalehelsescalew,scalew|Dont_keep->scalew,scalehinletscalew'',scaleh''=matchspec.spec_switchwith|Always->scalew',scaleh'|Bigger_onlywhenscalew'>=1.0&&scaleh'>=1.0->scalew',scaleh'|Smaller_onlywhenscalew'<=1.0&&scaleh'<=1.0->scalew',scaleh'|_->1.0,1.0inletw'=ifscalew=scalew''thenwelsetruncate(floatorgw*.scalew'')andh'=ifscaleh=scaleh''thenhelsetruncate(floatorgh*.scaleh'')in{geom_width=w';geom_height=h';geom_x=spec.spec_x;geom_y=spec.spec_y;}