Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Command = &cobra.Command{ Use: "color [flags] <hex|name>", Short: "Generate colors from a color", Example: ` # Using color name rong color hot_pink # Using #RGB format rong color '#F00' # Using #RRGGBB format rong color '#00FF00' # Get generate colors as json rong color green --dry-run --json | jq `, Args: cobra.ExactArgs(1), PreRun: func(cmd *cobra.Command, _ []string) { viper.BindPFlags(cmd.Flags()) }, RunE: func(_ *cobra.Command, args []string) error { name := strings.ToLower(args[0]) source, ok := Names[name] if !ok { src, err := color.ARGBFromHex(name) if err != nil { return err } source = src } slog.Info("Generating color", "from", source) primary := palettes.NewFromARGB(source) cfg, err := material.GetConfig() if err != nil { return err } scheme := dynamic.NewDynamicScheme(source.ToHct(), cfg.Variant, cfg.Constrast, cfg.Dark, cfg.Platform, cfg.Version, primary, nil, nil, nil, nil, nil, ) dcs := scheme.ToColorMap() colorMap := map[string]color.ARGB{} for key, value := range dcs { if value != nil { colorMap[key] = value.GetArgb(scheme) } } fg, bg := colorMap["on_background"], colorMap["background"] based := base16.GenerateRandom(fg, bg) output := models.NewOutput("", based, colorMap) if viper.GetBool("json") { json.NewEncoder(os.Stdout).Encode(output) } if !viper.GetBool("dry-run") { return templates.Execute(output) } return nil }, }
Command is the color command
View Source
var Names = map[string]color.ARGB{}/* 861 elements not displayed */
Names contains color names with their HEX values
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.