This is the answer to the literal question. For an answer that is likely better to solve the task, see the awk solution in the "Notes" below.
Assuming that the patterns found in file1.txt can only ever occur at the beginning of lines in file2.txt, you can use the -f flag to read multiple search patterns from a file rather than stating them as RegExes on the command-line. The file would then need to be connected to the output of your first grep run.
One way to do this is process substitution:
grep -F -w -f <(grep -w 2 file1.txt) file2.txt
- The 
<( ... ) construct makes the output of the command enclosed in parentheses available as if it were a file. 
- The 
-F flag disables full RegEx search and is for safety and in case the output of the first grep run can contain characters with special meaning in the context of RegExes. It also speeds up the matching as literal string comparison is faster then RegEx matching. 
- The 
-w flag ensures that no partial matches find their way into the results. This is particularly advisable for the first grep run in case the first column of file1.txt can contain multi-digit numbers such as 12. 
Update
As noted by @Stéphane Chazelas, the -f option accepts the often (but not always) implemented value of - to refer to the program's stdin, so you can also write this as
grep -w 2 file1.txt | grep -F -w -f - file2.txt
with the more easily recognized pipe-method to read from the output of another command.
Note
This assumes the pattern number color can only occur as the first two columns of file2.txt. If it can also occur later on the line, as in
4 red square and 2 blue triangle
such a line would be misidentified as also matching.
 
For working with tabulated data (as seems to be the case here), awk is usually a better-suited tool. Your task could be achieved by the following awk program:
awk -v num="2" 'NR==FNR{if ($1==num){col[$2]}; next} ($1==num) && ($2 in col)' file1.txt file2.txt
This will process both files. The search key is specified via an awk variable num.
While processing the first file (where NR, the global line counter, is equal to FNR, the per-file line counter), it registers the color in the second column in the indices of an array col (hence no actual assignment to col[$2]) if the number in the first column matches. It then skips execution to the next line.
When processing the second file, it checks if the first column matches the num variable, and if the second column is found among the indices of the array col. If so, the line is printed.
 
     
    
2 blueappear anywhere else infile2.txt"by chance" (as in4 red square and 2 blue triangles), i.e. do you need full RegEx search for matching the lines infile2.txtagainst the output of the firstgrep? Are other standard text-processing tools also acceptable, or does it need to begrep?grep 2on the first grep match21 redor12 greenfrom the first file? should2 bluefrom file1 match2 blueish-greenfrom file 2.grep -E "$(grep 2 file1.txt| awk '{ORS="|"; print}'| head -c-1)" file2.txtsed,awk,perl, etc.?