forked from Source-Python-Dev-Team/Source.Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcolors.html
More file actions
165 lines (150 loc) · 8.35 KB
/
colors.html
File metadata and controls
165 lines (150 loc) · 8.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<title>colors — Source.Python v743 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
<link rel="stylesheet" type="text/css" href="../../_static/classic.css?v=2780edc4" />
<script src="../../_static/documentation_options.js?v=b6beb2eb"></script>
<script src="../../_static/doctools.js?v=9bcbadda"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<link rel="icon" href="../../_static/sp_wiki_favicon.png"/>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="commands" href="commands.html" />
<link rel="prev" title="auth" href="auth.html" />
</head><body>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="commands.html" title="commands"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="auth.html" title="auth"
accesskey="P">previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html"> Source.Python v743 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="../module_tutorials.html" accesskey="U">Module tutorials</a> »</li>
<li class="nav-item nav-item-this"><a href="">colors</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<section id="colors">
<h1>colors<a class="headerlink" href="#colors" title="Link to this heading">¶</a></h1>
<p>This page contains tutorials about the <a class="reference internal" href="../modules/colors.html#module-colors" title="colors"><code class="xref py py-mod docutils literal notranslate"><span class="pre">colors</span></code></a> package.</p>
<section id="do-s-and-don-ts">
<h2>Do’s and Don’ts<a class="headerlink" href="#do-s-and-don-ts" title="Link to this heading">¶</a></h2>
<p>When utilizing a color constant, you must not change it’s RGBA values as that
will change the value of the constant itself:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">colors</span><span class="w"> </span><span class="kn">import</span> <span class="n">RED</span>
<span class="nb">print</span><span class="p">([</span><span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">RED</span><span class="p">])</span>
<span class="n">RED</span><span class="o">.</span><span class="n">r</span> <span class="o">=</span> <span class="mi">128</span>
</pre></div>
</div>
<p>In the above example, if you reload the plugin, the value for RED.r has been
permanently changed. If you wish to get a different color, use the following
instead:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">colors</span><span class="w"> </span><span class="kn">import</span> <span class="n">Color</span>
<span class="kn">from</span><span class="w"> </span><span class="nn">colors</span><span class="w"> </span><span class="kn">import</span> <span class="n">RED</span>
<span class="c1"># You can just set the color directly using the Color object</span>
<span class="n">my_red</span> <span class="o">=</span> <span class="n">Color</span><span class="p">(</span><span class="mi">128</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">255</span><span class="p">)</span>
<span class="c1"># Or, you can utilize RED itself to create a different value</span>
<span class="n">my_red</span> <span class="o">=</span> <span class="n">Color</span><span class="p">(</span><span class="o">*</span><span class="n">RED</span><span class="p">)</span>
<span class="n">my_red</span><span class="o">.</span><span class="n">r</span> <span class="o">=</span> <span class="mi">128</span>
</pre></div>
</div>
<p>Getting a different alpha value is a little bit easier:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span><span class="w"> </span><span class="nn">colors</span><span class="w"> </span><span class="kn">import</span> <span class="n">RED</span>
<span class="c1"># Again, you DO NOT want to use the following</span>
<span class="n">RED</span><span class="o">.</span><span class="n">a</span> <span class="o">=</span> <span class="mi">128</span>
<span class="c1"># Instead, use the "with_alpha" method of the Color object</span>
<span class="n">my_red</span> <span class="o">=</span> <span class="n">RED</span><span class="o">.</span><span class="n">with_alpha</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span>
</pre></div>
</div>
</section>
</section>
<div class="clearer"></div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="Main">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../../index.html">
<img class="logo" src="../../_static/sp_wiki_banner.png" alt="Logo of Source.Python"/>
</a></p>
<div>
<h3><a href="../../index.html">Table of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">colors</a><ul>
<li><a class="reference internal" href="#do-s-and-don-ts">Do’s and Don’ts</a></li>
</ul>
</li>
</ul>
</div>
<div>
<h4>Previous topic</h4>
<p class="topless"><a href="auth.html"
title="previous chapter">auth</a></p>
</div>
<div>
<h4>Next topic</h4>
<p class="topless"><a href="commands.html"
title="next chapter">commands</a></p>
</div>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../../_sources/developing/module_tutorials/colors.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<search id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
<input type="submit" value="Go" />
</form>
</div>
</search>
<script>document.getElementById('searchbox').style.display = "block"</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="Related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="commands.html" title="commands"
>next</a> |</li>
<li class="right" >
<a href="auth.html" title="auth"
>previous</a> |</li>
<li class="nav-item nav-item-0"><a href="../../index.html"> Source.Python v743 documentation</a> »</li>
<li class="nav-item nav-item-1"><a href="../module_tutorials.html" >Module tutorials</a> »</li>
<li class="nav-item nav-item-this"><a href="">colors</a></li>
</ul>
</div>
<div class="footer" role="contentinfo">
© Copyright 2025, Source.Python Development Team.
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.
</div>
</body>
</html>