graphics

نوشته شده در موضوع خرید اینترنتی در 05 ژوئن 2018

Here’s a chronicle of a duty that generalizes a era of time face to concede we to simply change a character of a numbers, a series of “hours”, and a radius of a face:

Options[clockFace] = {FontFamily - "Georgia", FontSize - 30};
clockFace[hours_Integer, radius_?NumericQ, opts : OptionsPattern[]] /;
   hours  0  Im[radius] == 0  radius  0 :=
 With[{range = Range[12]},
  With[{objects = 
        Style[#, 
          FilterRules[{opts}, Options[Style]] ~Join~ Options[clockFace]]  /@ range,
       thetas = Pi/2 - 2 Pi*range/hours},
  Graphics[Append[
     MapThread[Text[#1, {Cos[#2], Sin[#2]}] , {objects, thetas}],
     Circle[radius*1.2]]]]]

Some things are only Mathematica character issues; for instance,

FilterRules[{opts}, Options[Style]] ~Join~ Options[clockFace]

is only a approach to pass a germane discretionary arguments to Style while creation certain that clockFace‘s default values are used where relevant, since Mathematica will use a initial germane sequence that it finds in a list of manners (and duty options are only lists of rules). we also used With to name things, that is since there’s that nesting; other people competence cite to use a singular Module. Either way, it’s always best to make things internal variables whenever possible.

The biggest change, though, was generating a list of numbers in order, regulating Range, and afterwards adjusting a clarification of thetas so all winds adult in a right place. we consider it’s most easier to see what’s going on, since a reduction pointer means you’re relocating around clockwise and offsetting by Pi/2 creates it transparent you’re starting during a tip of a clock.

Article source: https://stackoverflow.com/questions/8187378/drawing-clock-face-in-mathematica-looking-for-a-better-solution

tiger pelak 2 graphics

دیدگاهتان را بنویسید

نشانی ایمیل شما منتشر نخواهد شد.

*

code